fix(analytics): scope /analytics/query + /sql to the caller (RLS) (#2852)#2854
Merged
Conversation
) handleAnalytics dropped the request's execution context — analyticsService.query(body) was called with no context, so the analytics read-scope provider (getReadScope → security getReadFilter) received undefined and applied NO tenant/RLS filter. An authenticated caller could query analytics datasets and receive rows their row-level security would otherwise hide. Thread context.executionContext into query() and generateSql() (both already accept it) so each object is scoped by its per-object read filter. The analytics getReadFilter does not yet apply the ADR-0090 D10 agent delegator intersection — latent (analytics isn't reachable over /mcp), tracked in #2852. Found by the D10 adversarial security review. Test: dispatcher asserts the execution context now reaches query/generateSql. runtime http-dispatcher 165 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 15 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the reachable part of #2852. Found by the ADR-0090 D10 adversarial security review.
The hole
handleAnalytics(the/api/v1/analytics/*dispatcher) received the request context as_context(unused) and calledanalyticsService.query(body)with no execution context. The analytics service's per-object read-scope provider (getReadScope→ securitygetReadFilter) therefore gotundefinedand applied no tenant/RLS filter — so an authenticated caller hittingPOST /analytics/queryreceived rows their row-level security would otherwise hide.The fix
Thread
context.executionContextintoanalyticsService.query(…)andgenerateSql(…)— both already accept an optionalExecutionContext. Each object in the query is now scoped by its per-object read filter (tenant + RLS), matching the/analytics/dataset/querybridge path which already threads it.Residual (tracked in #2852)
The analytics read-scope provider (
getReadFilterin plugin-security) does not yet apply the ADR-0090 D10 agent delegator intersection. This is latent today — analytics is not reachable over the OAuth/mcpsurface, so no agent principal drives it — but it should be brought in lock-step with the engine middleware when analytics becomes agent-reachable.Tests
queryandgenerateSql.runtimehttp-dispatcher suite 165 green.🤖 Generated with Claude Code