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.
Feature/tenant isolation audit #625
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Feature/tenant isolation audit #625
Changes from all commits
6f83d76ab5edc5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: unconditional mock-token path is an authentication bypass in production.
Any client can send
Authorization: Bearer mock-token-master-...to be authenticated asmaster_admin, ormock-token-<company>-<role>-<id>to impersonate any tenant/role — Supabase validation is skipped entirely. There is no environment guard, so this is reachable in production and defeats the tenant isolation this PR introduces. The same family of bypass exists formock-resource IDs inverify_resource_ownership(Line 171) andmock-user-IDs inmain.py::get_user_by_id.Gate all mock paths behind an explicit, default-off env flag.
🔒 Proposed fix (apply the same guard to the other mock paths)
token = credentials.credentials # --- MOCK TOKENS FOR TESTING / OFFLINE MODE --- - if token.startswith("mock-token-"): + if os.getenv("ENABLE_MOCK_AUTH") == "1" and token.startswith("mock-token-"):🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inner HTTPExceptions are swallowed and rewritten to a generic 401.
The broad
except Exceptioncatches the deliberateHTTPException(401, "Invalid or expired token.")andHTTPException(403, "User profile not registered.")and re-raises everything as401 "Authentication failed.", discarding the intended status/detail (the 403 case can never surface). Add anexcept HTTPException: raisebefore the catch-all, and chain withfrom e(addresses Ruff B904).🛠️ Proposed fix
🧰 Tools
🪛 Ruff (0.15.14)
[warning] 116-116: Do not catch blind exception:
Exception(BLE001)
[warning] 118-121: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.