Skip to content

Firewall: Rules [new] - remove direct "Config::getInstance()->save()" #10198

Closed

Description

@Monviech

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug

When having a user with "user-config-readonly", it can safe the config by e.g. changing logging or moving a rule in the new firewall rules.

Tip: to validate your setup was working with the previous version, use opnsense-revert (https://docs.opnsense.org/manual/opnsense_tools.html#opnsense-revert)

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'System -> Access -> Users'
  2. Create a new user:
    • Username: test
    • Group membership: admins
    • Privileges: System: Deny config write
  3. Go to "Firewall - Rules [new]"
  4. Toggle Logging of a rule
  5. Config is saved

Expected behavior

Config is not saved

Most likely this:

Environment

Software version used and hardware type if relevant, e.g.:

OPNsense 26.1.6

Activity

  1. AdSchellevis commented on Apr 23, 2026

    @AdSchellevis
    Member

    well, actually, Config::getInstance()->save(); shouldn't be called without checking.

  2. Monviech commented on Apr 23, 2026

    @Monviech
    MemberAuthor

    Does this need a wrapper around Config::getInstance()->save(); that does this check that is needed before calling it, or is such a check already built-in somewhere?

    I did take a quick look here but nothing caught my eye:

    public function save($revision = null, $backup = true)

  3. AdSchellevis commented on Apr 23, 2026

    @AdSchellevis
    Member

    no, frontend callers should guarantee consistency in this case, in this case we should probably just call $this->save() instead of the current serializeToConfig() + Config::getInstance()->save() currently used.

    if (!(new ACL())->hasPrivilege($this->getUserName(), 'user-config-readonly')) {

  4. Monviech commented on Apr 23, 2026

    @Monviech
    MemberAuthor

    I understand. I will take this one. Thanks for pointing the boundary out.

  5. changed the title [-]core: "Config::getInstance()->save()" seems to be an edgecase of privilege "user-config-readonly"[/-] [+] Firewall: Rules [new] - remove direct "Config::getInstance()->save()"[/+] on Apr 23, 2026
  6. added this to the 26.7 milestone on Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugProduction bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions