Commit Graph
2 Commits
Author SHA1 Message Date
shadowdaoandClaude Opus 5.5 5f8597363e mod_whp_proxy_guard: fail-closed switches (WHPProxyRequireTLS, WHPProxyRequireVhostList)
Review of WHP #362: the per-site :80 vhost redirected only its PRIMARY name,
so an alias host on :80 (reachable from the shared docker network; the edge
uses :443 only) was served with the tenant .htaccess and none of the :443
FastCGI pins. Measured on the current image: plain, <If> and nested
ProxyFCGISetEnvIf + [P] to another tenant's backend all ran its script there,
and with only the inherited fcgi://*:9000 default a [P] still ran the other
tenant's index.php.

- WHPProxyRequireTLS On (image default): no proxying for a request that did
  not arrive over TLS (ap_ssl_conn_is_ssl). Closes :80 for vhosts rendered
  before WHP's unconditional redirect.
- WHPProxyRequireVhostList On|Off (image default Off): a vhost without its
  OWN WHPProxyAllow may not proxy; an inherited list does not count. Off in
  the image because hosts carry pre-#362 renders; WHP turns it on once every
  vhost renders its own list.
- `WHPProxyAllow None` now resets the list; clearer refusal log lines.
- In-repo test: 40 assertions (plain-HTTP refusal, RequireVhostList with
  and without an own list).

DRAFT - DO NOT MERGE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-23 07:31:56 -08:00
shadowdaoandClaude Opus 5.5 ba3fb70d3c feat(shared-httpd): mod_whp_proxy_guard - request-time proxy allow list
A tenant's NESTED <If> in .htaccess is merged after every section a vhost
or the server-scope drop-in can use, so it overrides any config-only
SCRIPT_FILENAME / DOCUMENT_ROOT / PHP_VALUE pin. Measured on httpd
2.4.63-13.el10_2.8: `<If "true"><If "true"> ProxyFCGISetEnvIf "true"
SCRIPT_FILENAME "/home/<victim>/..." </If></If>` plus `RewriteRule ...
fcgi://<victim>-01:9000/... [P]` ran the other tenant's script as its uid
(also <If><If><If>, <Files><If><If> SetHandler "proxy:fcgi://", a nested
<ElseIf>, a nested PATH_TRANSLATED, the victim's IP); [P] to http/ws/ajp
reached any host (SSRF); a nested <If> `SetHandler balancer-manager` served
the balancer manager.

New loadable module (stock Alma httpd, built against httpd-devel like
mod_whp_symlink in #60, separate source so the two can merge independently):
- mod_proxy scheme_handler hook (APR_HOOK_REALLY_FIRST): after all config
  merging, mod_rewrite and balancer member selection, the connection target
  (UDS path or scheme://host:port) must be on the vhost's WHPProxyAllow
  list, else 403 before a byte is sent. Every proxy scheme is covered.
- WHPHtaccessProxyFCGI Deny: ProxyFCGISetEnvIf / ProxyFCGIBackendType in
  .htaccess (any nesting) is a config error, so the vhost's own rules stay
  the last word in mod_proxy_fcgi's fix_cgivars.
- WHPProxyScrubEnv: tenant-set PHP_VALUE / PHP_ADMIN_VALUE /
  PATH_TRANSLATED removed before the backend params are built.
- WHPDenyHandler: 403 for balancer-manager, server-status, server-info,
  lua-script, cgi-script (+ their MIME aliases) whatever selected them.
Image defaults (configs/whp-proxy-guard.conf): Deny, scrub, default allow
list fcgi://*:9000 (every WHP-rendered PHP handler), deny list. WHP renders
a per-vhost exact list inside <IfModule whp_proxy_guard_module>.

scripts/tests/whp-proxy-guard-module.test.sh: 36 assertions, PASS on the
built image, 24 FAIL on the current shared-httpd:latest.

DRAFT - DO NOT MERGE (merging publishes the image).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-23 07:20:15 -08:00