STIGQter STIGQter: STIG Summary: Microsoft Azure SQL Database Security Technical Implementation Guide Version: 2 Release: 3 Benchmark Date: 02 Jul 2025:

The Azure SQL Database and associated applications must reserve the use of dynamic code execution for situations that require it.

DISA Rule

SV-255311r1112455_rule

Vulnerability Number

V-255311

Group Title

SRG-APP-000251-DB-000391

Rule Version

ASQL-00-002200

Severity

CAT II

CCI(s)

Weight

10

Fix Recommendation

Where dynamic code execution is employed in circumstances where the objective could practically be satisfied by static execution with strongly typed parameters, modify the code to do so.

Check Contents

Review the system documentation to obtain a listing of stored procedures and functions that utilize dynamic code execution. Execute the following query:

DECLARE @tblDynamicQuery TABLE (ID INT identity(1,1), ProcToExecuteDynSQL VARCHAR(500))
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('EXEC[ (]@')
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('EXECUTE[ (]@')
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('SP_EXECUTESQL[ (]@')

SELECT
QUOTENAME(DB_Name()) DB_Name,
QUOTENAME(SCHEMA_NAME([schema_id])) + '.' + QUOTENAME(name) Name, QUOTENAME(type_desc) ObjectType
FROM sys.objects o
WHERE o.is_ms_shipped = 0 and
o.object_id IN (
SELECT m.object_id
FROM sys.sql_modules m
JOIN @tblDynamicQuery dsql ON REPLACE(REPLACE(REPLACE(m.definition,CHAR(32),'()'),')(',''),'()',CHAR(32)) like '%' + dsql.ProcToExecuteDynSQL + '%')

If any procedures or functions are returned that are not documented, this is a finding.

Vulnerability Number

V-255311

Documentable

False

Rule Version

ASQL-00-002200

Severity Override Guidance

Review the system documentation to obtain a listing of stored procedures and functions that utilize dynamic code execution. Execute the following query:

DECLARE @tblDynamicQuery TABLE (ID INT identity(1,1), ProcToExecuteDynSQL VARCHAR(500))
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('EXEC[ (]@')
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('EXECUTE[ (]@')
INSERT INTO @tblDynamicQuery(ProcToExecuteDynSQL) values('SP_EXECUTESQL[ (]@')

SELECT
QUOTENAME(DB_Name()) DB_Name,
QUOTENAME(SCHEMA_NAME([schema_id])) + '.' + QUOTENAME(name) Name, QUOTENAME(type_desc) ObjectType
FROM sys.objects o
WHERE o.is_ms_shipped = 0 and
o.object_id IN (
SELECT m.object_id
FROM sys.sql_modules m
JOIN @tblDynamicQuery dsql ON REPLACE(REPLACE(REPLACE(m.definition,CHAR(32),'()'),')(',''),'()',CHAR(32)) like '%' + dsql.ProcToExecuteDynSQL + '%')

If any procedures or functions are returned that are not documented, this is a finding.

Check Content Reference

M

Target Key

5500