SQLI-22-016400 - Execution of startup stored procedures must be restricted to necessary cases only.

Information

In certain situations, to provide required functionality, a DBMS needs to execute internal logic (stored procedures, functions, triggers, etc.) and/or external code modules with elevated privileges. However, if the privileges required for execution are at a higher level than the privileges assigned to organizational users invoking the functionality applications/programs, those users are indirectly provided with greater privileges than assigned by organizations.

When "Scan for startup procs" is enabled, SQL Server scans for and runs all automatically run stored procedures defined on the server. The execution of start-up stored procedures will be done under a high privileged context; therefore, it is a commonly used post-exploitation vector.

Solution

To disable startup stored procedure(s), run the following in Master for each undocumented procedure:
sp_procoption @procname = '<procedure name>', @OptionName = 'Startup', @optionValue = 'Off'

See Also

https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_MS_SQL_Server_2022_Y26M04_STIG.zip