adapter: authorize retained ALTER CONNECTION dependencies - #38486
Conversation
ggevay
left a comment
There was a problem hiding this comment.
LGTM, minor comments, plus one comment about a potential followup.
| guaranteed system-wide. Always ask: "does this still work if another node is | ||
| running the same code against the same backing store?" | ||
|
|
||
| ### System-session replanning does not grant authority |
There was a problem hiding this comment.
(Just double-checking if it was intentional to add this here, because we sometimes have over-eager AI additions in this file.)
There was a problem hiding this comment.
the AI did at it but I left it in because it maybe felt useful, but could also remove it again, we should always be fine to cut things here, btw, even after we merge
| during replanning. Before reading secrets, performing external I/O, or | ||
| persisting the result, authorize the final dependency set against the invoking | ||
| session. Check the final set rather than the union of old and new dependencies, | ||
| so a caller can remove a dependency they are no longer authorized to use. |
There was a problem hiding this comment.
Not for this PR, but worth a follow-up: the final-set rule does not cover tunnel-type connections. The owner of an SSH TUNNEL / AWS PRIVATELINK connection needs only ownership to change its HOST / SERVICE NAME, its own dependency set is empty, and handle_alter_connection re-renders every dependent through the new tunnel. The dependents' secrets then go to whatever the attacker's bastion connects them to, on any transport short of full hostname verification against a CA the attacker cannot influence: PG require/verify-ca and MySQL required/verify_ca never verify the hostname and fall back to system roots without a custom CA, Kafka SASL_PLAINTEXT has no TLS at all, and PrivateLink-tunneled Kafka defaults endpoint identification to none even on SASL_SSL. Same ownership premise as H01, and the tunnel creator can also be the attacker with no transfer involved. Maybe add a sentence here that a definition's peer can also change through a referenced tunnel connection.
| guaranteed system-wide. Always ask: "does this still work if another node is | ||
| running the same code against the same backing store?" | ||
|
|
||
| ### System-session replanning does not grant authority |
There was a problem hiding this comment.
nit, if the section stays: it lands between "No local-only assumptions" and the timestamp checklist, which belongs to the timestamp material above. Consider moving it below the checklist so that block stays contiguous.
ALTER CONNECTION initially authorizes only dependencies named in the submitted statement. Replanning the complete stored definition with a system session can retain secrets that the caller is not allowed to use. Authorize the final dependency set against the invoking session before reading secrets or validating the connection. This also permits callers to remove dependencies they can no longer use. Closes: SQL-654
38c474b to
392dfe0
Compare
Motivation
ALTER CONNECTIONinitially authorizes only dependencies named in the submitted statement. Replanning the complete stored definition with a system session can retain secret dependencies that the caller is not allowed to use, then read those secrets during content checks or connection validation.Description
Connection owners can no longer change connection options while retaining secrets or connections they lack
USAGEprivileges on. Authorize the fully reconstructed connection's final dependency set against the invoking session before any secret reads or validation. The check applies even when validation is disabled, and it uses the final set so callers can remove dependencies they are no longer authorized to use.The SQL privilege documentation describes the additional requirement. The adapter guide records the authorization boundary for DDL that replans stored definitions with a system session.
Verification
Added sqllogictest coverage that transfers a secret-bearing connection to a role without secret access, verifies alterations are denied until
USAGEis granted, and verifies the role can remove an inaccessible secret dependency.Added testdrive coverage that denies validated option changes before external validation while preserving delegated
VALIDATE CONNECTIONaccess to an unchanged connection.Closes: SQL-654