Skip to content
Misconfiguration Write-up Intermediate

CVE-2022-31813: Forwarding Addresses Is Hard

Apache HTTPD mod_proxy versions 2.2.1 to 2.4.53 fail to forward X-Forwarded headers when they are listed as hop-by-hop, causing the upstream application to see the request as coming from the proxy itself. An attacker could spoof IP addresses or hostnames to bypass access controls or filters.

Gaetan Ferry Follow

Published on synacktiv.com

Rédigé par Gaetan Ferry - 26/07/2022 - dans Exploit, Pentest - Téléchargement

Gaetan Ferry (@_mabote_), on synacktiv.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the order of operations in mod_proxy: it adds the X-Forwarded headers before calling the function that removes hop-by-hop headers, so the newly added headers are also removed.

Impact

Depending on the application, this could lead to authentication or filtering bypass, IP address spoofing, or denial of service; the text notes that no generic exploit exists and that impact varies by framework and configuration.

What the attacker needed

Apache HTTPD mod_proxy as reverse proxy; Application trusts X-Forwarded headers; Attacker can send requests to the proxy

The fix

The issue was fixed in Apache HTTPD version 2.4.54.

How it was found

  1. Send a request to the Apache reverse proxy with a Connection header listing X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Server as hop-by-hop.
  2. Observe that the upstream application receives the request without any X-Forwarded headers, making it appear as if the request came directly from the proxy.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A reverse proxy sits in front of a web app and adds headers like X-Forwarded-For to tell the app the real visitor's IP address. If a visitor marks those headers as 'hop-by-hop', the proxy should remove them, but Apache also removed the ones it just added, so the app thinks the request came from the proxy itself. This can let an attacker pretend to be a trusted IP or host.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.