You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several response/header parsing paths trim trailing whitespace by first forming a pointer to strlen(value) - 1. For an empty string, that constructs a pointer before the start of the object before the loop condition can reject it.
This change adds ap_cstr_stripws(char *) in server/util.c and declares it in include/httpd.h. The helper uses an end-exclusive pointer, so empty and all-whitespace strings are handled without underflow.
The duplicated trailing-whitespace logic is replaced in:
mod_proxy_http
mod_proxy_uwsgi
mod_proxy_hcheck
server/util_script.c
mod_cern_meta
cfg_trim_line()
byterange_filter
mod_negotiation
Coverage includes unit cases for empty strings, all-whitespace strings, ordinary values, trailing whitespace, and preservation of leading whitespace. The proxy regression tests also retain backend responses containing a valid empty X-Empty: header for both HTTP proxy and uWSGI paths.
Validation on the current branch in a clean Ubuntu 24.04 container:
full httpd build succeeds with the affected modules enabled
httpdunit passes 60/60, including all seven ap_cstr_stripws() cases
test_03_response.py and test_05_uwsgi.py pass 6/6, including the HTTP proxy and uWSGI empty-header regressions
git diff --check: clean
modified Python regression files compile cleanly with py_compile
I have not demonstrated a crash, out-of-bounds read/write, information disclosure, or other exploit primitive; this remains a narrow UB hardening change.
Thanks — added ap_cstr_stripws() in server/util.c, declared it in httpd.h, and switched the affected callers over to it. I also added focused unit coverage for empty/all-whitespace/trailing-whitespace cases and converted three additional instances of the same underflow-prone trimming idiom. The existing proxy regressions remain in place.
Fresh validation on the current single-commit head is clean: full Ubuntu 24.04 build succeeds, httpdunit passes 60/60 (including all 7 ap_cstr_stripws() cases), and the HTTP proxy + uWSGI regression files pass 6/6 including both empty-header cases. git diff --check and py_compile are clean as well. I updated the PR description with the current results.
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
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.
Several response/header parsing paths trim trailing whitespace by first forming a pointer to
strlen(value) - 1. For an empty string, that constructs a pointer before the start of the object before the loop condition can reject it.This change adds
ap_cstr_stripws(char *)inserver/util.cand declares it ininclude/httpd.h. The helper uses an end-exclusive pointer, so empty and all-whitespace strings are handled without underflow.The duplicated trailing-whitespace logic is replaced in:
mod_proxy_httpmod_proxy_uwsgimod_proxy_hcheckserver/util_script.cmod_cern_metacfg_trim_line()byterange_filtermod_negotiationCoverage includes unit cases for empty strings, all-whitespace strings, ordinary values, trailing whitespace, and preservation of leading whitespace. The proxy regression tests also retain backend responses containing a valid empty
X-Empty:header for both HTTP proxy and uWSGI paths.Validation on the current branch in a clean Ubuntu 24.04 container:
httpdunitpasses 60/60, including all sevenap_cstr_stripws()casestest_03_response.pyandtest_05_uwsgi.pypass 6/6, including the HTTP proxy and uWSGI empty-header regressionsgit diff --check: cleanpy_compileI have not demonstrated a crash, out-of-bounds read/write, information disclosure, or other exploit primitive; this remains a narrow UB hardening change.