Skip to content
Software development
ASD ISMISM-1275

ASD ISM 1275 Ensure secure database queries in software

What it says

All queries to databases from software are filtered for legitimate content and correct syntax.

Quoted as published. Everything else on this page is written by Control Stack.

In plain English

Filter every query that software sends to a database so only legitimate content in correct syntax gets through, and anything else is blocked before it runs.

Every query that software sends to a database must be filtered for legitimate content and correct syntax. Legitimate content means only what that software is meant to send, such as its expected statements, tables and values, with nothing injected. Correct syntax means the query is well formed for the database. Queries from data access libraries, reports, scheduled jobs and AI features all count. ISM-1276 separately requires parameterised queries or stored procedures. The ISM applies this to software the organisation develops or commissions.

Why it matters

A query carrying injected content can read, change or delete data the software was never meant to touch, or give a malicious actor control of the database server. Filtering every query checks for such content and malformed syntax before the database runs it.

How to implement

  1. Find every place the software sends queries to a database.

    Search the code for database calls, including data access libraries, stored procedure calls, reporting and export features, scheduled jobs and AI features. Compare with the database's own record of query types arriving from the software's accounts, so paths nobody documented show up.

  2. Define what a legitimate query looks like for each feature.

    Record the statement types, tables and columns it needs, and the valid format or range of each value. Where input decides a table, column or sort order, use it only to choose between fixed queries written in code, never insert it.

  3. Check each value before it goes into a query.

    Validate its type, length, format and range against that definition, and pass it as a parameter (ISM-1276) so it cannot change the query's structure. Turn off support for several statements in one call in the database driver, where the driver has that setting.

  4. Add filtering at the database as a second layer.

    A database firewall or proxy that allows only known query patterns blocks anything else, which also covers legacy software you cannot change. Where a feature, such as an AI assistant, would write its own queries, give it fixed parameterised queries to call instead (ISM-1276).

Keep it running

Update the query definitions and filter rules whenever a feature adds or changes a query. Investigate the queries with comments or multiple embedded queries that ISM-1537 logs, because they can show injection attempts or a gap in filtering.

Evidence and audit

  1. Check 1 of 3What an auditor asks for

    Ask for

    The list of places the software queries databases, with the database's own log of the query types arriving from the software's accounts.

    Look at

    Whether every kind of query seen at the database traces to a listed place that is filtered.

    Good evidence

    Every query type seen at the database traces to a listed, filtered place in the software, and no query reaches the database by an unlisted route.

  2. Check 2 of 3What an auditor asks for

    Ask for

    A test in an environment configured like production that sends injection strings, such as quote marks, comment markers and stacked statements, through a sample of inputs that end up in queries.

    Look at

    What the filtering does with each string, and what the database actually receives according to its query log.

    Good evidence

    Each test string that does not fit its field's definition, such as a quote mark in a numeric field, is rejected by the filtering before the query runs; any string the field allows reaches the database only as a value, and no extra statement, comment or change to the query's structure is executed.

  3. Check 3 of 3What an auditor asks for

    Ask for

    The code for a sample of database calls, including background jobs and administration features.

    Look at

    Whether any call reaches the database without going through validation and filtering.

    Good evidence

    Every sampled call passes through the filtering, with no path that sends an unchecked query to the database.

Mappings

Closest match in ISO/IEC 27001: A.8.25, Secure development life cycle, which this control partially meets.

ISO 27001

ISO/IEC 27001: 2 mappings

  • A.8.25Secure development life cyclePartially meets
  • A.8.28Secure codingPartially meets

Mappings show how controls relate across frameworks. They do not imply full equivalence or certification.