Skip to content

fix: tighten object-level and destination checks across four unrelated endpoints - #44036

Merged
sadpandajoe merged 4 commits into
masterfrom
fix/oauth2-guest-token-semantic-layer-boundaries
Sep 22, 2026
Merged

sadpandajoe merged 4 commits into
masterfrom
fix/oauth2-guest-token-semantic-layer-boundaries

Conversation

@rusackas

@rusackas rusackas commented Sep 9, 2026

Copy link
Copy Markdown
Member

SUMMARY

Four independent fixes, bundled into one PR for review efficiency (each touches a different subsystem, no shared root cause):

superset/db_engine_specs/base.py, gsheets.py, snowflake.py, config.py — a database's own encrypted_extra.oauth2_client_info sets authorization_request_uri/token_request_uri with no host validation. The token endpoint is POSTed to directly by the server, carrying the connection's client_secret in the body. Validates both endpoint hosts (is_safe_host, matching the existing pattern in db_engine_specs/impala.py's cancel_query and reports/notifications/webhook.py) before use, with an opt-out config flag (DATABASE_OAUTH2_ALLOW_INTERNAL_HOSTS) for legitimately internal identity providers.

superset/security/manager.py — validate_guest_token_resources only checked that a dashboard exists and is embedded, never that the principal minting the token actually has access to it. Adds a raise_for_access(dashboard=...) check.

superset/commands/semantic_layer/update.py — masked configuration fields were restored from the stored value unconditionally, without checking whether other submitted fields also changed in the same request. Refuses to reveal a masked field when anything else in the payload differs from what's stored.

superset/views/utils.py — get_dashboard_extra_filters resolved a dashboard by id with only a chart-membership check, no access check. Chart reuse across dashboards means chart access doesn't imply dashboard access. Adds a raise_for_access(dashboard=...) check, failing closed to an empty filter list.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend-only changes, no UI impact.

TESTING INSTRUCTIONS

Regression tests added for all four; each was verified to fail without its corresponding fix and pass with it.

pytest tests/unit_tests/db_engine_specs/ tests/unit_tests/security/ tests/unit_tests/commands/semantic_layer/ tests/unit_tests/semantic_layers/ tests/unit_tests/views/ tests/unit_tests/commands/chart/

2718 passed, 1 skipped.

ADDITIONAL INFORMATION

  • Has associated issue
  • Required feature flags
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Confirm DB Migration upgrade and downgrade tested
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5aa31a

Actionable Suggestions - 0
Additional Suggestions - 5
  • superset/db_engine_specs/base.py - 1
    • CWE-918: SSRF DNS Rebinding · Line 983-983
      `is_safe_host` resolves the hostname at validation time, but `requests.post(uri, ...)` re-resolves it when the connection opens. An attacker-controlled domain that passes validation and then re-resolves to an internal IP (DNS rebinding) can exfiltrate the `client_secret` in the POST body. The webhook path already closes this via `_PeerValidatingHTTPAdapter` (webhook.py:106-147); apply the same peer-address check here. ([CWE-918](https://cwe.mitre.org/data/definitions/918.html))
  • tests/unit_tests/views/test_utils.py - 1
    • Dead patches in deny test · Line 190-200
      In `test_get_dashboard_extra_filters_denies_unauthorized_dashboard`, the `_check_dashboard_access` and `build_extra_filters` patches are dead: `raise_for_access` is patched to raise `SupersetSecurityException`, so `get_dashboard_extra_filters` returns `[]` at the `except` clause (views/utils.py:516-517) before reaching `get_dashboard_filter_context` or `build_extra_filters`. Remove these two patches to avoid implying those paths are exercised.
  • superset/config.py - 1
    • Undocumented config flag · Line 2742-2742
      This new security-relevant flag is not documented, while the other `DATABASE_OAUTH2_*` flags are listed in `docs/user_docs_versioned_docs/version-6.0.0/configuration/databases.mdx`. Since it relaxes SSRF protections, operators need it discoverable. Add it to the OAuth2 config docs with its default (`False`) and the warning that it should stay off when untrusted users can edit database connections.
  • superset/views/utils.py - 1
    • Redundant auth check · Line 514-517
      `raise_for_access(dashboard=...)` now runs twice on the same path: here and again inside `get_dashboard_filter_context` via `_check_dashboard_access` (dashboard_filter_context.py:302). The new check is what converts the exception into a graceful `[]` return, but the duplicate authorization work (slice/datasource resolution) is redundant and risks divergence. Consider consolidating to a single check.
  • tests/unit_tests/db_engine_specs/test_base.py - 1
    • Broad autouse SSRF mock · Line 956-965
      The `autouse=True` fixture patches `is_safe_host` to return `True` for the entire file, silently disabling SSRF host validation for any test in this file that exercises a path using it. The dedicated SSRF tests override it, but a future test relying on real `is_safe_host` behavior would be masked. Consider scoping the mock to only the OAuth2 tests that need it.
Review Details
  • Files reviewed - 15 · Commit Range: 4ec3612..4ec3612
    • superset/commands/semantic_layer/update.py
    • superset/config.py
    • superset/db_engine_specs/base.py
    • superset/db_engine_specs/gsheets.py
    • superset/db_engine_specs/snowflake.py
    • superset/security/manager.py
    • superset/views/utils.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
    • tests/unit_tests/db_engine_specs/test_base.py
    • tests/unit_tests/db_engine_specs/test_databricks.py
    • tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
    • tests/unit_tests/db_engine_specs/test_snowflake.py
    • tests/unit_tests/db_engine_specs/test_trino.py
    • tests/unit_tests/security/manager_test.py
    • tests/unit_tests/views/test_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/db_engine_specs/base.py Resolved
Comment thread superset/db_engine_specs/base.py Resolved
Comment thread superset/db_engine_specs/base.py Resolved
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.03419% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.65%. Comparing base (43fee87) to head (6e2fe30).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
superset/commands/database/utils.py 75.00% 3 Missing and 1 partial ⚠️
superset/security/manager.py 84.00% 2 Missing and 2 partials ⚠️
superset/utils/network.py 89.47% 3 Missing and 1 partial ⚠️
superset/commands/database/update.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #44036    +/-   ##
========================================
  Coverage   80.65%   80.65%            
========================================
  Files        2942     2942            
  Lines      175692   175803   +111     
  Branches    40788    40805    +17     
========================================
+ Hits       141705   141800    +95     
- Misses      31325    31336    +11     
- Partials     2662     2667     +5     
Flag Coverage Δ
hive 37.13% <23.07%> (-0.03%) ⬇️
mysql 56.35% <34.18%> (-0.03%) ⬇️
postgres 56.37% <34.18%> (-0.04%) ⬇️
presto 39.01% <23.07%> (-0.03%) ⬇️
python 84.96% <88.03%> (+<0.01%) ⬆️
sqlite 56.08% <34.18%> (-0.03%) ⬇️
unit 76.78% <86.32%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
rusackas force-pushed the fix/oauth2-guest-token-semantic-layer-boundaries branch from 4ec3612 to 309ecaf Compare September 9, 2026 01:23
@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Sep 9, 2026
@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #91b652

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/views/utils.py - 1
    • Redundant access check · Line 514-517
      This check duplicates the access evaluation already performed inside `get_dashboard_filter_context` (via `_check_dashboard_access` → `raise_for_access(dashboard=dashboard)`). For dashboards without explicit viewers, `raise_for_access` iterates all member slices and issues a datasource query per unique datasource, so the expensive evaluation now runs twice per granted call. Consider catching `SupersetSecurityException` around the `get_dashboard_filter_context` call instead.
  • superset/commands/semantic_layer/update.py - 1
    • CWE-200: Secret Reveal on Field Removal · Line 105-113
      The guard only iterates `new_configuration.items()`, so it detects changed/added keys but not keys removed from the stored config. Reusing a masked secret while removing a destination-relevant field (e.g. `host`) passes through, restoring the real secret while the removed field falls back to a connector default — contradicting the docstring's "any other field changing at all is treated as unsafe." Consider also rejecting when `any(key not in new_configuration for key in existing_configuration)`.
  • tests/unit_tests/views/test_utils.py - 1
    • Redundant test mocks · Line 191-191
      In `test_get_dashboard_extra_filters_denies_unauthorized_dashboard`, the `_check_dashboard_access` and `build_extra_filters` patches are never exercised: `get_dashboard_extra_filters` calls `security_manager.raise_for_access` (line 515) which raises, so it returns `[]` at line 517 before reaching `get_dashboard_filter_context`/`build_extra_filters`. These mocks mislead readers about which access check is validated. Consider dropping them.
  • tests/unit_tests/utils/test_network.py - 1
    • Inline imports to module level · Line 183-185
      These imports are placed inline inside the test bodies. Per repo standard (BITO.md rule 12745), imports belong at module level unless a circular dependency exists (none here). Move `HTTPConnection` and `_PeerValidatingHTTPConnection` to the top-level import block for consistency with the rest of the file.
Review Details
  • Files reviewed - 18 · Commit Range: cc6ad51..309ecaf
    • superset/commands/semantic_layer/update.py
    • superset/config.py
    • superset/db_engine_specs/base.py
    • superset/db_engine_specs/gsheets.py
    • superset/db_engine_specs/snowflake.py
    • superset/security/manager.py
    • superset/utils/network.py
    • superset/views/utils.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
    • tests/unit_tests/db_engine_specs/test_base.py
    • tests/unit_tests/db_engine_specs/test_databricks.py
    • tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
    • tests/unit_tests/db_engine_specs/test_gsheets.py
    • tests/unit_tests/db_engine_specs/test_snowflake.py
    • tests/unit_tests/db_engine_specs/test_trino.py
    • tests/unit_tests/security/manager_test.py
    • tests/unit_tests/utils/test_network.py
    • tests/unit_tests/views/test_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #91b652

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/security/manager.py - 1
    • Backward-compat regression risk · Line 5365-5368
      This new `raise_for_access(dashboard=...)` check changes observable behavior for existing deployments: a non-Admin role holding only `grant_guest_token` (a realistic 'embedding backend service' grant) that previously minted tokens for any embedded dashboard will now get `EmbeddedDashboardAccessDeniedError`. The hardening is sound, but it is a breaking change — please document it and note that such roles must be granted dashboard-level access.
  • superset/utils/network.py - 1
    • Duplicated SSRF validation logic · Line 65-151
      The docstring says this was "factored out" so call sites can reuse it, but `superset/reports/notifications/webhook.py` still carries its own verbatim copies of `_raise_for_unsafe_peer`, the `_PeerValidating*Connection/Pool` classes, `_PeerValidatingHTTPAdapter`, and `_get_requester`. Two copies of security-critical SSRF logic can drift. Consider migrating `webhook.py` to import these shared symbols.
  • superset/views/utils.py - 1
    • Silent access-denial swallow · Line 514-517
      When `raise_for_access(dashboard=...)` denies access, this silently returns `[]`, so `ChartWarmUpCacheCommand` proceeds without the dashboard's default filters yet `/warm_up_cache/` still reports success. Consider re-raising so `run()` surfaces the access error, or at least log the denial, to avoid misleading operators into thinking the dashboard was warmed with its filters.
Review Details
  • Files reviewed - 18 · Commit Range: cc6ad51..309ecaf
    • superset/commands/semantic_layer/update.py
    • superset/config.py
    • superset/db_engine_specs/base.py
    • superset/db_engine_specs/gsheets.py
    • superset/db_engine_specs/snowflake.py
    • superset/security/manager.py
    • superset/utils/network.py
    • superset/views/utils.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
    • tests/unit_tests/db_engine_specs/test_base.py
    • tests/unit_tests/db_engine_specs/test_databricks.py
    • tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
    • tests/unit_tests/db_engine_specs/test_gsheets.py
    • tests/unit_tests/db_engine_specs/test_snowflake.py
    • tests/unit_tests/db_engine_specs/test_trino.py
    • tests/unit_tests/security/manager_test.py
    • tests/unit_tests/utils/test_network.py
    • tests/unit_tests/views/test_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/security/manager.py Resolved
@github-actions github-actions Bot added the api Related to the REST API label Sep 10, 2026
@netlify

netlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 6e2fe30
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aaf076dca653b0008d05215
😎 Deploy Preview https://deploy-preview-44036--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #a24a1d

Actionable Suggestions - 1
  • superset/security/api.py - 1
Review Details
  • Files reviewed - 4 · Commit Range: 309ecaf..9de81a7
    • superset/commands/semantic_layer/update.py
    • superset/security/api.py
    • tests/integration_tests/security/api_tests.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/security/api.py Resolved
Comment thread superset/db_engine_specs/base.py Resolved
Comment thread superset/security/manager.py Resolved
Comment thread superset/utils/network.py Resolved
@bito-code-review

bito-code-review Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #413136

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/utils/network.py - 1
    • CA bundle disabled by trust_env · Line 155-155
      `session.trust_env = False` also disables `REQUESTS_CA_BUNDLE`/`CURL_CA_BUNDLE` (requests 2.33.0 `merge_environment_settings` reads them only when `trust_env` is True). Deployments using a private CA for OAuth2 token endpoints (`get_oauth2_token`/`get_oauth2_fresh_token` in `db_engine_specs/base.py`) will now fail TLS verification. Consider re-applying the operator-configured CA bundle to `session.verify` explicitly (e.g. read `REQUESTS_CA_BUNDLE`/`CURL_CA_BUNDLE` from the environment and set `session.verify` accordingly), remembering to import `os`.
  • superset/commands/database/utils.py - 1
    • Inconsistent endpoint field · Line 137-141
      `redirect_uri` is not a destination the client secret is posted to: `OAuth2ClientConfigSchema` auto-populates it via `load_default=get_oauth2_redirect_uri` at read time, and the frontend `OAuth2ClientField` never submits it. Including it in the endpoint-change check is inconsistent with the secret-rebind rationale and could cause a false-positive block if it is ever persisted. Consider dropping it from the tuple.
Review Details
  • Files reviewed - 9 · Commit Range: 9de81a7..9c7d15b
    • superset/commands/database/exceptions.py
    • superset/commands/database/update.py
    • superset/commands/database/utils.py
    • superset/security/api.py
    • superset/security/manager.py
    • superset/utils/network.py
    • tests/unit_tests/commands/databases/utils_test.py
    • tests/unit_tests/security/manager_test.py
    • tests/unit_tests/utils/test_network.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 19, 2026
rusackas and others added 4 commits September 19, 2026 14:52
…d endpoints

Four independent fixes, bundled together for review efficiency (each
touches a different subsystem, no shared root cause):

- superset/db_engine_specs/base.py, gsheets.py, snowflake.py, config.py:
  a database's own encrypted_extra.oauth2_client_info sets
  authorization_request_uri/token_request_uri with no host validation.
  The token endpoint is POSTed to directly by the server, carrying the
  connection's client_secret in the body. Validate both endpoint hosts
  (is_safe_host, matching the existing pattern in
  db_engine_specs/impala.py's cancel_query and
  reports/notifications/webhook.py) before use, with an opt-out config
  flag for legitimately internal identity providers.

- superset/security/manager.py: validate_guest_token_resources only
  checked that a dashboard exists and is embedded, never that the
  principal minting the token has access to it. A narrower
  can_grant_guest_token grant (a realistic non-Admin "embedding backend
  service" role) could mint a valid guest token scoped to any embedded
  dashboard in the instance.

- superset/commands/semantic_layer/update.py: masked configuration
  fields were restored from the stored value unconditionally, without
  checking whether other submitted fields also changed. An editor could
  reveal a masked secret while changing an unrelated field in the same
  request, persisting the secret against changed configuration.

- superset/views/utils.py: get_dashboard_extra_filters resolved a
  dashboard by id with only a chart-membership check, no access check.
  Chart reuse across dashboards means chart access doesn't imply
  dashboard access.

Regression tests added for all four; each verified to fail without its
corresponding fix and pass with it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ing gap; tighten semantic layer secret-reveal check

The OAuth2 endpoint host check validated the hostname up front but the
actual POST could still be redirected to an internal target by the
remote server, or reach a different address than validated via DNS
rebinding. Route token requests through a peer-validating requester
and stop following redirects. Also make the scheme check unconditional
(previously skippable via DATABASE_OAUTH2_ALLOW_INTERNAL_HOSTS) and
guard urlparse against a bare ValueError on malformed input.

Separately, the semantic layer secret-reveal guard used dict.get(key)
to detect unchanged fields, which can't distinguish a key that's
absent from one explicitly stored as None -- a new None-valued key
could slip through as "unchanged" alongside a revealed secret.
…ig changes in semantic layer unmask

Review follow-ups (sadpandajoe):
- security/api.py: validate_guest_token_resources now raises
  EmbeddedDashboardAccessDeniedError (a ForbiddenError), but the guest_token
  endpoint only translated not-found and validation errors, so @safe turned an
  expected denial into a logged 500. Translate it to 403.
- semantic_layer/update.py: the masked-secret guard iterated only submitted keys,
  so reusing the mask while dropping a stored key slipped through even though the
  update replaces the stored dictionary wholesale. Removed keys now count as a
  configuration change too.
- Tests for both (unit for the unmask helper, API-level for the 403).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… proxy hardening

- security/api.py: FAB 5.x response_403() takes no message, so the 403 mapping raised
  TypeError and still produced a 500 (caught by the integration test); build the 403 with
  self.response(403, ...). Also pass the datasets claim into resource validation.
- security/manager.py: validate_guest_token_resources now requires the minting principal
  to be entitled to every datasource the token will grant (or the datasets allowlist), not
  just to the dashboard: raise_for_access(dashboard=...) is satisfied on a non-RBAC
  dashboard by access to any one member datasource. Admin/editor/RBAC-viewer callers are
  covered by the dashboard entitlement itself. Unit tests for all three paths.
- commands/database: changing the OAuth2 endpoint URIs inside masked_encrypted_extra while
  reusing the masked client secret is now refused like any other destination rebind
  (oauth2_endpoint_rebind_unsafe); tests added, error message extended.
- utils/network.py: the protected session ignores environment proxies (trust_env=False):
  a proxied request bypasses the peer-validating pools, and the peer would be the proxy
  anyway. Deployments needing a proxy use the documented allow_unsafe_hosts opt-in.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@rusackas
rusackas force-pushed the fix/oauth2-guest-token-semantic-layer-boundaries branch from 9c7d15b to 6e2fe30 Compare September 19, 2026 22:06
@rusackas rusackas removed the requires:rebase Requires rebasing on top of current master label Sep 19, 2026

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #1bb6d0

Actionable Suggestions - 1
  • superset/commands/database/utils.py - 1
Additional Suggestions - 7
  • superset/utils/network.py - 1
    • Proxy/CA support disabled · Line 155-155
      `session.trust_env = False` disables HTTP(S)_PROXY/NO_PROXY and REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE for the OAuth2 token requests. The previous `requests.post` honored these, so deployments behind a mandatory proxy or using a private CA for their IdP will now fail the token exchange; the only opt-out (`allow_unsafe_hosts=True`) disables SSRF protection entirely. This is documented, but it is a behavioral regression for proxy/private-CA deployments worth surfacing.
  • tests/unit_tests/db_engine_specs/test_base.py - 3
    • Discarded requester mock · Line 1082-1082
      `_mock_requester(mocker)` is consumed inline as `_mock_requester(mocker).return_value.post`, so the `MagicMock` from `mocker.patch` is only reachable through `mock_post`. These tests therefore cannot assert requester-level behavior (e.g. `assert_called_once_with(allow_unsafe_hosts=False)` as the new redirect tests do). Bind the patch mock to a variable first, then take `.return_value.post`.
    • Helper return type Any · Line 1348-1348
      `_mock_requester` returns the `MagicMock` produced by `mocker.patch`, but is annotated `-> Any`, discarding type information for all callers; repo rules require explicit return type annotations on helper functions in test files. Annotate it `-> MagicMock` (importing from `unittest.mock`).
    • Untyped mock variables · Line 1453-1453
      The new tests bind mock variables without type annotations (`is_safe_host` at 1429/1453/1482/1502, `mock_get_requester`/`mock_post` at 1378/1454-1455 and siblings); repo rules require explicit annotations such as `is_safe_host: MagicMock = mocker.patch(...)` on all mock variables in test files.
  • superset/views/utils.py - 1
    • Silent access-denial swallow · Line 514-517
      The new `SupersetSecurityException` guard returns `[]` silently. The deny itself is intentional and unit-tested, but without a log record an operator debugging why warm-up skips dashboard filters for a given user has no trace. `logger` already exists in this module and `security_manager` logs access decisions elsewhere; consider a `logger.warning` with `dashboard.id`/`slice_id` before returning.
  • tests/unit_tests/db_engine_specs/test_gsheets.py - 1
    • Unit tests hit real DNS · Line 706-709
      These tests mock `get_ssrf_safe_requester` but not `is_safe_host`. The new `_validate_oauth2_endpoint_host` call in `get_oauth2_token`/`get_oauth2_fresh_token` invokes `is_safe_host('oauth2.googleapis.com')`, which does a real `socket.getaddrinfo` lookup. That makes the unit tests depend on external DNS and fail in offline/restricted CI or if DNS returns a non-public IP. Patch `is_safe_host` (or `_validate_oauth2_endpoint_host`) to keep them hermetic.
  • superset/commands/database/utils.py - 1
    • Duplicated endpoint field list · Line 138-142
      `OAUTH2_ENDPOINT_FIELDS` duplicates the endpoint names already enumerated in `_handle_oauth2` (update.py:154-155: `authorization_request_uri`, `token_request_uri`). Two copies of the endpoint field set must be kept in sync; adding an endpoint to one without the other silently changes purge vs. rebind behavior. Consider a single shared constant.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/config.py - 1
Review Details
  • Files reviewed - 24 · Commit Range: ae5d127..6e2fe30
    • superset/commands/database/exceptions.py
    • superset/commands/database/update.py
    • superset/commands/database/utils.py
    • superset/commands/semantic_layer/update.py
    • superset/config.py
    • superset/db_engine_specs/base.py
    • superset/db_engine_specs/gsheets.py
    • superset/db_engine_specs/snowflake.py
    • superset/security/api.py
    • superset/security/manager.py
    • superset/utils/network.py
    • superset/views/utils.py
    • tests/integration_tests/security/api_tests.py
    • tests/unit_tests/commands/databases/utils_test.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
    • tests/unit_tests/db_engine_specs/test_base.py
    • tests/unit_tests/db_engine_specs/test_databricks.py
    • tests/unit_tests/db_engine_specs/test_databricks_multi_cloud.py
    • tests/unit_tests/db_engine_specs/test_gsheets.py
    • tests/unit_tests/db_engine_specs/test_snowflake.py
    • tests/unit_tests/db_engine_specs/test_trino.py
    • tests/unit_tests/security/manager_test.py
    • tests/unit_tests/utils/test_network.py
    • tests/unit_tests/views/test_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/commands/database/utils.py Resolved
@sadpandajoe
sadpandajoe merged commit 7dd70ea into master Sep 22, 2026
103 checks passed
@sadpandajoe
sadpandajoe deleted the fix/oauth2-guest-token-semantic-layer-boundaries branch September 22, 2026 21:31
villebro pushed a commit that referenced this pull request Sep 23, 2026
…d endpoints (#44036)

Co-authored-by: Claude Sonnet 5 <[email protected]>
(cherry picked from commit 7dd70ea)
villebro added a commit that referenced this pull request Sep 23, 2026
Picks up the parameterized annotation-chart error message and the reworded
connection-move message from #44036.
aminghadersohi added a commit to aminghadersohi/superset that referenced this pull request Sep 23, 2026
`babel_update.sh` output was stale on this branch in two ways: this PR's
own geographic strings were added to messages.pot by hand, unwrapped and
never propagated into the per-language catalogs, and merging master
brought in a source string (apache#44036) whose changed text had not been
re-extracted. Regenerating fixes both, so `check_pot_drift.py` passes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API preset-io size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants