Heimdall IP Spoofing via Unvalidated Forwarding Headers
A high-severity vulnerability in dadrus/heimdall (versions <= 0.17.16) enables attackers to spoof client IP addresses by injecting unvalidated or malformed values into `Forwarded` or `X-Forwarded-For` HTTP headers, potentially bypassing access controls or propagating malicious IP data to upstream services when `trusted_proxies` is configured.
A high-severity vulnerability has been identified in dadrus/heimdall versions up to and including 0.17.16. This flaw allows attackers to spoof client IP addresses when the trusted_proxies option is configured, due to insufficient validation of values extracted from Forwarded and X-Forwarded-For HTTP headers. Heimdall extracts these header values into Request.ClientIPAddresses without checking for syntactically valid IP addresses, accepting arbitrary strings, malformed literals, or RFC 7239 unknown values. Additionally, the Forwarded header parser fails to correctly handle quoted strings containing delimiters (, or ;), leading to misparsing and the creation of malformed entries. This vulnerability can be exploited by manipulating HTTP forwarding headers, allowing attackers to bypass access control rules that rely on Request.ClientIPAddresses for authorization, or to propagate attacker-controlled IP values to upstream services when Heimdall operates in proxy mode.
Attack Chain
- An attacker crafts an HTTP request targeting a heimdall instance where the
trusted_proxiesconfiguration option is enabled. - The attacker includes a manipulated
X-Forwarded-Forheader (e.g.,X-Forwarded-For: 192.168.1.1, EVIL_IP) orForwardedheader (e.g.,Forwarded: for="127.0.0.1;attacker_id",Forwarded: for="unknown") containing a syntactically invalid, spoofed, or otherwise malformed IP address value. - Heimdall, lacking proper validation, extracts this malicious value from the forwarding header and populates its internal
Request.ClientIPAddressesproperty with the attacker-controlled string. - If the heimdall instance uses rules (e.g., a CEL authorizer) that reference
Request.ClientIPAddressesto enforce access control (e.g., restricting access to specific IP ranges), these rules evaluate against the spoofed IP. - The attacker successfully bypasses the intended access control logic, gaining unauthorized access or circumventing restrictions based on the spoofed IP address.
- (Alternative/Concurrent): If heimdall is operating in proxy mode, it uses the manipulated
Request.ClientIPAddressesto reconstructX-Forwarded-ForandForwardedheaders before forwarding the request to upstream services. - Upstream services that trust these forwarded headers will receive and process the attacker-controlled IP value, potentially leading to incorrect logging, misattribution, or further exploitation within the internal network.
Impact
The primary impact of this vulnerability is the circumvention of application-level access controls and the potential for misattribution or further exploitation of upstream systems. Organizations utilizing dadrus/heimdall as an API gateway or proxy with the trusted_proxies option enabled are at risk. Attackers can bypass IP-based authorization checks, granting them unauthorized access to protected resources. Furthermore, in proxy mode, attacker-controlled IP values can be propagated to backend services, corrupting security logs, impacting forensic investigations, or enabling further attacks that rely on source IP validation. There is no information regarding specific victim counts or targeted sectors in the advisory, but any organization relying on Heimdall's IP-based security features could be affected.
Recommendation
- Upgrade
dadrus/heimdallto a version higher than 0.17.16 immediately to patch the vulnerability described in the GHSA advisory. - Ensure network-level controls are in place to only permit trusted proxies to communicate directly with your Heimdall instances.
- Configure any proxies forwarding requests to Heimdall to sanitize or completely override, rather than append to, existing
ForwardedorX-Forwarded-Forheaders. - Review and adjust any rules (e.g., CEL authorizer rules) that rely on
Request.ClientIPAddressesfor security-sensitive decisions, considering the potential for IP spoofing until patches are applied. - Deploy the Sigma rules provided in this brief to your SIEM to detect attempts at IP spoofing via manipulated
X-Forwarded-ForandForwardedheaders.
Detection coverage 2
Detect Heimdall IP Spoofing - Malformed X-Forwarded-For Header
highDetects attempts to exploit Heimdall's vulnerability by injecting non-IP characters or 'unknown' identifiers into the 'X-Forwarded-For' header to spoof client IP addresses.
Detect Heimdall IP Spoofing - Malformed Forwarded Header 'for=' Parameter
highDetects attempts to exploit Heimdall's vulnerability via the 'Forwarded' header's 'for=' parameter, specifically looking for non-IP values, the 'unknown' identifier, or quoted strings containing internal delimiters like ';' or ',' that could lead to misparsing.
Detection queries are available on the platform. Get full rules →