DRAFT, DO NOT MERGE. Measured locally only. The write-up is in /workspace/shared-apache-symlink-protect-2026-11-23.md on the dev box.
Problem
Tenant .htaccess lines Options +FollowSymLinks, All and Includes answer 500 on shared-httpd since the WHP AllowOverride ... Options= lockdown (PR #346). Stock CodeIgniter 4, Joomla, OpenCart and Magento 2 files all contain one of them.
Change
mod_whp_symlink is a small loadable module. It is built against the distro httpd-devel in a build stage, so the stock AlmaLinux httpd RPMs and their errata stay. It has two features:
WHPHtaccessOptionsRemap On rewrites the Options line of a .htaccess before the core parses it:
FollowSymLinks becomes SymLinksIfOwnerMatch.
Includes becomes IncludesNOEXEC.
Positive ExecCGI is dropped.
A name is only emitted if AllowOverride permits it.
The core's own resolve_symlink owner check stays in charge. Because the rewrite happens at parse time, it also covers nested <If>.
WHPOwnerGuard Log|On checks the owner of the file descriptor actually served (fstat in an output filter) against the owner of DocumentRoot. This is the Bluehost/cPanel SymlinkProtect idea without a core patch. It closes the SymLinksIfOwnerMatch check-then-open race and the swapped-public_html case. It ships in Log mode.
The build fails if the runtime httpd differs from the httpd-devel it was compiled against, or if the module does not load.
Measured (local docker, httpd 2.4.63-13.el10_2.8)
CMS files. The 4 stock CMS .htaccess files go from 500 to 200, and their front-controller routes go from 500 to 200. The exception is CI4 index.php/$1, a separate WHP SCRIPT_NAME pin bug.
Symlinks. All 8 FollowSymLinks shapes now give 200 for the tenant's own files and 403 for a cross-tenant symlink.
Race. Tenant A swaps a dir and a symlink to B with RENAME_EXCHANGE while requests run:
Setup
Leaked B's file
Today
1639 of ~8000
WHPOwnerGuard On
0
Nested <If>. Nested <If> ExecCGI no longer runs CGI on the trunk image.
Performance. No measurable overhead in ab.
WHP harness.test-shared-httpd-tenant-isolation.sh against this image fails only its 7 "want 500" assertions, which now answer 403 or 200 with no leak. WHP has to update those assertions.
An automated security review found two HIGH issues in the first prototype. Both are fixed:
Incomplete remap. Only bare All was handled. The rewrite is now deny-by-default: every word is matched against the full core keyword list and only known-safe keywords are emitted (+/- prefix kept). Any symlink-follow form becomes SymLinksIfOwnerMatch, any exec-SSI form becomes IncludesNOEXEC or is dropped, positive ExecCGI is dropped, and unknown words are dropped.
Parser differential.ap_getword_conf removes quotes before the line is re-joined for the core. .htaccess Options lines containing ", ' or \ are now refused with a config error, which enables nothing.
The new scripts/tests/whp-symlink-module.test.sh covers 29 forms: ±All, All mixed with +/-, case and spelling variants, quoted, escaped and tab-separated. Each form is checked for cross-tenant reads, SSI/CGI exec, quoted-line refusal and the swapped-docroot guard. Against this image it passes 71/71. The local 44-form matrix passes 88/88 with 0 cross-tenant reads and 0 exec. The full CMS, symlink and race matrix was re-run with unchanged results: race leaks were 1365 without the guard and 0 with it.
Removed the racy WHPSymlinkWalk prototype (hook, directive, docs). WHPOwnerGuard is the race-free mechanism.
Bare Options All keeps Apache semantics (All includes Indexes, excludes MultiViews): it maps to Indexes SymLinksIfOwnerMatch. Now asserted (directory listing 200, MultiViews 404, same-owner symlink 200, cross-tenant refused, plus None/+MultiViews controls).
CI: .gitea/workflows/shared-httpd-symlink-pr.yaml runs the probe test on pull requests (amd64 image built locally, nothing pushed, no secrets). Build-Shared-httpd in build-push.yaml runs the same test against the amd64 digest it just pushed, before the arm64 build and tag assembly, so a failure publishes no tag. WHP_SYMTEST_REQUIRE=1 makes a missing docker/image a failure instead of a SKIP. Local run: docs/shared-httpd-symlink-module.md.
Probe test: 106/106 on the rebuilt image (and 87 passed, 20 failed against an image without the module). WHP isolation harness: only the 7 expected "want 500" assertions fail (now 403, or 200 with the SSI exec left unexecuted); 59 pass. Workflow wiring test 42/42, bash -n and shellcheck clean.
CI hardening (security review, MEDIUM)
Runner finding: Gitea has two online ubuntu-latest runners and no separate label for untrusted jobs (the others are arm64, windows, macos), so PR jobs and publish jobs share runners.
The PR workflow now has no secrets and no registry login, checks out without persisted credentials, builds with --pull --no-cache under a per-run tag shared-httpd:pr-probe-<run_id>, and removes its image and containers in an if: always() step.
Every docker/build-push-action step in build-push.yaml (12) now sets pull: true and no-cache: true (fresh buildx builder per job, base image already digest-pinned), so a publish build never reuses a local cache or image.
Maintainer setting (Josh's call): require approval for PR workflows from forks in the Gitea repo settings.
Remaining blockers before un-drafting
The WHP PR with the <Directory "/mnt/users"> Options SymLinksIfOwnerMatch block (docroot swap) must land first, together with the harness update (the 7 "want 500" assertions) and later WHPOwnerGuard On.
Coordinate with PR #59 (touches the same Dockerfile/workflow area); rebase whichever lands second.
arm64 is not probed in CI (amd64 only); an arm64 build check is still open.
DO NOT MERGE: merging to trunk publishes production images.
DRAFT, DO NOT MERGE. Measured locally only. The write-up is in `/workspace/shared-apache-symlink-protect-2026-11-23.md` on the dev box.
## Problem
Tenant `.htaccess` lines `Options +FollowSymLinks`, `All` and `Includes` answer **500** on shared-httpd since the WHP `AllowOverride ... Options=` lockdown (PR #346). Stock CodeIgniter 4, Joomla, OpenCart and Magento 2 files all contain one of them.
## Change
`mod_whp_symlink` is a small loadable module. It is built against the distro `httpd-devel` in a build stage, so the stock AlmaLinux httpd RPMs and their errata stay. It has two features:
- **`WHPHtaccessOptionsRemap On`** rewrites the `Options` line of a `.htaccess` before the core parses it:
- FollowSymLinks becomes SymLinksIfOwnerMatch.
- Includes becomes IncludesNOEXEC.
- Positive ExecCGI is dropped.
- A name is only emitted if AllowOverride permits it.
The core's own `resolve_symlink` owner check stays in charge. Because the rewrite happens at parse time, it also covers nested `<If>`.
- **`WHPOwnerGuard Log|On`** checks the owner of the file descriptor actually served (fstat in an output filter) against the owner of DocumentRoot. This is the Bluehost/cPanel SymlinkProtect idea without a core patch. It closes the SymLinksIfOwnerMatch check-then-open race and the swapped-`public_html` case. It ships in **Log** mode.
The build fails if the runtime httpd differs from the httpd-devel it was compiled against, or if the module does not load.
## Measured (local docker, httpd 2.4.63-13.el10_2.8)
**CMS files.** The 4 stock CMS `.htaccess` files go from 500 to 200, and their front-controller routes go from 500 to 200. The exception is CI4 `index.php/$1`, a separate WHP SCRIPT_NAME pin bug.
**Symlinks.** All 8 FollowSymLinks shapes now give 200 for the tenant's own files and 403 for a cross-tenant symlink.
**Race.** Tenant A swaps a dir and a symlink to B with RENAME_EXCHANGE while requests run:
| Setup | Leaked B's file |
|---|---|
| Today | 1639 of ~8000 |
| `WHPOwnerGuard On` | 0 |
**Nested `<If>`.** Nested `<If>` ExecCGI no longer runs CGI on the trunk image.
**Performance.** No measurable overhead in `ab`.
**WHP harness.** `test-shared-httpd-tenant-isolation.sh` against this image fails only its 7 "want 500" assertions, which now answer 403 or 200 with no leak. WHP has to update those assertions.
## Security review fixes (commit 31e42ec)
An automated security review found two HIGH issues in the first prototype. Both are fixed:
1. **Incomplete remap.** Only bare `All` was handled. The rewrite is now deny-by-default: every word is matched against the full core keyword list and only known-safe keywords are emitted (+/- prefix kept). Any symlink-follow form becomes SymLinksIfOwnerMatch, any exec-SSI form becomes IncludesNOEXEC or is dropped, positive ExecCGI is dropped, and unknown words are dropped.
2. **Parser differential.** `ap_getword_conf` removes quotes before the line is re-joined for the core. `.htaccess` Options lines containing `"`, `'` or `\` are now refused with a config error, which enables nothing.
The new `scripts/tests/whp-symlink-module.test.sh` covers 29 forms: ±All, All mixed with +/-, case and spelling variants, quoted, escaped and tab-separated. Each form is checked for cross-tenant reads, SSI/CGI exec, quoted-line refusal and the swapped-docroot guard. Against this image it passes 71/71. The local 44-form matrix passes 88/88 with 0 cross-tenant reads and 0 exec. The full CMS, symlink and race matrix was re-run with unchanged results: race leaks were 1365 without the guard and 0 with it.
## Update 0d9e57e (review items)
- **Removed** the racy `WHPSymlinkWalk` prototype (hook, directive, docs). `WHPOwnerGuard` is the race-free mechanism.
- **Bare `Options All`** keeps Apache semantics (All includes Indexes, excludes MultiViews): it maps to `Indexes SymLinksIfOwnerMatch`. Now asserted (directory listing 200, MultiViews 404, same-owner symlink 200, cross-tenant refused, plus None/+MultiViews controls).
- **CI**: `.gitea/workflows/shared-httpd-symlink-pr.yaml` runs the probe test on pull requests (amd64 image built locally, nothing pushed, no secrets). `Build-Shared-httpd` in `build-push.yaml` runs the same test against the amd64 digest it just pushed, before the arm64 build and tag assembly, so a failure publishes no tag. `WHP_SYMTEST_REQUIRE=1` makes a missing docker/image a failure instead of a SKIP. Local run: `docs/shared-httpd-symlink-module.md`.
- Probe test: 106/106 on the rebuilt image (and 87 passed, 20 failed against an image without the module). WHP isolation harness: only the 7 expected "want 500" assertions fail (now 403, or 200 with the SSI exec left unexecuted); 59 pass. Workflow wiring test 42/42, bash -n and shellcheck clean.
## CI hardening (security review, MEDIUM)
- Runner finding: Gitea has two online `ubuntu-latest` runners and no separate label for untrusted jobs (the others are arm64, windows, macos), so PR jobs and publish jobs share runners.
- The PR workflow now has no secrets and no registry login, checks out without persisted credentials, builds with `--pull --no-cache` under a per-run tag `shared-httpd:pr-probe-<run_id>`, and removes its image and containers in an `if: always()` step.
- Every `docker/build-push-action` step in `build-push.yaml` (12) now sets `pull: true` and `no-cache: true` (fresh buildx builder per job, base image already digest-pinned), so a publish build never reuses a local cache or image.
- **Maintainer setting (Josh's call):** require approval for PR workflows from forks in the Gitea repo settings.
## Remaining blockers before un-drafting
- The WHP PR with the `<Directory "/mnt/users"> Options SymLinksIfOwnerMatch` block (docroot swap) must land first, together with the harness update (the 7 "want 500" assertions) and later `WHPOwnerGuard On`.
- Coordinate with PR #59 (touches the same Dockerfile/workflow area); rebase whichever lands second.
- arm64 is not probed in CI (amd64 only); an arm64 build check is still open.
- DO NOT MERGE: merging to trunk publishes production images.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Tenant .htaccess files that say `Options +FollowSymLinks` / `All` /
`Includes` (stock CodeIgniter 4, Joomla, OpenCart, Magento) answer 500 on the
shared tier since the AllowOverride Options= lockdown. A small loadable module,
built against the distribution httpd-devel (stock AlmaLinux httpd RPMs stay):
- WHPHtaccessOptionsRemap On: rewrites the Options line in .htaccess before
the core parses it (FollowSymLinks -> SymLinksIfOwnerMatch, Includes ->
IncludesNOEXEC, positive ExecCGI dropped), so those files work while the
core's own owner-match symlink check stays in charge. Covers nested <If>.
- WHPOwnerGuard Log|On: fstat() owner check on the file descriptor actually
served (the Bluehost/cPanel SymlinkProtect idea, as an output filter);
closes the SymLinksIfOwnerMatch check-then-open race and the swapped
public_html case. Ships in Log mode.
DRAFT: measured locally only, see the WHP-side write-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Security review (2 HIGH):
- Incomplete remap: only bare `All` was handled; `+All`/`-All`, `None +X`,
`RunScripts` etc. passed through. The remap now matches every word against
the full core keyword list and emits only known-safe names (prefix kept,
core +/- mixing rules respected): any symlink-follow form ->
SymLinksIfOwnerMatch, any exec-SSI form -> IncludesNOEXEC (only if allowed,
else dropped), positive ExecCGI dropped, unknown words dropped. The line is
always replaced by the normalised form, so the core never sees input words.
- Parser differential: ap_getword_conf() unquotes, and the re-joined line was
re-tokenised by the core. A line containing quote or backslash characters is
now refused (config error -> 500, nothing enabled); emitted tokens are fixed
keywords, so the join is unambiguous.
scripts/tests/whp-symlink-module.test.sh probes 29 Options forms (+All, -All,
All mixed with +/-, case and FollowSymlinks spelling variants, quoted,
escaped, tab-separated) for cross-tenant symlink reads, SSI/CGI exec, refusal
of quoted lines, and the swapped public_html owner guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- guard_filter logged fi.user uninitialised when fstat of the served fd
failed (refusal itself was already fail-closed); now -1.
- Drop the unused guard_ctx.checked_ok.
- Header: state what the fd guard cannot see (no FILE bucket): 304 to a
conditional request (confirms a wrong-owner target's ETag, measured),
mod_autoindex listings (a swapped public_html still lists the other
tenant's directory names with guard On and no WHP <Directory /mnt/users>
fix, measured), PHP via FPM.
- whp-symlink-module.test.sh: Options inside nested <If>, <ElseIf>, <Else>,
<Files>+<If>, <FilesMatch>, <IfModule>/<IfDefine>/<IfVersion>, <Limit>,
mod_macro expansion, backslash line continuation; and a tenant .htaccess
setting WHPOwnerGuard / WHPHtaccessOptionsRemap (also inside <If>) must
500. 100/100 against the rebuilt image.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Independent security review (adversarial, local docker only) — verdict: no bypass found; keep DRAFT until the items under "Before un-drafting" are done
Reviewed 31e42ec line by line against the httpd 2.4.63 source, rebuilt the image from the branch (amd64 native; arm64 under QEMU: compiles with -Werror, version gate, httpd -t and httpd -M all pass), and probed it with two tenants (uid 1006 / 1003) using WHP's current shared-vhost-template + shared-httpd-security.conf. Pushed one small commit (1953a17, see below). Not merged.
Mechanism (verified in source and by measurement)
ap_walk_config_sub invokes every module that declares Options, most recently added first, re-reading current->args each time; loaded modules are prepended after the prelinked core, also after a restart (rebuild_conf_hash(pconf, 1) then LoadModule). Remap still active after graceful x3 and -k restart.
is_htaccess() is sound: in .htaccesscmd->path is non-NULL, so <Files>/<If> never add ACCESS_CONF there; <Directory>/<Location>/<Proxy> (which do) are not allowed in .htaccess. Server config is passed through untouched (measured: a server <Directory> Options FollowSymLinks still follows a cross-owner link).
${VAR}, mod_macro Use, and backslash continuation are all resolved before the module sees the line (continuation lines are joined by ap_cfg_getline, so the backslash refusal does not affect stock CMS files: measured 200).
Tenants cannot set WHPOwnerGuard* / WHPHtaccessOptionsRemap (no OR_* override; 500 even inside <If>).
Bypass matrix (all: no cross-tenant read, no SSI/CGI exec)
Attempt
Result
Author's 44-form adversarial set (rerun on my build)
inert (raw SSI / source / "Options ExecCGI is off")
DirectoryIndex / MultiViews / ErrorDocument pointing at the cross-tenant link
403 / 404
per-dir RewriteRule to /mnt/users/b/..., [PT], ../, %{DOCUMENT_ROOT}/..
404 / 400
docroot swap, PR defaults (guard Log, no WHP dir fix)
200 B's file (pre-existing; image alone does not close it)
docroot swap, guard On, no WHP dir fix
files 404, but directory listing of B's dir still 200 and If-None-Match: <B's ETag> gets 304
docroot swap, guard On + WHP <Directory "/mnt/users"> Options SymLinksIfOwnerMatch
403 everywhere
Race (renameat2 swapper, 8 clients)
guard Log: 1,675 leaks; guard On: 0 leaks, 2,416 refusals
Findings
Sev
Where
Finding
Action
Medium (config)
WHP shared-httpd-security.conf
The image (guard Log) does not close the docroot swap; guard On alone leaves the swapped dir's listing (names) and a 304 ETag oracle.
WHP <Directory "/mnt/users"> Options SymLinksIfOwnerMatch is mandatory, land before/with this image.
Low
mod_whp_symlink.c guard_filter
No FILE bucket => not checked: 304 to a conditional request confirms a wrong-owner target's ETag (needs the exact ETag); autoindex listings of a raced dir.
Documented in header (1953a17). Optional follow-up: also compare r->finfo.user in a fixups hook (not race-free, but closes 304 + listing for the non-race case).
Low
mod_whp_symlink.c:390-446
WHPSymlinkWalk prototype (measured racy) ships in the production module.
Remove before un-draft (opt-in only, so not a vuln).
Info (fixed)
mod_whp_symlink.c:362
fi.user logged uninitialised when fstat of the served fd failed (refusal was already fail-closed).
Fixed in 1953a17; also dropped unused checked_ok.
Info
mod_whp_symlink.c:209
-Includes -> -IncludesNOEXEC clears OPT_INCLUDES but not OPT_INC_WITH_EXEC. Harmless: nothing in WHP config grants exec-SSI to tenant dirs.
None.
Info
mod_whp_symlink.c:198
-SymLinksIfOwnerMatch passes through; it would expose an inherited FollowSymLinks. WHP's absolute Options at the docroot (and the /mnt/users fix) prevent any inheritance.
Keep docroot Options absolute in WHP.
Residual, not this PR
trunk image
mod_lua LuaHook* (OR_ALL, allowed in .htaccess), mod_info / mod_cgid via nested-If handler: not Options-based. AuthUserFile naming another tenant's file: not symlink-based, not tested.
KeepAllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,MultiViews,SymLinksIfOwnerMatch,ExecCGI exactly as today. The module only ever emits names from this list (synthesised names go through push_if), so it is safe and fully functional with the narrow list (that is what was tested).
Do NOT add FollowSymLinks (or Includes) to Options=. It is not needed (the module rewrites it to SymLinksIfOwnerMatch), and on a rollback image or with WHPHtaccessOptionsRemap Off it would re-open cross-tenant symlinks. The module itself is safe even under AllowOverride All (FollowSymLinks/Includes/+ExecCGI never reach the core), but the WHP list must stay safe on its own.
Optional: drop ExecCGI from Options= only after #59 (then -ExecCGI lines would 500 without the module; with the module they pass).
Required: <Directory "/mnt/users"> Options SymLinksIfOwnerMatch </Directory>; later WHPOwnerGuard On inside <IfModule whp_symlink_module>.
Distro httpd-devel only, no network sources; -Wall -Werror; .so has full RELRO, BIND_NOW, NX stack, stack protector; build fails on httpd vs httpd-devel version-release drift and if the module does not load. arm64 build passes under QEMU.
Before un-drafting
Wire scripts/tests/whp-symlink-module.test.sh into CI (amd64 leg).
Remove the WHPSymlinkWalk prototype.
WHP PR with the /mnt/users Directory fix (must ship first) and the updated isolation harness.
Decide Indexes for bare All; optionally the fixups-time owner check.
Performance was not re-measured (one lstat + one fstat per static response).
## Independent security review (adversarial, local docker only) — verdict: no bypass found; keep DRAFT until the items under "Before un-drafting" are done
Reviewed 31e42ec line by line against the httpd 2.4.63 source, rebuilt the image from the branch (amd64 native; arm64 under QEMU: compiles with `-Werror`, version gate, `httpd -t` and `httpd -M` all pass), and probed it with two tenants (uid 1006 / 1003) using WHP's current `shared-vhost-template` + `shared-httpd-security.conf`. Pushed one small commit (1953a17, see below). Not merged.
### Mechanism (verified in source and by measurement)
- `ap_walk_config_sub` invokes every module that declares `Options`, most recently added first, re-reading `current->args` each time; loaded modules are prepended after the prelinked core, also after a restart (`rebuild_conf_hash(pconf, 1)` then `LoadModule`). Remap still active after `graceful` x3 and `-k restart`.
- `is_htaccess()` is sound: in `.htaccess` `cmd->path` is non-NULL, so `<Files>`/`<If>` never add ACCESS_CONF there; `<Directory>`/`<Location>`/`<Proxy>` (which do) are not allowed in `.htaccess`. Server config is passed through untouched (measured: a server `<Directory> Options FollowSymLinks` still follows a cross-owner link).
- `${VAR}`, mod_macro `Use`, and backslash continuation are all resolved before the module sees the line (continuation lines are joined by `ap_cfg_getline`, so the backslash refusal does not affect stock CMS files: measured 200).
- Tenants cannot set `WHPOwnerGuard*` / `WHPHtaccessOptionsRemap` (no OR_* override; 500 even inside `<If>`).
### Bypass matrix (all: no cross-tenant read, no SSI/CGI exec)
| Attempt | Result |
|---|---|
| Author's 44-form adversarial set (rerun on my build) | 88/88 pass |
| `Options` in nested `<If><If>`, `<ElseIf>`, `<Else>`, `<Files>`, `<Files><If><If>`, `<FilesMatch>`, `<IfModule>`/`<IfModule !x><If>`, `<IfDefine>`, `<IfVersion>`, `<IfFile>`, `<IfDirective>`, `<Limit>`, `<LimitExcept>` | remapped: 200 own / 403 cross-tenant |
| mod_macro `Use M +FollowSymLinks`, `Use M All`, `Use M FollowSymLinks ExecCGI` | remapped |
| `${UNDEF}` / `${HOSTNAME}` inside the word list | expanded first; unknown words dropped |
| continuation `\` + newline, CRLF, `\v`, `\f`, NUL byte, UTF-8 homoglyph, `++X`, `=X`, `X#y`, `OPTIONS` upper-case directive | safe (remapped / dropped) |
| 8 KB line (880 words), 2,500 words, 8,000-char word, 18 KB line | safe; 18 KB = core "line too long" 500 |
| 60 random-byte lines + 60 random keyword combos | 0 leaks, 0 exec, 0 crashes (children alive) |
| `-SymLinksIfOwnerMatch` alone, `-All`, `None +Indexes`, `All -Indexes`, two Options lines | symlinks off or owner-checked |
| `XBitHack full`, `RewriteRule [H=cgi-script]` + nested-If ExecCGI, `<Files><If> SetHandler cgi-script` + ExecCGI | inert (raw SSI / source / "Options ExecCGI is off") |
| DirectoryIndex / MultiViews / ErrorDocument pointing at the cross-tenant link | 403 / 404 |
| per-dir RewriteRule to `/mnt/users/b/...`, `[PT]`, `../`, `%{DOCUMENT_ROOT}/..` | 404 / 400 |
| docroot swap, PR defaults (guard **Log**, no WHP dir fix) | **200 B's file** (pre-existing; image alone does not close it) |
| docroot swap, guard **On**, no WHP dir fix | files 404, but **directory listing of B's dir still 200** and `If-None-Match: <B's ETag>` gets **304** |
| docroot swap, guard On + WHP `<Directory "/mnt/users"> Options SymLinksIfOwnerMatch` | 403 everywhere |
| Race (`renameat2` swapper, 8 clients) | guard Log: **1,675 leaks**; guard On: **0 leaks**, 2,416 refusals |
### Findings
| Sev | Where | Finding | Action |
|---|---|---|---|
| Medium (config) | WHP `shared-httpd-security.conf` | The image (guard Log) does not close the docroot swap; guard On alone leaves the swapped dir's listing (names) and a 304 ETag oracle. | WHP `<Directory "/mnt/users"> Options SymLinksIfOwnerMatch` is **mandatory**, land before/with this image. |
| Low | `mod_whp_symlink.c` guard_filter | No FILE bucket => not checked: 304 to a conditional request confirms a wrong-owner target's ETag (needs the exact ETag); autoindex listings of a raced dir. | Documented in header (1953a17). Optional follow-up: also compare `r->finfo.user` in a fixups hook (not race-free, but closes 304 + listing for the non-race case). |
| Low | `mod_whp_symlink.c:390-446` | `WHPSymlinkWalk` prototype (measured racy) ships in the production module. | Remove before un-draft (opt-in only, so not a vuln). |
| Info (fixed) | `mod_whp_symlink.c:362` | `fi.user` logged uninitialised when `fstat` of the served fd failed (refusal was already fail-closed). | Fixed in 1953a17; also dropped unused `checked_ok`. |
| Info | `mod_whp_symlink.c:209` | `-Includes` -> `-IncludesNOEXEC` clears OPT_INCLUDES but not OPT_INC_WITH_EXEC. Harmless: nothing in WHP config grants exec-SSI to tenant dirs. | None. |
| Info | `mod_whp_symlink.c:198` | `-SymLinksIfOwnerMatch` passes through; it would expose an *inherited* FollowSymLinks. WHP's absolute `Options` at the docroot (and the /mnt/users fix) prevent any inheritance. | Keep docroot `Options` absolute in WHP. |
| Residual, not this PR | trunk image | mod_lua `LuaHook*` (OR_ALL, allowed in .htaccess), mod_info / mod_cgid via nested-If handler: not Options-based. `AuthUserFile` naming another tenant's file: not symlink-based, not tested. | PR #59 removes the modules; merge #59 too. |
### AllowOverride / WHP config the module needs
- **Keep** `AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,MultiViews,SymLinksIfOwnerMatch,ExecCGI` exactly as today. The module only ever emits names from this list (synthesised names go through `push_if`), so it is safe and fully functional with the narrow list (that is what was tested).
- **Do NOT add FollowSymLinks** (or Includes) to `Options=`. It is not needed (the module rewrites it to SymLinksIfOwnerMatch), and on a rollback image or with `WHPHtaccessOptionsRemap Off` it would re-open cross-tenant symlinks. The module itself is safe even under `AllowOverride All` (FollowSymLinks/Includes/+ExecCGI never reach the core), but the WHP list must stay safe on its own.
- Optional: drop `ExecCGI` from `Options=` only after #59 (then `-ExecCGI` lines would 500 without the module; with the module they pass).
- Required: `<Directory "/mnt/users"> Options SymLinksIfOwnerMatch </Directory>`; later `WHPOwnerGuard On` inside `<IfModule whp_symlink_module>`.
### Regressions (stock .htaccess, WHP template, no FPM: route = rewrite reached index.php)
| | static | same-owner file link | same-owner dir link | route |
|---|---|---|---|---|
| stock image | WordPress, Laravel, Nextcloud, MediaWiki OK; **Drupal (root + files dir), Magento 1, Magento 2 (root, pub/static, pub/media), Joomla, CI4, OpenCart, `Options All -Indexes` = 500** | same | same | same |
| PR image (Log, and dirfix+On) | all 200 | all 200 | all 200 | all reach index.php except CI4 (`index.php/$1` PATH_INFO, known separate WHP bug) |
`Options -Indexes` still 403s listings. In-PR test: 100/100 (71 + 29 new).
### Build / supply chain
Distro `httpd-devel` only, no network sources; `-Wall -Werror`; `.so` has full RELRO, BIND_NOW, NX stack, stack protector; build fails on httpd vs httpd-devel version-release drift and if the module does not load. arm64 build passes under QEMU.
### Before un-drafting
1. Wire `scripts/tests/whp-symlink-module.test.sh` into CI (amd64 leg).
2. Remove the `WHPSymlinkWalk` prototype.
3. WHP PR with the `/mnt/users` Directory fix (must ship first) and the updated isolation harness.
4. Decide `Indexes` for bare `All`; optionally the fixups-time owner check.
Performance was not re-measured (one `lstat` + one `fstat` per static response).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- Remove the WHPSymlinkWalk post-walk lstat prototype (check-then-use race by
construction; WHPOwnerGuard is the race-free mechanism): hook, directive,
per-dir member, header docs. The directive is now an unknown command.
- Probe test: WHP_SYMTEST_REQUIRE=1 turns every SKIP into a FAIL (no docker, no
image, container does not start) and a minimum assertion count is enforced.
New assertions: bare `Options All` keeps Apache semantics (Indexes on,
MultiViews off, same-owner symlink followed, cross-tenant refused) plus
None/+MultiViews controls (106 assertions).
- CI: new pull_request workflow shared-httpd-symlink-pr.yaml (builds amd64
locally, no push/secrets, runs the probe test); build-push.yaml
Build-Shared-httpd runs the probe test against the amd64 digest it just pushed,
before the arm64 build and tag assembly, so a failure publishes no tag.
Test script added to the shellcheck set; wiring tests added.
- docs/shared-httpd-symlink-module.md: behaviour, local run, CI.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- PR workflow: no secrets/registry login, checkout without persisted credentials,
docker build --pull --no-cache, per-run tag shared-httpd:pr-probe-<run_id>,
always() cleanup of the image and containers.
- build-push.yaml: every docker/build-push-action step gets pull: true and
no-cache: true (base is already digest-pinned by the resolve step).
- Wiring tests for both; docs: CI trust model.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
All checks were successful
shared-httpd mod_whp_symlink PR check / Symlink-Module-Probe (pull_request) Successful in 2m25s
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
DRAFT, DO NOT MERGE. Measured locally only. The write-up is in
/workspace/shared-apache-symlink-protect-2026-11-23.mdon the dev box.Problem
Tenant
.htaccesslinesOptions +FollowSymLinks,AllandIncludesanswer 500 on shared-httpd since the WHPAllowOverride ... Options=lockdown (PR #346). Stock CodeIgniter 4, Joomla, OpenCart and Magento 2 files all contain one of them.Change
mod_whp_symlinkis a small loadable module. It is built against the distrohttpd-develin a build stage, so the stock AlmaLinux httpd RPMs and their errata stay. It has two features:WHPHtaccessOptionsRemap Onrewrites theOptionsline of a.htaccessbefore the core parses it:The core's own
resolve_symlinkowner check stays in charge. Because the rewrite happens at parse time, it also covers nested<If>.WHPOwnerGuard Log|Onchecks the owner of the file descriptor actually served (fstat in an output filter) against the owner of DocumentRoot. This is the Bluehost/cPanel SymlinkProtect idea without a core patch. It closes the SymLinksIfOwnerMatch check-then-open race and the swapped-public_htmlcase. It ships in Log mode.The build fails if the runtime httpd differs from the httpd-devel it was compiled against, or if the module does not load.
Measured (local docker, httpd 2.4.63-13.el10_2.8)
CMS files. The 4 stock CMS
.htaccessfiles go from 500 to 200, and their front-controller routes go from 500 to 200. The exception is CI4index.php/$1, a separate WHP SCRIPT_NAME pin bug.Symlinks. All 8 FollowSymLinks shapes now give 200 for the tenant's own files and 403 for a cross-tenant symlink.
Race. Tenant A swaps a dir and a symlink to B with RENAME_EXCHANGE while requests run:
WHPOwnerGuard OnNested
<If>. Nested<If>ExecCGI no longer runs CGI on the trunk image.Performance. No measurable overhead in
ab.WHP harness.
test-shared-httpd-tenant-isolation.shagainst this image fails only its 7 "want 500" assertions, which now answer 403 or 200 with no leak. WHP has to update those assertions.Security review fixes (commit
31e42ec)An automated security review found two HIGH issues in the first prototype. Both are fixed:
Allwas handled. The rewrite is now deny-by-default: every word is matched against the full core keyword list and only known-safe keywords are emitted (+/- prefix kept). Any symlink-follow form becomes SymLinksIfOwnerMatch, any exec-SSI form becomes IncludesNOEXEC or is dropped, positive ExecCGI is dropped, and unknown words are dropped.ap_getword_confremoves quotes before the line is re-joined for the core..htaccessOptions lines containing",'or\are now refused with a config error, which enables nothing.The new
scripts/tests/whp-symlink-module.test.shcovers 29 forms: ±All, All mixed with +/-, case and spelling variants, quoted, escaped and tab-separated. Each form is checked for cross-tenant reads, SSI/CGI exec, quoted-line refusal and the swapped-docroot guard. Against this image it passes 71/71. The local 44-form matrix passes 88/88 with 0 cross-tenant reads and 0 exec. The full CMS, symlink and race matrix was re-run with unchanged results: race leaks were 1365 without the guard and 0 with it.Update
0d9e57e(review items)WHPSymlinkWalkprototype (hook, directive, docs).WHPOwnerGuardis the race-free mechanism.Options Allkeeps Apache semantics (All includes Indexes, excludes MultiViews): it maps toIndexes SymLinksIfOwnerMatch. Now asserted (directory listing 200, MultiViews 404, same-owner symlink 200, cross-tenant refused, plus None/+MultiViews controls)..gitea/workflows/shared-httpd-symlink-pr.yamlruns the probe test on pull requests (amd64 image built locally, nothing pushed, no secrets).Build-Shared-httpdinbuild-push.yamlruns the same test against the amd64 digest it just pushed, before the arm64 build and tag assembly, so a failure publishes no tag.WHP_SYMTEST_REQUIRE=1makes a missing docker/image a failure instead of a SKIP. Local run:docs/shared-httpd-symlink-module.md.CI hardening (security review, MEDIUM)
ubuntu-latestrunners and no separate label for untrusted jobs (the others are arm64, windows, macos), so PR jobs and publish jobs share runners.--pull --no-cacheunder a per-run tagshared-httpd:pr-probe-<run_id>, and removes its image and containers in anif: always()step.docker/build-push-actionstep inbuild-push.yaml(12) now setspull: trueandno-cache: true(fresh buildx builder per job, base image already digest-pinned), so a publish build never reuses a local cache or image.Remaining blockers before un-drafting
<Directory "/mnt/users"> Options SymLinksIfOwnerMatchblock (docroot swap) must land first, together with the harness update (the 7 "want 500" assertions) and laterWHPOwnerGuard On.🤖 Generated with Claude Code
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Independent security review (adversarial, local docker only) — verdict: no bypass found; keep DRAFT until the items under "Before un-drafting" are done
Reviewed
31e42ecline by line against the httpd 2.4.63 source, rebuilt the image from the branch (amd64 native; arm64 under QEMU: compiles with-Werror, version gate,httpd -tandhttpd -Mall pass), and probed it with two tenants (uid 1006 / 1003) using WHP's currentshared-vhost-template+shared-httpd-security.conf. Pushed one small commit (1953a17, see below). Not merged.Mechanism (verified in source and by measurement)
ap_walk_config_subinvokes every module that declaresOptions, most recently added first, re-readingcurrent->argseach time; loaded modules are prepended after the prelinked core, also after a restart (rebuild_conf_hash(pconf, 1)thenLoadModule). Remap still active aftergracefulx3 and-k restart.is_htaccess()is sound: in.htaccesscmd->pathis non-NULL, so<Files>/<If>never add ACCESS_CONF there;<Directory>/<Location>/<Proxy>(which do) are not allowed in.htaccess. Server config is passed through untouched (measured: a server<Directory> Options FollowSymLinksstill follows a cross-owner link).${VAR}, mod_macroUse, and backslash continuation are all resolved before the module sees the line (continuation lines are joined byap_cfg_getline, so the backslash refusal does not affect stock CMS files: measured 200).WHPOwnerGuard*/WHPHtaccessOptionsRemap(no OR_* override; 500 even inside<If>).Bypass matrix (all: no cross-tenant read, no SSI/CGI exec)
Optionsin nested<If><If>,<ElseIf>,<Else>,<Files>,<Files><If><If>,<FilesMatch>,<IfModule>/<IfModule !x><If>,<IfDefine>,<IfVersion>,<IfFile>,<IfDirective>,<Limit>,<LimitExcept>Use M +FollowSymLinks,Use M All,Use M FollowSymLinks ExecCGI${UNDEF}/${HOSTNAME}inside the word list\+ newline, CRLF,\v,\f, NUL byte, UTF-8 homoglyph,++X,=X,X#y,OPTIONSupper-case directive-SymLinksIfOwnerMatchalone,-All,None +Indexes,All -Indexes, two Options linesXBitHack full,RewriteRule [H=cgi-script]+ nested-If ExecCGI,<Files><If> SetHandler cgi-script+ ExecCGI/mnt/users/b/...,[PT],../,%{DOCUMENT_ROOT}/..If-None-Match: <B's ETag>gets 304<Directory "/mnt/users"> Options SymLinksIfOwnerMatchrenameat2swapper, 8 clients)Findings
shared-httpd-security.conf<Directory "/mnt/users"> Options SymLinksIfOwnerMatchis mandatory, land before/with this image.mod_whp_symlink.cguard_filter1953a17). Optional follow-up: also comparer->finfo.userin a fixups hook (not race-free, but closes 304 + listing for the non-race case).mod_whp_symlink.c:390-446WHPSymlinkWalkprototype (measured racy) ships in the production module.mod_whp_symlink.c:362fi.userlogged uninitialised whenfstatof the served fd failed (refusal was already fail-closed).checked_ok.mod_whp_symlink.c:209-Includes->-IncludesNOEXECclears OPT_INCLUDES but not OPT_INC_WITH_EXEC. Harmless: nothing in WHP config grants exec-SSI to tenant dirs.mod_whp_symlink.c:198-SymLinksIfOwnerMatchpasses through; it would expose an inherited FollowSymLinks. WHP's absoluteOptionsat the docroot (and the /mnt/users fix) prevent any inheritance.Optionsabsolute in WHP.LuaHook*(OR_ALL, allowed in .htaccess), mod_info / mod_cgid via nested-If handler: not Options-based.AuthUserFilenaming another tenant's file: not symlink-based, not tested.AllowOverride / WHP config the module needs
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,MultiViews,SymLinksIfOwnerMatch,ExecCGIexactly as today. The module only ever emits names from this list (synthesised names go throughpush_if), so it is safe and fully functional with the narrow list (that is what was tested).Options=. It is not needed (the module rewrites it to SymLinksIfOwnerMatch), and on a rollback image or withWHPHtaccessOptionsRemap Offit would re-open cross-tenant symlinks. The module itself is safe even underAllowOverride All(FollowSymLinks/Includes/+ExecCGI never reach the core), but the WHP list must stay safe on its own.ExecCGIfromOptions=only after #59 (then-ExecCGIlines would 500 without the module; with the module they pass).<Directory "/mnt/users"> Options SymLinksIfOwnerMatch </Directory>; laterWHPOwnerGuard Oninside<IfModule whp_symlink_module>.Regressions (stock .htaccess, WHP template, no FPM: route = rewrite reached index.php)
Options All -Indexes= 500index.php/$1PATH_INFO, known separate WHP bug)Options -Indexesstill 403s listings. In-PR test: 100/100 (71 + 29 new).Build / supply chain
Distro
httpd-develonly, no network sources;-Wall -Werror;.sohas full RELRO, BIND_NOW, NX stack, stack protector; build fails on httpd vs httpd-devel version-release drift and if the module does not load. arm64 build passes under QEMU.Before un-drafting
scripts/tests/whp-symlink-module.test.shinto CI (amd64 leg).WHPSymlinkWalkprototype./mnt/usersDirectory fix (must ship first) and the updated isolation harness.Indexesfor bareAll; optionally the fixups-time owner check.Performance was not re-measured (one
lstat+ onefstatper static response).🤖 Generated with Claude Code
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.