T1505.001 SQL Stored Procedures
Adversaries may abuse SQL stored procedures to establish persistent access to systems. SQL Stored Procedures are code that can be saved and reused so that database users do not waste time rewriting frequently used SQL queries. Stored procedures can be invoked via SQL statements to the database using the procedure name or via defined events (e.g. when a SQL server application is started/restarted).
Adversaries may craft malicious stored procedures that can provide a persistence mechanism in SQL database servers.43 To execute operating system commands through SQL syntax the adversary may have to enable additional functionality, such as xp_cmdshell for MSSQL Server.432
Microsoft SQL Server can enable common language runtime (CLR) integration. With CLR integration enabled, application developers can write stored procedures using any .NET framework language (e.g. VB .NET, C#, etc.).1 Adversaries may craft or modify CLR assemblies that are linked to stored procedures since these CLR assemblies can be made to execute arbitrary commands.5
| Item | Value |
|---|---|
| ID | T1505.001 |
| Sub-techniques | T1505.001, T1505.002, T1505.003, T1505.004, T1505.005, T1505.006 |
| Tactics | TA0003 |
| Platforms | Linux, Windows |
| Version | 1.1 |
| Created | 12 December 2019 |
| Last Modified | 24 October 2025 |
Procedure Examples
| ID | Name | Description |
|---|---|---|
| C0025 | 2016 Ukraine Electric Power Attack | During the 2016 Ukraine Electric Power Attack, Sandworm Team used various MS-SQL stored procedures.7 |
| S0603 | Stuxnet | Stuxnet used xp_cmdshell to store and execute SQL code.6 |
Mitigations
| ID | Mitigation | Description |
|---|---|---|
| M1047 | Audit | Regularly check component software on critical services that adversaries may target for persistence to verify the integrity of the systems and identify if unexpected changes have been made. |
| M1045 | Code Signing | Ensure all application component binaries are signed by the correct application developers. |
| M1026 | Privileged Account Management | Do not allow administrator accounts that have permissions to add component software on these services to be used for day-to-day operations that may expose them to potential adversaries on unprivileged systems. |
References
-
Microsoft. (2017, June 19). Common Language Runtime Integration. Retrieved July 8, 2019. ↩
-
Microsoft. (2017, March 15). xp_cmdshell (Transact-SQL). Retrieved September 9, 2019. ↩
-
Plakhov, A., Sitchikhin, D. (2019, August 22). Agent 1433: remote attack on Microsoft SQL Server. Retrieved September 4, 2019. ↩↩
-
Sutherland, S. (2016, March 7). Maintaining Persistence via SQL Server – Part 1: Startup Stored Procedures. Retrieved September 12, 2024. ↩↩
-
Sutherland, S. (2017, July 13). Attacking SQL Server CLR Assemblies. Retrieved September 12, 2024. ↩
-
Nicolas Falliere, Liam O Murchu, Eric Chien 2011, February W32.Stuxnet Dossier (Version 1.4) Retrieved November 17, 2024. ↩
-
Joe Slowik. (2018, October 12). Anatomy of an Attack: Detecting and Defeating CRASHOVERRIDE. Retrieved December 18, 2020. ↩