Skip to content

Reject clients who match an existing st_client row #2748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gefjon
Copy link
Contributor

@gefjon gefjon commented May 16, 2025

Description of Changes

At various places in our codebase, we assume that client connections are unique by (identity, connection_id) pair,
but we never actually enforced this prior to now.
It was difficult, but not impossible, to accidentally connect with an already-present (identity, connection_id) pair. The easiest way was to open two DbConnections in parallel from within a single Rust client SDK process,
due to a misbehavior in that SDK which I intend to fix in a separate PR.

This commit modifies MutTxId::insert_st_client to return an error if the row to be inserted is already resident in the database. It's still possible for a database owner to delete from st_client manually via a SQL delete statement, which will cause strange misbehaviors, but it should no longer be possible for an unprivileged client to accidentally put the database into a state that's intended to be impossible.

API and ABI breaking changes

N/a

Expected complexity level and risk

1

Testing

At various places in our codebase, we assume that client connections
are unique by `(identity, connection_id)` pair,
but we never actually enforced this prior to now.
It was difficult, but not impossible, to accidentally connect
with an already-present `(identity, connection_id)` pair.
The easiest way was to open two `DbConnection`s in parallel
from within a single Rust client SDK process,
due to a misbehavior in that SDK which I intend to fix in a separate PR.

This commit modifies `MutTxId::insert_st_client` to return an error
if the row to be inserted is already resident in the database.
It's still possible for a database owner to delete from `st_client` manually
via a SQL `delete` statement, which will cause strange misbehaviors,
but it should no longer be possible for an unprivileged client
to accidentally put the database into a state that's intended to be impossible.
@gefjon gefjon marked this pull request as draft May 16, 2025 18:11
@gefjon
Copy link
Contributor Author

gefjon commented May 16, 2025

Marking as draft because I still need to write an automated test for this, but I'm putting it on the back burner as higher priority tickets have surfaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant