Repository navigation
Conversation
UpdateRLSRuleCommand only checked datasource access on the submitted tables when the payload carried `tables`. A caller could therefore rebind a rule from a datasource they cannot access to one they can, lifting the filter from the former. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Muk4ptfk2ka1wrxivBHH7U
| # tables, which lifts the filter from the tables it leaves. The caller | ||
| # must therefore access the rule's current tables, and the new ones | ||
| # when ``tables`` is present. | ||
| raise_for_datasource_access(self._model.tables) |
There was a problem hiding this comment.
Suggestion: A concurrent rebind after this check lets a caller authorized only for the old table modify the rule now bound to an inaccessible table; this transaction takes no lock.
Assessment: 🔴 Critical · 🔁 Occurrence: Rarely · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/commands/security/update.py
**Line:** 76:76
**Comment:**
*Race Condition: A concurrent rebind after this check lets a caller authorized only for the old table modify the rule now bound to an inaccessible table; this transaction takes no lock.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
This check-then-write window exists in every Superset command (RLS create/delete and the partial-update branch from #41294 included); none of them lock. Exploiting it needs a privileged user to rebind the rule within the same few milliseconds, which the caller cannot trigger. Locking only here would make this command the odd one out, and it does nothing on SQLite. This PR closes the deterministic rebind bypass and opens nothing new, so I'd keep it focused.
There was a problem hiding this comment.
✅ Customized review instruction saved!
Instruction:
Do not flag the existing check-then-write race in this update command as a new regression; recommend locking only when it can be addressed consistently across commands and supported backends.
Applied to:
superset/commands/security/update.py
💡 To manage or update this instruction, visit: CodeAnt AI Settings
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45214 +/- ##
=======================================
Coverage 86.42% 86.42%
=======================================
Files 3183 3184 +1
Lines 222605 222615 +10
Branches 52996 53003 +7
=======================================
+ Hits 192377 192386 +9
- Misses 26758 26759 +1
Partials 3470 3470
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EnxDev
left a comment
There was a problem hiding this comment.
Read through this and the change is right. On master a role with RLS write and access to dataset B but not A could move a rule from A to B and lift the filter from A, because only the submitted tables were checked. Checking self._model.tables unconditionally closes that, and the new test covers exactly that path.
No inline notes. Agree with leaving the check-then-write window alone here, it's the same across the RLS commands.
sha174n
left a comment
There was a problem hiding this comment.
Approving. This closes a real authorization gap: before this change the update command only validated access against the submitted tables when the payload carried tables, so a caller authorized for the target dataset but not the rule's current one could rebind the rule and drop its filter off a dataset they are not allowed to manage. Moving the current-tables check so it always runs, then additionally checking the submitted tables, makes a rebind require access to both the old and the new datasources, which is the right invariant and keeps the create/delete commands consistent. The partial-update protection from the earlier change is preserved since the old else-branch is just folded into the unconditional call.
The new unit test is a proper red-green: it fails on master and passes here, and it asserts the rebind is refused because of the rule's existing table rather than the submitted one.
On the concurrent-rebind note: agree with keeping this focused. That check-then-write window is present uniformly across these commands and is not introduced here; addressing it piecemeal in one command (and as a no-op on SQLite) would be inconsistent. Worth a separate, cross-command discussion if we want row locking at all.
One optional follow-up: consider a companion test for the mirror case (caller holds the current table but not the new target) to lock the both-ends requirement explicitly. Not blocking.
SUMMARY
#40650 enforces datasource access in the RLS rule commands, and #41294 extends the check to partial updates that omit
tables. When the payload does carrytables, though,UpdateRLSRuleCommandonly checks the submitted tables. A caller with access to dataset B but not to dataset A can therefore rebind a rule from A to B, which lifts the filter from A.The update now always checks the rule's current tables, then the submitted ones when
tablesis present.TESTING INSTRUCTIONS
pytest tests/unit_tests/commands/security/rls_test.pyThe new test
test_update_rls_rule_forbidden_when_retargeting_away_from_denied_tablesfails on master and passes with this change.ADDITIONAL INFORMATION
Affects unreleased code only: #40650 is not in 6.1.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Muk4ptfk2ka1wrxivBHH7U