You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/02 01:02:32 UTC
(superset) 01/01: fix(mcp): use configured admin role + warn on permission-less protected tools
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch fix/mcp-authz-hardening
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 68ba87ec43291b8a72640515b258058be447167e
Author: Claude Code <no...@anthropic.com>
AuthorDate: Mon Jun 1 18:02:12 2026 -0700
fix(mcp): use configured admin role + warn on permission-less protected tools
- user_has_permission() hardcoded the admin role check to "Admin"/"admin",
ignoring AUTH_ROLE_ADMIN. Deployments that rename the admin role would have
admins over-filtered (denied the field-level sensitive-data bypass). Use the
configured AUTH_ROLE_ADMIN.
- check_tool_permission() silently allows a permission-protected tool that
declares no class_permission_name. This is a supported configuration, but a
protected tool with an accidentally-omitted permission would fail open with
no signal. Keep the allow behavior but log a warning so the misconfiguration
is visible.
Add a test verifying the admin bypass follows AUTH_ROLE_ADMIN.
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
superset/mcp_service/auth.py | 10 +++++++-
superset/mcp_service/utils/permissions_utils.py | 9 ++++++--
.../mcp_service/utils/test_permissions_utils.py | 27 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/superset/mcp_service/auth.py b/superset/mcp_service/auth.py
index 583b721b9ea..580801a5edc 100644
--- a/superset/mcp_service/auth.py
+++ b/superset/mcp_service/auth.py
@@ -119,7 +119,15 @@ def check_tool_permission(func: Callable[..., Any]) -> bool:
class_permission_name = getattr(func, CLASS_PERMISSION_ATTR, None)
if not class_permission_name:
- # No RBAC configured for this tool; allow by default.
+ # No RBAC configured for this tool; allow by default. This is a
+ # supported configuration (a protected tool may intentionally
+ # declare no permission class), but surface it so an accidental
+ # omission on a sensitive tool doesn't silently fail open.
+ logger.warning(
+ "Tool %s is permission-protected but declares no "
+ "class_permission_name; allowing access without an RBAC check",
+ func.__name__,
+ )
return True
method_permission_name = getattr(func, METHOD_PERMISSION_ATTR, "read")
diff --git a/superset/mcp_service/utils/permissions_utils.py b/superset/mcp_service/utils/permissions_utils.py
index c4b24afc50d..f7561ad4957 100644
--- a/superset/mcp_service/utils/permissions_utils.py
+++ b/superset/mcp_service/utils/permissions_utils.py
@@ -89,10 +89,15 @@ def user_has_permission(
return False
try:
- # Check if user is admin (has all permissions)
+ from flask import current_app
+
+ # Check if user is admin (has all permissions). Use the configured
+ # admin role name rather than hardcoding "Admin", so deployments that
+ # rename the admin role (AUTH_ROLE_ADMIN) still grant admins the bypass.
+ admin_role_name = current_app.config["AUTH_ROLE_ADMIN"]
if hasattr(user, "roles"):
for role in user.roles:
- if role.name in ("Admin", "admin"):
+ if role.name == admin_role_name:
return True
# Check specific permission
diff --git a/tests/unit_tests/mcp_service/utils/test_permissions_utils.py b/tests/unit_tests/mcp_service/utils/test_permissions_utils.py
index 160fccb6344..c4833080693 100644
--- a/tests/unit_tests/mcp_service/utils/test_permissions_utils.py
+++ b/tests/unit_tests/mcp_service/utils/test_permissions_utils.py
@@ -19,13 +19,40 @@
from unittest.mock import Mock
+from flask import current_app
+
from superset.mcp_service.utils.permissions_utils import (
apply_field_permissions_to_columns,
filter_sensitive_data,
get_allowed_fields,
+ user_has_permission,
)
+def test_user_has_permission_admin_uses_configured_role_name():
+ """The admin bypass honors AUTH_ROLE_ADMIN, not a hardcoded 'Admin'."""
+
+ def _role(name: str) -> Mock:
+ role = Mock()
+ role.name = name # set after construction (Mock intercepts name=)
+ return role
+
+ original = current_app.config["AUTH_ROLE_ADMIN"]
+ current_app.config["AUTH_ROLE_ADMIN"] = "Superuser"
+ try:
+ admin = Mock()
+ admin.roles = [_role("Superuser")]
+ assert user_has_permission(admin, "can_read", "Chart") is True
+
+ # The previously-hardcoded "Admin" name no longer grants the bypass;
+ # it falls through to the real permission check, which denies here.
+ not_admin = Mock()
+ not_admin.roles = [_role("Admin")]
+ assert user_has_permission(not_admin, "can_read", "Chart") is False
+ finally:
+ current_app.config["AUTH_ROLE_ADMIN"] = original
+
+
def test_get_allowed_fields_always_denies_user_directory_fields():
user = Mock()
user.roles = []