@@ -1358,18 +1358,97 @@ def engine_context_manager( # pylint: disable=unused-argument
1358
1358
# unsafe SQL functions in SQL Lab and Charts. The keys of the dictionary are the engine
1359
1359
# names, and the values are sets of disallowed functions.
1360
1360
DISALLOWED_SQL_FUNCTIONS : dict [str , set [str ]] = {
1361
+ # PostgreSQL functions that could reveal sensitive information
1361
1362
"postgresql" : {
1362
- "database_to_xml" ,
1363
+ # System information functions
1364
+ "current_database" ,
1365
+ "current_schema" ,
1366
+ "current_user" ,
1367
+ "session_user" ,
1368
+ "current_setting" ,
1369
+ "version" ,
1370
+ # Network/server information functions
1363
1371
"inet_client_addr" ,
1372
+ "inet_client_port" ,
1364
1373
"inet_server_addr" ,
1374
+ "inet_server_port" ,
1375
+ # File system functions
1376
+ "pg_read_file" ,
1377
+ "pg_ls_dir" ,
1378
+ "pg_read_binary_file" ,
1379
+ # XML functions that can execute SQL
1380
+ "database_to_xml" ,
1381
+ "database_to_xmlschema" ,
1365
1382
"query_to_xml" ,
1366
- "query_to_xml_and_xmlschema " ,
1383
+ "query_to_xmlschema " ,
1367
1384
"table_to_xml" ,
1368
1385
"table_to_xml_and_xmlschema" ,
1386
+ "query_to_xml_and_xmlschema" ,
1387
+ "table_to_xmlschema" ,
1388
+ # Other potentially dangerous functions
1389
+ "pg_sleep" ,
1390
+ "pg_terminate_backend" ,
1391
+ },
1392
+ # MySQL functions and variables that could reveal sensitive information
1393
+ "mysql" : {
1394
+ # Functions
1395
+ "database" ,
1396
+ "schema" ,
1397
+ "current_user" ,
1398
+ "session_user" ,
1399
+ "system_user" ,
1400
+ "user" ,
1401
+ "version" ,
1402
+ "connection_id" ,
1403
+ "load_file" ,
1404
+ "sleep" ,
1405
+ "benchmark" ,
1406
+ "kill" ,
1407
+ },
1408
+ # SQLite functions that could reveal sensitive information
1409
+ "sqlite" : {
1410
+ "sqlite_version" ,
1411
+ "sqlite_source_id" ,
1412
+ "sqlite_offset" ,
1413
+ "sqlite_compileoption_used" ,
1414
+ "sqlite_compileoption_get" ,
1415
+ "load_extension" ,
1416
+ },
1417
+ # Microsoft SQL Server functions
1418
+ "mssql" : {
1419
+ "db_name" ,
1420
+ "suser_sname" ,
1421
+ "user_name" ,
1422
+ "host_name" ,
1423
+ "host_id" ,
1424
+ "suser_id" ,
1425
+ "system_user" ,
1426
+ "current_user" ,
1427
+ "original_login" ,
1428
+ "xp_cmdshell" ,
1429
+ "xp_regread" ,
1430
+ "xp_fileexist" ,
1431
+ "xp_dirtree" ,
1432
+ "serverproperty" ,
1433
+ "is_srvrolemember" ,
1434
+ "has_dbaccess" ,
1435
+ "fn_virtualfilestats" ,
1436
+ "fn_servershareddrives" ,
1437
+ },
1438
+ # Clickhouse functions
1439
+ "clickhouse" : {
1440
+ "currentUser" ,
1441
+ "currentDatabase" ,
1442
+ "hostName" ,
1443
+ "currentRoles" ,
1369
1444
"version" ,
1445
+ "buildID" ,
1446
+ "url" ,
1447
+ "filesystemPath" ,
1448
+ "getOSInformation" ,
1449
+ "getMacro" ,
1450
+ "getSetting" ,
1370
1451
},
1371
- "clickhouse" : {"url" , "version" , "currentDatabase" , "hostName" },
1372
- "mysql" : {"version" },
1373
1452
}
1374
1453
1375
1454
0 commit comments