Skip to content
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

release-22.1: admin: statement diagnostics uses correct auth helpers #99055

Merged

Conversation

dhartunian
Copy link
Collaborator

Previously, the statement diagnostics HTTP handler was initialized using the incorrect ctx value. This caused the HTTP request context to not be correctly handed down to the handler. Furthermore, the call to userFromIncomingRPCContext was incorrect in this scenario since it relied on a gRPC context being populated with HTTP session information, which did not exist. That code sets a root user when context is missing because the gRPC handlers are used for inter-node communication and HTTP with the DB console and external tools.

This commit attaches the request context to the diagnostics bundle handler correctly, and amends the authorization code to use userFromHTTPAuthInfoContext which correctly reads the session cookie info from the request (like many api/v2 handlers do since those exist outside the gRPC infrastructure).

Resolves #99049

Epic: None

Release note (security update): Previously, users could gain unauthorized access to statement diagnostic bundles they did not create if they requested the bundle through an HTTP request to /_admin/v1/stmtbundle/<id> and correctly guessed its (non-secret) ID. This change locks down this endpoint behind the usual SQL gating that correctly uses the SQL user in the HTTP session as identified by their cookie.


Release justification: security bug

@dhartunian dhartunian requested a review from a team March 20, 2023 20:09
@dhartunian dhartunian requested a review from a team as a code owner March 20, 2023 20:09
@dhartunian dhartunian changed the title admin: statement diagnostics uses correct auth helpers release-22.1: admin: statement diagnostics uses correct auth helpers Mar 20, 2023
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dhartunian dhartunian force-pushed the release-22.1-stmtdiag-fix branch 4 times, most recently from 1655b41 to 79fb33b Compare March 20, 2023 22:47
Previously, the statement diagnostics HTTP handler was initialized using the
incorrect `ctx` value. This caused the HTTP request context to not be correctly
handed down to the handler. Furthermore, the call to
`userFromIncomingRPCContext` was incorrect in this scenario since it relied on
a gRPC context being populated with HTTP session information, which did not
exist. That code sets a `root` user when context is missing because the gRPC
handlers are used for inter-node communication *and* HTTP with the DB console
and external tools.

This commit attaches the request context to the diagnostics bundle handler
correctly, and amends the authorization code to use
`userFromHTTPAuthInfoContext` which correctly reads the session cookie info
from the request (like many `api/v2` handlers do since those exist outside the
gRPC infrastructure).

Resolves cockroachdb#99049

Epic: None

Release note (security update): Previously, users could gain unauthorized
access to statement diagnostic bundles they did not create if they requested
the bundle through an HTTP request to `/_admin/v1/stmtbundle/<id>` and
correctly guessed its (non-secret) ID.  This change locks down this endpoint
behind the usual SQL gating that correctly uses the SQL user in the HTTP
session as identified by their cookie.
@dhartunian dhartunian force-pushed the release-22.1-stmtdiag-fix branch from 79fb33b to a94bdad Compare March 21, 2023 00:30
@dhartunian dhartunian merged commit 6ea872a into cockroachdb:release-22.1 Mar 21, 2023
@dhartunian dhartunian deleted the release-22.1-stmtdiag-fix branch March 21, 2023 01:35
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.

3 participants