Join our Newsletter — 33% off our NHI Course

Sanitisation Gap

A mismatch between what a security filter thinks it has removed and what the browser actually executes. These gaps often appear when content is parsed differently across layers, allowing encoded or non-standard payloads to survive validation.

What a Sanitisation Gap Means in Practice

A sanitisation gap is not just a failed filter rule. It is a disagreement between layers about what has been removed, and that disagreement creates room for payloads to survive as they move from server-side validation to browser execution.

Why Sanitisation Gaps Happen

These gaps usually appear when one component normalises, decodes, strips, or tokenises input differently from another. A security layer may believe it has neutralised a string, while the browser later reconstructs or interprets the same bytes as active HTML, script, or another executable structure.

The problem is often structural, not accidental. Differences in character encoding, entity handling, URL decoding, parser quirks, or context shifts between HTML, JavaScript, CSS, and URL processing can all produce a payload that looks inert during validation but becomes meaningful at render time.

Where Sanitisation Gaps Show Up

Sanitisation gaps are most visible in web applications that transform user input before displaying it. Rich text editors, templating systems, markdown renderers, content management workflows, and legacy applications with multiple filters are common places for inconsistent parsing to emerge.

They also matter whenever the same input passes through more than one security boundary. A payload may be filtered at upload time, altered again by a storage layer, and then interpreted differently by the client, which means the final execution context can differ from the one the filter assumed.

For a related baseline on what effective sanitisation is meant to prevent, compare the control intent in OWASP API Security Top 10 with the broader defensive control set in NIST SP 800-53 Rev 5 Security and Privacy Controls.

How to Recognise the Security Meaning of the Term

Sanitisation gap is a useful term because it points to a specific failure mode, not a generic validation issue. The key question is whether the system removes dangerous content in one representation while leaving a later representation capable of executing, rendering, or otherwise changing meaning.

That distinction matters because the fix is rarely just “add more filtering.” The real problem is usually consistency across layers, so the security requirement is to make sure every parser, decoder, and renderer agrees on the same interpretation before the browser ever receives the content.

At the design level, media and content handling guidance such as NIST SP 800-88 Media Sanitization is a useful reminder that sanitisation only works when the intended end state is unambiguous and verifiable. For code and component governance, OWASP SAMM helps frame sanitisation as a software assurance concern, not just a patchable bug.

Risk and Threat Considerations

Sanitisation gaps create a classic web exploitation path because they let attacker-controlled content survive one control layer and become active in another. That can lead to script execution, content injection, broken trust boundaries, or persistence of malicious markup after a filter has falsely reported success.

Failure mechanism: The application validates input in one syntax or context, but the browser later interprets a differently normalised or decoded version of the same content as executable or trusted content.

Impact: Attackers can bypass intended sanitisation, trigger cross-site scripting-style outcomes, corrupt rendered content, or exploit downstream parsing differences to manipulate what users see and what the application believes it stored.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP ASVS V1 — Encoding and Sanitization Sanitisation gaps arise from inconsistent encoding and sanitization across contexts.
V15 — Secure Coding and Architecture Parser and rendering mismatches are a secure design and implementation concern.
Recommendation — Validate context-sensitive encoding and sanitization at each output boundary. Design content flows so each parser and renderer uses a single, explicit trust boundary.
NIST SP 800-53 Rev 5 SI-10 — Information Input Validation The term describes failures in validating and normalizing untrusted input before use.
SI-3 — Malicious Code Protection Sanitisation gaps can allow active payloads to survive filtering and execute later.
Recommendation — Normalize and validate untrusted input before it reaches security-sensitive processing. Inspect and block active content that survives preprocessing or transformation layers.