Skip to content

mod_proxy_fcgi: Fix SCRIPT_NAME with %-escapes and proxy-fcgi-pathinfo - #1053

Open
arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/bz66608-fcgi-script-name-escapes
Open

arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/bz66608-fcgi-script-name-escapes

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

https://bz.apache.org/bugzilla/show_bug.cgi?id=66608

With proxy-fcgi-pathinfo set to keep the URL path as is (e.g. SetEnvIf Request_URI . proxy-fcgi-pathinfo=1), a request like /rt5/a%20b/c behind ProxyPass /rt5/ fcgi://... gets SCRIPT_NAME /rt5/a b/c instead of /rt5.

In that mode r->path_info is %-encoded while r->uri is decoded, so ap_add_cgi_vars() cannot find where PATH_INFO starts in r->uri once the path has an escape. SCRIPT_NAME is now set again from the decoded PATH_INFO, with the same handling of encoded slashes as r->uri. PATH_INFO itself is sent unchanged, as documented. RFC 3875 4.1.13: no PATH_INFO segment is included in SCRIPT_NAME.

Test: test/modules/proxy/test_12_fcgi_script_name.py, with a small FastCGI backend (fcgi_echo.py) that echoes the CGI variables. The two escaped cases fail on trunk and pass with the fix; the plain and unescape cases pass on both. The proxy suite passes (64).


  • This PR does not report or address a security vulnerability
    (see SECURITY.md and
    https://www.apache.org/security/#reporting-a-vulnerability).
  • Code follows the httpd style guide.
  • New log messages (level debug or higher) use an empty APLOGNO() tag;
    numbers are assigned by a committer at merge time (see docs/log-message-tags/README).
  • If the change is user-visible, a changes-entries/*.txt file is included,
    following the template in README.CHANGES (not needed otherwise).
  • Test cases based on pyhttpd are included where appropriate, in the
    test/modules/xxx directory matching the modules/xxx module source,
    or test/modules/core for core server changes. On Unix, verify these
    pass locally with e.g. make check-pytest PYTEST_DIRS=test/modules/xxx.

With proxy-fcgi-pathinfo set to keep the URL path as is (any value but
first-dot, last-dot, full or unescape), r->path_info is %-encoded while
r->uri is decoded. ap_add_cgi_vars() then fails to find where PATH_INFO
starts in r->uri as soon as the path has an escape, and SCRIPT_NAME gets
the whole path.

Set SCRIPT_NAME again from the decoded PATH_INFO in that case, except
for an SSI include where core sets it to the whole URI. PATH_INFO itself
is sent unchanged.

PR 66608.
@arturobernalg
arturobernalg force-pushed the fix/bz66608-fcgi-script-name-escapes branch from 0773639 to 1fac837 Compare November 18, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant