pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Check that commutator/negator operators return the same data typ 3+ messages / 1 participants [nested] [flat]
* pgsql: Check that commutator/negator operators return the same data typ @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Check that commutator/negator operators return the same data type. The commutator or negator of an operator must surely return the same data type as the operator itself (always boolean for a negator, but for a commutator it could be any type). CREATE/ALTER OPERATOR failed to enforce this, providing a route for evildoers to reach type-confusion problems. Another ancient oversight in this feature is that if the first CREATE OPERATOR names a commutator or negator, but no corresponding clause appears in the CREATE OPERATOR that fills in the shell operator, we failed to preserve the shell operator's back-link, resulting in inconsistent catalog state. That has to be considered part of the security problem, since it prevents checking whether the two operators have matching result types. However, fixing it means that an operator created without any COMMUTATOR or NEGATOR clause at all can acquire a commutator/negator, if it overwrites a shell operator that links to such a sibling object. That creates a new security problem: an attacker could set up a trojan-horse operator that names a commutator/negator operator that doesn't exist yet, but that the attacker expects to be created later. Then the attacker has the potential to inject his own code into uses of that victim operator. The object_ownercheck() test in OperatorCreate() doesn't prevent that if the second operator is created by a superuser. To fix this, we change that test to insist on exact equality of creating user. (This tightening could potentially break innocent use-cases, except that it's hard to foresee innocent cases where the two operators wouldn't be created by the same role. The logic does not prevent either operator from being reassigned to a new owner later.) In v16 and earlier, this fix incorporates portions of commit 2b5154bea. Before that, there were yet other scenarios for creating inconsistent commutator/negator links, potentially allowing type confusion. I also adopted some of the cosmetic refactoring done in that commit, just to make pg_operator.c look less different across branches. In master, this deletes OperatorUpd() in favor of an expanded function UpdateOperatorLinks(). In the back branches, OperatorUpd() is kept to preserve ABI compatibility. I doubt there are any external callers, but as a one-line wrapper it's cheap enough to not worry about. Reported-by: Stephan Lipp <Stephan@Adalogics.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116335 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/28e164e1de25887aea7db4f2066cb4ce508decc4 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/backend/catalog/pg_operator.c | 223 ++++++++++++++++++++++---- src/backend/commands/operatorcmds.c | 13 +- src/include/catalog/pg_operator.h | 3 +- src/test/regress/expected/alter_operator.out | 12 ++ src/test/regress/expected/create_operator.out | 122 +++++++++++++- src/test/regress/sql/alter_operator.sql | 14 ++ src/test/regress/sql/create_operator.sql | 110 ++++++++++++- 7 files changed, 456 insertions(+), 41 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Check that commutator/negator operators return the same data typ @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Check that commutator/negator operators return the same data type. The commutator or negator of an operator must surely return the same data type as the operator itself (always boolean for a negator, but for a commutator it could be any type). CREATE/ALTER OPERATOR failed to enforce this, providing a route for evildoers to reach type-confusion problems. Another ancient oversight in this feature is that if the first CREATE OPERATOR names a commutator or negator, but no corresponding clause appears in the CREATE OPERATOR that fills in the shell operator, we failed to preserve the shell operator's back-link, resulting in inconsistent catalog state. That has to be considered part of the security problem, since it prevents checking whether the two operators have matching result types. However, fixing it means that an operator created without any COMMUTATOR or NEGATOR clause at all can acquire a commutator/negator, if it overwrites a shell operator that links to such a sibling object. That creates a new security problem: an attacker could set up a trojan-horse operator that names a commutator/negator operator that doesn't exist yet, but that the attacker expects to be created later. Then the attacker has the potential to inject his own code into uses of that victim operator. The object_ownercheck() test in OperatorCreate() doesn't prevent that if the second operator is created by a superuser. To fix this, we change that test to insist on exact equality of creating user. (This tightening could potentially break innocent use-cases, except that it's hard to foresee innocent cases where the two operators wouldn't be created by the same role. The logic does not prevent either operator from being reassigned to a new owner later.) In v16 and earlier, this fix incorporates portions of commit 2b5154bea. Before that, there were yet other scenarios for creating inconsistent commutator/negator links, potentially allowing type confusion. I also adopted some of the cosmetic refactoring done in that commit, just to make pg_operator.c look less different across branches. In master, this deletes OperatorUpd() in favor of an expanded function UpdateOperatorLinks(). In the back branches, OperatorUpd() is kept to preserve ABI compatibility. I doubt there are any external callers, but as a one-line wrapper it's cheap enough to not worry about. Reported-by: Stephan Lipp <Stephan@Adalogics.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116335 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/420586131fa9ecd7363f3cc0f86b0d2034bfabac Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/backend/catalog/pg_operator.c | 236 ++++++++++++++++++++++---- src/backend/commands/operatorcmds.c | 13 +- src/include/catalog/pg_operator.h | 3 + src/test/regress/expected/alter_operator.out | 12 ++ src/test/regress/expected/create_operator.out | 122 ++++++++++++- src/test/regress/sql/alter_operator.sql | 14 ++ src/test/regress/sql/create_operator.sql | 110 +++++++++++- 7 files changed, 470 insertions(+), 40 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Check that commutator/negator operators return the same data typ @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Check that commutator/negator operators return the same data type. The commutator or negator of an operator must surely return the same data type as the operator itself (always boolean for a negator, but for a commutator it could be any type). CREATE/ALTER OPERATOR failed to enforce this, providing a route for evildoers to reach type-confusion problems. Another ancient oversight in this feature is that if the first CREATE OPERATOR names a commutator or negator, but no corresponding clause appears in the CREATE OPERATOR that fills in the shell operator, we failed to preserve the shell operator's back-link, resulting in inconsistent catalog state. That has to be considered part of the security problem, since it prevents checking whether the two operators have matching result types. However, fixing it means that an operator created without any COMMUTATOR or NEGATOR clause at all can acquire a commutator/negator, if it overwrites a shell operator that links to such a sibling object. That creates a new security problem: an attacker could set up a trojan-horse operator that names a commutator/negator operator that doesn't exist yet, but that the attacker expects to be created later. Then the attacker has the potential to inject his own code into uses of that victim operator. The object_ownercheck() test in OperatorCreate() doesn't prevent that if the second operator is created by a superuser. To fix this, we change that test to insist on exact equality of creating user. (This tightening could potentially break innocent use-cases, except that it's hard to foresee innocent cases where the two operators wouldn't be created by the same role. The logic does not prevent either operator from being reassigned to a new owner later.) In v16 and earlier, this fix incorporates portions of commit 2b5154bea. Before that, there were yet other scenarios for creating inconsistent commutator/negator links, potentially allowing type confusion. I also adopted some of the cosmetic refactoring done in that commit, just to make pg_operator.c look less different across branches. In master, this deletes OperatorUpd() in favor of an expanded function UpdateOperatorLinks(). In the back branches, OperatorUpd() is kept to preserve ABI compatibility. I doubt there are any external callers, but as a one-line wrapper it's cheap enough to not worry about. Reported-by: Stephan Lipp <Stephan@Adalogics.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116335 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/165bbc265631f937b6396df3bfcac7e6520618e3 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/backend/catalog/pg_operator.c | 236 ++++++++++++++++++++++---- src/backend/commands/operatorcmds.c | 13 +- src/include/catalog/pg_operator.h | 3 + src/test/regress/expected/alter_operator.out | 12 ++ src/test/regress/expected/create_operator.out | 122 ++++++++++++- src/test/regress/sql/alter_operator.sql | 14 ++ src/test/regress/sql/create_operator.sql | 110 +++++++++++- 7 files changed, 470 insertions(+), 40 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-09 14:21 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-09 14:21 pgsql: Check that commutator/negator operators return the same data typ Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Check that commutator/negator operators return the same data typ Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Check that commutator/negator operators return the same data typ Noah Misch <noah@leadboat.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox