MSSQL Dangerous Configuration Checks
Several SQL Server features are disabled by default but are commonly re-enabled by DBAs and application teams. Each one represents a distinct exploitation path when accessible to the current login. Confirming which are active before attempting exploitation avoids unnecessary noise and tightens the attack plan.
All checks here require an authenticated SQL session. Use impacket-mssqlclient to run these queries interactively.
Check Current Privilege Level First
Confirm your privilege context before checking configurations. Some settings are only visible to sysadmin:
SYSTEM_USER: CORP\sqlsvc is_sysadmin: 1 is_public: 1
is_sysadmin returning 1 means all configuration checks will succeed and all exploitation paths are available. If it returns 0, configuration reads may still work depending on the public role permissions, but write operations like enabling xp_cmdshell will fail without impersonation or privilege escalation first.
xp_cmdshell Status
xp_cmdshell executes OS commands as the SQL Server service account. When enabled, it is a direct OS execution primitive. Check whether it is currently enabled:
name value value_in_use xp_cmdshell 1 1
value_in_use of 1 means xp_cmdshell is active right now and usable without any configuration changes. value of 1 but value_in_use of 0 means it is configured on but requires a RECONFIGURE to activate. Both cases lead to the xp_cmdshell exploitation page.
Ole Automation Procedures
Ole Automation allows creating COM objects from T-SQL, including WScript.Shell for command execution and MSXML2.ServerXMLHTTP for outbound HTTP. It is an alternative OS execution path when xp_cmdshell is disabled:
name value value_in_use Ole Automation Procedures 1 1
Ole Automation enabled alongside or instead of xp_cmdshell gives equivalent OS access through a different T-SQL path. Flag both as active when found.
Linked Servers with RPC
Linked servers allow queries to be forwarded to other SQL Server instances. When RPC Out is enabled on a linked server, stored procedures including xp_cmdshell can be executed on the remote instance. This is a lateral movement path even when local privileges are limited:
name product is_rpc_out_enabled is_data_access_enabled SQL-PROD-02 SQL Server 1 1
Any linked server with is_rpc_out_enabled = 1 is a pivot candidate. The security context under which the linked server connection runs determines what privileges you land with on the remote instance. Check the linked server login mappings:
A self-mapping entry or a mapping to a high-privilege account on the remote server means the linked server pivot may land you with elevated privileges on the target instance.
Service Account Privileges
SQL Server service accounts running as NT AUTHORITY\SYSTEM, a Domain Admin, or a highly privileged domain service account give any sysadmin-level SQL access OS-level impact immediately. Confirm what the service account is:
nt authority\system
NT AUTHORITY\SYSTEM output means OS commands execute at SYSTEM level. Any command execution via xp_cmdshell or Ole Automation gives full host compromise without a separate privilege escalation step.
Impersonation Rights
EXECUTE AS LOGIN allows one login to impersonate another. When a low-privilege login can impersonate sa or a sysadmin, it is a direct privilege escalation path. Check which logins the current user can impersonate:
name sa Admin
Any sysadmin account appearing in this output means impersonation-based privilege escalation is available. The exploitation path is covered in the MSSQL impersonation page.
Bulk Quick Check with nxc
nxc can check for xp_cmdshell availability in a single command without opening an interactive session:
References
-
Microsoft — sys.configurationslearn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-configurations-transact-sql (opens in new tab)
Configuration values including xp_cmdshell and Ole Automation Procedures
-
Microsoft — sys.serverslearn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-servers-transact-sql (opens in new tab)
Linked server fields including is_rpc_out_enabled and is_data_access_enabled
Was this helpful?
Your feedback helps improve this page.