From: dwsteele (@dwsteele) <noreply+dwsteele@github.com>
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Subject: Re: [pgaudit/pgaudit] issue #335: SET pgaudit.log = 'none' isn’t logged, leaving no trace that auditing was disabled
Date: Sun, 25 Oct 2026 18:14:59 +0000
Message-ID: <gh-pgaudit-pgaudit-335-c6401329233@github.com> (raw)
In-Reply-To: <gh-pgaudit-pgaudit-335@github.com>
References: <gh-pgaudit-pgaudit-335@github.com>
This has come up before in #78. We decided not to do it then and I think that still makes sense.
The `pgaudit.*` settings can only be changed by a superuser. A superuser has many ways to disable or work around pgAudit, and logging the `SET` would only catch the most obvious one. For example, the same setting can be passed as a connection option:
```sh
psql "dbname=postgres options='-c pgaudit.log=none'"
```
No statement is executed so there is nothing for pgAudit to log. Some other options are `SELECT set_config('pgaudit.log', 'none', false)`, which is only logged when the `read` class is enabled, or `ALTER ROLE ... SET pgaudit.log = 'none'` followed by a reconnect.
If we logged `SET pgaudit.log = 'none'` it would give a false sense of security. The absence of a `SET pgaudit.log` entry in the log would not mean that auditing was left enabled for the session.
As noted in the [Caveats](https://github.com/pgaudit/pgaudit#caveats) section of the README, it is not possible to reliably audit superusers with pgAudit. Our recommendation is to restrict access to superuser accounts and use the [set_user](https://github.com/pgaudit/set_user) extension to escalate privileges when required. set_user logs the escalation, sets `log_statement = 'all'` for the escalated session and blocks `SET log_statement`, `ALTER SYSTEM` and `COPY PROGRAM` by default.