Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Double Encoding
Cyber Security

Double Encoding

← Back to Glossary
By NHI Mgmt Group Updated October 30, 2026 Domain: Cyber Security

Double encoding is a technique where an attacker encodes the same characters more than once so different layers interpret the payload differently. In API attacks, the edge may see benign text after one decode pass while the backend restores the malicious string and executes the exploit.

How Double Encoding Works

Double encoding exploits differences between layers that decode input at different times or to different depths. An attacker can hide a payload by encoding it once for an outer filter, then again so a downstream component decodes the string back into something harmful. The weakness is not the encoding itself, but inconsistent interpretation across the request path.

This matters because security controls often inspect a request at one stage, while application code, a framework, or a backend service interprets the same bytes later. If those components do not apply the same canonicalisation rules, a payload can appear harmless to one layer and malicious to another.

Why It Bypasses Validation

Double encoding is effective when validation is performed before full normalisation. For example, an edge device may decode a value once and see safe text, while the origin server decodes it again and restores characters that change routing, query structure, or command meaning. That mismatch can defeat input validation, filtering, and security logging that rely on the pre-decoded form.

The technique is especially useful against systems that split responsibility across proxies, gateways, web frameworks, and application code. Each layer may assume the previous layer already handled decoding correctly, which creates a blind spot for attacker-controlled input that changes meaning only after multiple decode passes.

Where It Shows Up in API Security

In API environments, double encoding can affect request paths, query parameters, JSON values, form fields, and header-like inputs that are transformed more than once. It becomes dangerous when the API gateway, WAF, reverse proxy, and backend do not share a single canonical representation of the request. That inconsistency can let attackers smuggle reserved characters, alter resource identifiers, or bypass policy checks.

APIs are particularly sensitive because even a small change in character interpretation can change which object is addressed, which action is invoked, or how a parameter is parsed. When decoding happens inconsistently, the issue can look like a harmless formatting quirk while still enabling authorisation bypass, injection, or routing abuse.

Prevention and Defensive Handling

The safest approach is to normalise input once, validate the canonical form, and reject ambiguous or over-encoded values before they reach business logic. Defenders should also align decoding behaviour across the edge and origin, so a string cannot be interpreted differently by different layers. Strong logging helps, but logs should capture both the raw and normalised forms when that is safe and operationally useful.

Testing should focus on whether the full request path preserves a single meaning for every user-controlled field. If a security control, proxy, or parser can be persuaded to decode more than once, or to decode in a different order from the backend, the application may still be vulnerable even when the outer filter appears to work correctly.

Risk and Threat Considerations

Double encoding is risky because it turns parsing differences into a control bypass. A payload can evade perimeter inspection, then reappear in its dangerous form inside the application, where it may alter routing, access checks, or downstream processing.

Failure mechanism: The attacker supplies an over-encoded value that is decoded once by an upstream control and again by the backend, creating two different interpretations of the same input.

Impact: This can enable filter bypass, injection, path manipulation, or other request-smuggling style abuse, depending on where the second decode occurs.

Standards & Framework Alignment

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

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS, CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP API Security Top 10API8 — Security MisconfigurationDouble decoding failures often stem from inconsistent API parsing and gateway handling.
Recommendation — Harden API parsing so gateways and backends apply one canonical decode path before enforcement.
NIST SP 800-53 Rev 5SI-10 — Input ValidationDouble encoding bypasses poorly normalised input checks before application processing.
Recommendation — Validate canonicalised input and reject ambiguous or over-encoded values before business logic.
OWASP ASVSV1 — Encoding and SanitizationASVS V1 covers consistent encoding and sanitisation to prevent multi-layer interpretation bugs.
Recommendation — Apply consistent canonicalisation and sanitisation rules across every request-processing layer.
CIS Controls v8CIS-16 — Application Software SecurityApplication security safeguards directly address parser and validation flaws that enable double encoding.
Recommendation — Review application parsing and validation paths for inconsistent decoding and bypass opportunities.
NIST CSF 2.0PR.DS-01 — Data-at-rest is protectedNot directly used.

Practitioner Guidance

What to watch for: Investigate inconsistent decode handling whenever a payload is accepted by an edge control but behaves differently at the application layer. The key question is not whether the input looks encoded, but whether every component in the chain arrives at the same canonical value before policy decisions are made.

Practitioner takeaway: Treat canonicalisation as a security boundary, not a formatting detail, and make sure every trust decision uses the same decoded representation.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org