Summary
A URL path encoding flaw in Heimdall's Envoy gRPC decision API mode causes certain path-based access control rules to be bypassed when special characters (such as '?') are present in the request path.
When Heimdall is deployed with an "allow all" default rule and non-wildcard path matchers, an attacker can craft URLs that are re-encoded in a way that prevents intended rules from matching, potentially granting unintended access.
Affected context
This vulnerability occurs when Heimdall is used as an Identity Aware Proxy behind Envoy in gRPC decision API mode, specifically in versions 0.7.0-alpha through 0.17.10.
It manifests when:
- Envoy splits and forwards the URL components (path and query) to Heimdall,
- Heimdall reconstructs the URL using Go's
net/urllibrary, which re-encodes special characters, - Path-based rules rely on non-wildcard path expressions, and
- A permissive "allow all" default rule is configured (or secure defaults are explicitly disabled).
Exploit preconditions
- Attack surface: HTTP(S) requests flowing through Envoy to Heimdall in gRPC decision API mode.
- Required access: Ability to send crafted requests to the protected endpoint(s) behind Envoy/Heimdall (typically remote network access).
- Configuration conditions:
- Heimdall versions 0.7.0-alpha through 0.17.10.
- Use of non-wildcard path match rules (e.g.,
/mypath). - An "allow all" or otherwise overly-permissive default rule is present.
- Secure default rule enforcement is disabled (e.g., via
--insecure-skip-secure-default-rule-enforcementor--insecure). - Trigger point: Requests that place characters like
?into the path portion (as seen by Heimdall) so that Go's URL reconstruction encodes them (e.g.,/mypath?foo=barbecoming/mypath%3Ffoo=bar). - Why exploitation is possible: The mismatch between how Envoy sends the URL and how Heimdall reconstructs it causes the path used for rule evaluation to differ from the original routing intent, preventing expected rules from matching and falling back to the permissive default.
Why this happens
The root cause is a combination of improper input normalization/encoding and access control decisions made on incorrectly processed data.
Envoy provides URL components to Heimdall under an API contract where the query field is effectively unused and the full URL query string is embedded into the path field. Heimdall's implementation reconstructs the URL using Go's net/url library, which automatically escapes reserved characters in the path segment. As a result, a path like /mypath?foo=bar is interpreted and normalized to /mypath%3Ffoo=bar when evaluated against rules.
This behavior maps to:
- CWE-116: Improper Encoding or Escaping of Output – the system changes the effective semantics of the path by applying automatic encoding without aligning rule evaluation and configuration with this transformation.
- CWE-863: Incorrect Authorization – access decisions rely on path-based rules that no longer match the transformed value, causing Heimdall to incorrectly apply the default policy and grant access where it should have been denied.
In abstract, this is an authorization design flaw where policy evaluation is performed on a transformed/normalized resource identifier that does not match the administrator's intent.
Potential impact
- Unintended access to endpoints that are expected to be protected by path-based rules.
- Bypass of non-wildcard path restrictions when a permissive default rule is active.
- Possible exposure of internal or administrative APIs behind Heimdall.
- Expansion of an attacker's reachable surface area within a protected environment.
General mitigation guidance
Effective mitigation focuses on ensuring consistent URL normalization and defensive authorization defaults:
- Align rule evaluation with the exact canonical form of the URL used internally (including any encoding behavior).
- Treat any components subject to automatic encoding/decoding as untrusted until they are normalized in a single, well-defined way before policy checks.
- Favor deny-by-default authorization policies so that unmatched or malformed paths do not automatically receive access.
- Avoid relying solely on non-wildcard path matches for critical protections when there is ambiguity in how paths and queries are represented; consider explicit handling of query vs. path.
- Disable insecure or "allow all" defaults in environments where URL normalization differences may occur, and avoid flags that skip secure default enforcement except in tightly controlled scenarios.
- Document and standardize how proxies and downstream services (like Envoy and Heimdall) share and interpret URL components, especially when using gRPC decision APIs.
How teams detect issues like this
Potential detection and assurance strategies include:
- Configuration review:
- Identify deployments using Envoy gRPC decision API mode with Heimdall.
- Flag configurations that specify "allow all" or overly broad default rules, especially when secure default enforcement is disabled.
- Review path-based rule patterns to see if they match only "clean" paths and ignore encoded variants.
- Static and policy analysis:
- Analyze policy and routing code or configuration for inconsistent treatment of URL path and query components.
- Use policy-as-code tools to assert that no critical routes rely solely on non-wildcard path matches with permissive fallbacks.
- Dynamic testing:
- Perform security tests by sending requests with reserved characters (e.g.,
?,#,%) in the path region and observing whether authorization decisions match expectation. - Compare authorization results between canonical paths and their encoded equivalents.
- Monitoring and logging:
- Enable detailed logging of normalized paths as seen by Heimdall and compare them to original request URLs at the proxy edge.
- Use anomaly detection to spot unusual patterns where encoded characters frequently appear in path segments.

