Skip to content

fix: enhance disallowed SQL functions list for improved security #33084

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 83 additions & 4 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,18 +1358,97 @@ def engine_context_manager( # pylint: disable=unused-argument
# unsafe SQL functions in SQL Lab and Charts. The keys of the dictionary are the engine
# names, and the values are sets of disallowed functions.
DISALLOWED_SQL_FUNCTIONS: dict[str, set[str]] = {
# PostgreSQL functions that could reveal sensitive information
"postgresql": {
"database_to_xml",
# System information functions
"current_database",
"current_schema",
"current_user",
"session_user",
"current_setting",
"version",
# Network/server information functions
"inet_client_addr",
"inet_client_port",
"inet_server_addr",
"inet_server_port",
# File system functions
"pg_read_file",
"pg_ls_dir",
"pg_read_binary_file",
# XML functions that can execute SQL
"database_to_xml",
"database_to_xmlschema",
"query_to_xml",
"query_to_xml_and_xmlschema",
"query_to_xmlschema",
"table_to_xml",
"table_to_xml_and_xmlschema",
"query_to_xml_and_xmlschema",
"table_to_xmlschema",
# Other potentially dangerous functions
"pg_sleep",
"pg_terminate_backend",
},
# MySQL functions and variables that could reveal sensitive information
"mysql": {
# Functions
"database",
"schema",
"current_user",
"session_user",
"system_user",
"user",
"version",
"connection_id",
"load_file",
"sleep",
"benchmark",
"kill",
},
# SQLite functions that could reveal sensitive information
"sqlite": {
"sqlite_version",
"sqlite_source_id",
"sqlite_offset",
"sqlite_compileoption_used",
"sqlite_compileoption_get",
"load_extension",
},
# Microsoft SQL Server functions
"mssql": {
"db_name",
"suser_sname",
"user_name",
"host_name",
"host_id",
"suser_id",
"system_user",
"current_user",
"original_login",
"xp_cmdshell",
"xp_regread",
"xp_fileexist",
"xp_dirtree",
"serverproperty",
"is_srvrolemember",
"has_dbaccess",
"fn_virtualfilestats",
"fn_servershareddrives",
},
# Clickhouse functions
"clickhouse": {
"currentUser",
"currentDatabase",
"hostName",
"currentRoles",
"version",
"buildID",
"url",
"filesystemPath",
"getOSInformation",
"getMacro",
"getSetting",
},
"clickhouse": {"url", "version", "currentDatabase", "hostName"},
"mysql": {"version"},
}


Expand Down
Loading