mod_wsgi 4.6.8.post1: backport CVE-2022-2255 - #1
Merged
Conversation
When WSGITrustedProxies / WSGITrustedProxyHeaders (or mod_wsgi-express --trust-proxy / --trust-proxy-header) designated X-Client-IP as the trusted client-IP header, and a request arrived from a client which was NOT a trusted proxy, wsgi_process_proxy_headers() failed to strip HTTP_X_CLIENT_IP from the request environment. REMOTE_ADDR was correctly left untouched in that case, so an application following best practice and reading only REMOTE_ADDR was unaffected. However an application that additionally ran WSGI/framework middleware which re-processes proxy headers (e.g. Werkzeug's ProxyFix, Django's USE_X_FORWARDED_*) would see the attacker-supplied HTTP_X_CLIENT_IP and could be induced to trust a spoofed client address. The untrusted-client branch tested only HTTP_X_FORWARDED_FOR and HTTP_X_REAL_IP when setting match_client_header, which drives the loop that unsets every header in wsgi_proxy_client_headers[]. X-Client-IP is listed in wsgi_proxy_client_headers[] (and is handled correctly in the trusted-proxy branch above), so the omission here meant the drop loop never ran for that configuration. Add HTTP_X_CLIENT_IP to the check, matching the upstream fix released in mod_wsgi 4.9.3. Upstream commit: af3c0c2 Upstream release notes: docs/release-notes/version-4.9.3.rst Advisory: https://nvd.nist.gov/vuln/detail/CVE-2022-2255 GHSA-7527-8855-9cf8 No Python-version concerns: the change is in the Apache C module. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ActiveState security release of mod_wsgi 4.6.8 carrying the backport of CVE-2022-2255 (X-Client-IP not dropped for untrusted clients), fixed upstream in 4.6.8's successor line at 4.9.3. Bumps MOD_WSGI_VERSION_STRING to "4.6.8.post1", which is what setup.py's _version() reads and what is reported in the Server header. MOD_WSGI_MAJORVERSION_NUMBER / MINORVERSION_NUMBER / MICROVERSION_NUMBER are deliberately left at 4 / 6 / 8. Those three macros are the only source of the `mod_wsgi.version` (iii) tuple exposed to WSGI applications (mod_wsgi.c:2747, mod_wsgi.c:14399, wsgi_interp.c:1156); keeping them numeric and unchanged preserves existing `mod_wsgi.version >= (4, 6, 8)` comparisons in consumer code. Adds docs/release-notes/version-4.6.8.post1.rst and lists it in the release notes toctree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Backports the upstream fix for CVE-2022-2255 to the 4.6.8 line by ensuring X-Client-IP is stripped from the WSGI environment when a request comes from an untrusted client (even if WSGITrustedProxyHeaders is configured to trust it). Also bumps the human-readable/package version string to 4.6.8.post1 and documents the security release.
Changes:
- Fix proxy-header sanitization so
HTTP_X_CLIENT_IPis included in the “untrusted client” header-stripping path. - Update
MOD_WSGI_VERSION_STRINGto4.6.8.post1while leaving the numeric(4, 6, 8)tuple intact. - Add and link release notes describing the CVE and behavioral impact.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/server/wsgi_version.h | Bumps MOD_WSGI_VERSION_STRING to 4.6.8.post1 without changing the numeric version macros. |
| src/server/mod_wsgi.c | Adds HTTP_X_CLIENT_IP to the untrusted-client match so the header-removal loop runs for that configuration. |
| docs/release-notes/version-4.6.8.post1.rst | Documents the 4.6.8.post1 security release and CVE-2022-2255 backport details. |
| docs/release-notes.rst | Adds the new 4.6.8.post1 release notes page to the toctree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
emanuelc-activestate
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ActiveState security release of mod_wsgi 4.6.8, the version this line ships.
The vulnerability
With
WSGITrustedProxies/WSGITrustedProxyHeaders(ormod_wsgi-express --trust-proxy/--trust-proxy-header) configured to trustX-Client-IP, a request from a client that is not a trusted proxy did not getHTTP_X_CLIENT_IPstripped from the WSGI environment.4.6.8 has the vulnerable code verbatim at
src/server/mod_wsgi.c:13944-13945: the untrusted-client branch setsmatch_client_headerforHTTP_X_FORWARDED_FORandHTTP_X_REAL_IPbut notHTTP_X_CLIENT_IP, andmatch_client_headeris what drives the loop that unsets every header inwsgi_proxy_client_headers[].X-Client-IPis in that array and is handled correctly in the trusted-proxy branch above, so the omission meant the drop loop simply never ran for that configuration.REMOTE_ADDRwas correctly left alone, so an application reading onlyREMOTE_ADDRwas unaffected. An application also running middleware that re-processes proxy headers (ProxyFix, Django'sUSE_X_FORWARDED_*) could be induced to trust a spoofed client address.The fix
One line, matching upstream commit
af3c0c2736bc: addHTTP_X_CLIENT_IPto the check.Versioning
MOD_WSGI_VERSION_STRINGbecomes"4.6.8.post1"— that is whatsetup.py's_version()parses and what appears in theServerheader.MOD_WSGI_MAJORVERSION_NUMBER/MINORVERSION_NUMBER/MICROVERSION_NUMBERare deliberately left at 4/6/8. Those three macros are the only source of themod_wsgi.version(iii)tuple exposed to WSGI applications (mod_wsgi.c:2747,mod_wsgi.c:14399,wsgi_interp.c:1156), so leaving them numeric and unchanged preserves existingmod_wsgi.version >= (4, 6, 8)comparisons.Testing
Not compiled or run. This environment has no Apache development headers (no
apxs, nohttpd.h), so the change is unverified beyond review. It is a single||clause added to an existing chain, structurally identical to the trusted-proxy branch 20 lines above and to upstream's own diff. It should be built against Apache before the tag is cut.🤖 Generated with Claude Code