RCE in Microsoft SQL Server: Exploring Misconfigurations and Gain
The article describes how an attacker with access to a Microsoft SQL Server shell can enable the xp_cmdshell feature to execute operating system commands on the target machine. The author demonstrates that after enabling advanced options and xp_cmdshell, commands like whoami can be run, potentially leading to further compromise.
The original lives on systemweakness.com
We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the SQL Server service account had excessive privileges and the xp_cmdshell feature was not properly disabled or restricted, allowing an attacker with SQL access to enable it and execute commands.
What the attacker needed
Access to MSSQL shell; administrator privileges in MSSQL
How it was found
- Connect to the Microsoft SQL Server shell.
- Attempt to run a command using xp_cmdshell, which fails due to missing permissions.
- Enable advanced options using SP_CONFIGURE and RECONFIGURE.
- Enable xp_cmdshell using SP_CONFIGURE and RECONFIGURE.
- Run xp_cmdshell with a command such as whoami to execute system commands.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Microsoft SQL Server has a feature called xp_cmdshell that lets you run system commands from within SQL. It is turned off by default because it is dangerous. If an attacker can run SQL commands (for example through SQL injection), they might be able to turn it on and then run commands on the server, taking over the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.