Repository navigation
A tracker credential is read-only only when every grant is a known read - #243
Merged
Merged
Conversation
review_grants compared upper-cased access types against a deny-list that held displaySecretsInShowAndSelect in mixed case, and it dropped the part after TO where WITH GRANT OPTION and WITH ADMIN OPTION appear, so all three passed as read-only. The check is now an allow-list: SELECT, SHOW of databases/tables/columns/dictionaries, dictGet and CREATE TEMPORARY TABLE; any other type, an option to pass a grant on, or a line it cannot parse is refused. Column lists no longer split on their inner commas. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…p tables A backtick-quoted column holding `(`, `,` or ` ON ` hid the access types after it from the check. Quoted names are now blanked out before the line is split, an unbalanced quote refuses the line, and each type must be a name with at most one column list. CREATE ARBITRARY TEMPORARY TABLE is no longer read access. GrantReview.write_types is now refused, since it also holds grant options and unparsed lines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The probe now also runs SHOW GRANTS FINAL, which merges the grants of the user's roles into its own, so a role holding INSERT or a grant option is refused like a direct grant. The direct SHOW GRANTS still names the roles reported back. A line with more than one ON clause is refused as unparsed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
GrantReview drops its unread raw-lines field, the roles comment no longer calls them opaque, and a server that refuses SHOW GRANTS FINAL is told that loom needs it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
An exception is always truthy, so `e or type(e).__name__` never fell back to the type name; the message now reads str(e). The source-add roles field description no longer calls roles opaque to the check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
SHOW GRANTS FINAL merges a role chain's access types but drops the role lines, so an admin option on a role granted to a role reached neither statement. The probe now reads system.enabled_roles, which lists every role in the chain with its admin option, and refuses a granted role that is not a default role, since its chain is not enabled and cannot be seen. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The role-name decoder reverses every backslash escape in one pass, and the refusal for a granted role missing from system.enabled_roles says it is not among the enabled roles rather than guessing why. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…es its fix A line such as `GRANT on TO u` split into no types and no roles and was skipped; it is now refused. A granted role that is not enabled is kept apart from the refused grants, so the refusal says to run SET DEFAULT ROLE ALL instead of asking for a SELECT-only user, and a role granted WITH ADMIN OPTION is named once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The dashboard appended "create a user with SELECT only" to every CREDENTIAL_NOT_READONLY message, which was wrong for a role that is not a default role and doubled the server's advice otherwise; the server message now holds the advice and the dashboard shows it as is. The SET DEFAULT ROLE and ALTER USER hints quote a user name that is not a plain identifier. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Whitespace in a SHOW GRANTS line collapses only outside quoted names, and \b and \f decode, so such a role matches its system.enabled_roles row. A clickhouse-local test pins that SHOW GRANTS FINAL carries the access types of a non-default role chain two levels down while neither statement shows its nested admin option. The probe tests share one fake server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…only GrantReview.roles holds each role's name rather than its SHOW GRANTS quoting, so the roles field and the refusal messages name a role the same way. The dashboard no longer asks the registrant to judge the roles, since the check reads their grants, and the record contract page says a server that refuses SHOW GRANTS FINAL is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…hey cover Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
review_roles mutated the review review_grants returned, and each removed duplicates; review_grants now takes both inputs and returns the finished review. The roles field comments read as one sentence each. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/tracker-grant-review-fail-closed
branch
from
November 4, 2026 04:31
969184c to
5934c0e
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
tracker.source.add,tracker.source.inspect,tracker.source.rotateandtracker.source.set_mappingrefuse a credential that holdsdisplaySecretsInShowAndSelect, a grantWITH GRANT OPTIONorWITH ADMIN OPTION, or any access type beyondSELECT,SHOW,dictGetandCREATE TEMPORARY TABLE, held directly or through a granted role, nested roles included, and a credential with a granted role that is not a default role. Such credentials were accepted as read-only.Why
Failing cases:
review_grants(["GRANT displaySecretsInShowAndSelect ON *.* TO u"]).read_only,GRANT SELECT ON db.* TO u WITH GRANT OPTIONandGRANT r1 TO u WITH ADMIN OPTIONwere allTrue.Pattern: the read-only check was a deny-list compared in a different case and a different part of the line than where the entries appear. The set held
displaySecretsInShowAndSelectin mixed case while the code compared upper-cased types, and the twoOPTIONentries only appear afterTO, which the parser drops. A deny-list also passes any access type it does not list.A granted role was also never inspected: the probe ran a bare
SHOW GRANTS, which lists a role by name and not what it grants, soGRANT writer TO loom_rowithwriterholdingINSERTpassed.Fix: the check is an allow-list. The probe runs
SHOW GRANTS(for the role names it reports back) andSHOW GRANTS FINAL, which merges each granted role's grants into the user's. A credential is read-only when every access type in both isSELECT,SHOW(databases, tables, columns, dictionaries),dictGetorCREATE TEMPORARY TABLE, compared upper-case, and no line grantsWITH GRANT OPTIONorWITH ADMIN OPTION.SHOW GRANTS FINALdrops role lines, so an admin option on a role granted to a role reaches neither statement. The probe also readssystem.enabled_roles(one of the tables every user can read), which lists each role in the chain with its admin option, and refuses one that has it. It refuses a granted role that is not a default role, because its chain is not enabled and cannot be seen.Any other type, any line that is neither
GRANTnorREVOKE, a line with an unbalanced quote, a line with more than oneONclause and aGRANTline with noONorTO, or with no names before it, are refused. Quoted names (columns, roles, users) are blanked out before the line is split, so a backtick-quoted column holding(,,orONcannot hide the types after it, and column lists (SELECT(a, b)) are split only on commas outside the parentheses. Each type must be a name with at most one column list.CREATE ARBITRARY TEMPORARY TABLEis not read access.GrantReview.write_typesis renamedrefused, since it also holds grant options and unparsed lines;GrantReview.grants(the raw lines, read by nothing) is removed;not_enabledholds granted roles missing from the enabled roles;rolesholds role names unquoted. The dashboard's roles line after a passing check now says the roles grant read access only.Scope and risk
Touches
server/tracker/app/onboarding.py(review_grants, which now also takes the enabled roles,GrantReview.refusal, andprobe_credential, which now also runsSHOW GRANTS FINALand readssystem.enabled_roles), the refusal message inserver/tracker/app/sources.py, and the dashboard's read-only check row, which now shows the server's message as is instead of appending its own advice. Granted roles are still reported back by name.SHOW GRANTS FINALmerges every granted role, default or not, and follows roles granted to roles (both checked withclickhouse localafterSET DEFAULT ROLE NONE), so a role the session has not enabled, or one two levels down, is checked too. Break: a credential holding a type outside the list (for exampleINTROSPECTION,SHOW ACCESSorCREATE ARBITRARY TEMPORARY TABLE) or any grantWITH GRANT OPTIONis now refused withCREDENTIAL_NOT_READONLY, and so is one whose granted role holds such a type, and one granted a role that is not a default role (fixed withSET DEFAULT ROLE ALL TO <user>). A server that does not acceptSHOW GRANTS FINALis refused asSOURCE_UNREACHABLE, with a message that names the statement. The check runs on add, rotate, inspect (alsoinspectby name, with the stored credential) andset_mapping(stored credential), so a registered source whose credential holds such a grant cannot be inspected by name or remapped until its credential is rotated. Reads of a registered source are not re-checked.Compatibility, rollout and rollback
CREDENTIAL_NOT_READONLYmessage now reads "holds more than read access (...)", or, for a role that is not a default role, names it and says to runSET DEFAULT ROLE ALL TO <user>.Tests
tests/unit/test_tracker_source_add.py::test_grant_review_refuses_what_it_cannot_classify_as_read_onlyfailed before the fix on thedisplaySecretsInShowAndSelectline and passes now. It also covers bothOPTIONforms,SHOW NAMED COLLECTIONS, an unknown type,CREATE ARBITRARY TEMPORARY TABLE, quoted columns holding(,,andONin front ofINSERT, an unbalanced quote, quoted role and user names, a role grantedWITH ADMIN OPTION, a column list and aREVOKEline.tests/unit/test_tracker_onboarding_host.py::test_probe_reviews_the_grants_a_role_carriesdrivesprobe_credentialwith a fake client whose onlyINSERTcomes from a role and asserts it is refused. It also feeds an admin option on a nested role throughsystem.enabled_roles;test_role_review_refuses_a_role_that_is_not_enabled_or_holds_an_admin_optioncovers a non-default role and a nested admin option.test_probe_names_the_grant_statement_the_server_refusedcovers a server that rejectsSHOW GRANTS FINAL.test_show_grants_final_carries_what_a_role_chain_grantsrunsSHOW GRANTSandSHOW GRANTS FINALthroughclickhouse localfor a non-default role chain withINSERTtwo levels down and a nested admin option, and asserts the review refuses theINSERTand that neither statement shows the admin option (skipped without the binary). The other grant lines match what a 26.3 server prints for those grants (checked withclickhouse local:displaySecretsInShowAndSelectin mixed case,WITH ADMIN OPTIONon a role line, andFINALdropping the role lines and carrying the role'sWITH GRANT OPTION). Ranmake format lint typecheck, the tracker source, onboarding, public-copy, doc-link and agent-instruction unit tests, andvitest run src/flows/TrackerSourceDialogs.test.tsx.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I checked the failing cases against the old code and that the allow-list keeps the documented
loom_rogrants read-only.I can explain every line of this diff and how it interacts with the rest of Loom.
🤖 Generated with Claude Code