Skip to content

Report incomplete process inspection instead of a clean stale-worker check - #1

Closed
artifexignotvs wants to merge 1 commit into
EXT-IT:mainfrom
artifexignotvs:fix-process-inspection-gaps
Closed

artifexignotvs wants to merge 1 commit into
EXT-IT:mainfrom
artifexignotvs:fix-process-inspection-gaps

Conversation

@artifexignotvs

Copy link
Copy Markdown
Contributor

Root inside a container may lack permission to inspect PHP workers even when its effective UID is zero. The stale-process check currently skips failed reads of /proc/<pid>/exe and can report the process check as ok despite visible PHP workers that it could not inspect.

This change records an unknown process finding for recognized PHP/Apache processes with inaccessible executable links, or Apache processes whose maps cannot be read. It preserves existing restart warnings, avoids an ok finding when inspection is incomplete, ignores zombies and processes that have disappeared, and uses the existing P2S_PROC_ROOT hook for deterministic regression cases. The existing summary logic then returns undecided / exit 2.

Reproduced in an isolated Ubuntu 24.04 container with php8.3-fpm 8.3.6-0ubuntu0.24.04.13. With three stable FPM processes and UID 0, dropping SYS_PTRACE made all three executable links unreadable. On the same process identities, the original script reported not-vulnerable / process ok / exit 0; the patched script reported undecided / process unknown / exit 2. With inspection permission present, the patched script retained process ok / exit 0. No exploit requests were used.

Validation:

  • 236 tests passed, including all 225 existing tests and 11 new process-inspection cases.
  • ShellCheck v0.11.0 at the repository's style level passed.
  • Script checksum updated and verified.
  • The new cases cover current and deleted FPM executables, unreadable FPM/Apache evidence, mixed stale and unreadable processes, unrelated processes, exited processes and zombies.

This does not establish coverage of hidden PIDs or renamed runtimes; it prevents known inspection failures from being treated as successful process checks.

@Kilian-Schwarz

Copy link
Copy Markdown
Contributor

Merged as afdfc06 and released in 3.0.0. Thank you — this closed a real gap,
and your regression cases then caught a second one.

We reproduced the original problem before merging, in an unmodified
php:8.3-fpm container: the master runs as root and its /proc/<pid>/exe is
readable, both workers run as www-data and theirs are not, because Docker's
default capability set has no SYS_PTRACE. The published 2.1.1 answered
[ OK ] process host, "no PHP process runs a replaced binary", exit 0 — about
two processes it had never looked at. The patched script answers [ ?? ] process host and exit 2.

Because that is the normal state of a run inside a container rather than a rare
one, the exit code changes for a documented use case. That is the same shape as
the 2.0.0 change, so it went out as a major version with the consequence
spelled out in the CHANGELOG, and the README now names the container case among
the limits together with --cap-add=SYS_PTRACE.

Then the Alpine job of the matrix turned red on your own case "Apache maps read
failure is unknown, never ok". The reason is portability of the exit code the
Apache branch read: measured on alpine:3.20, busybox grep answers 1 for an
unreadable path where GNU grep answers 2, so on every busybox host the
unreadable case fell back to "no match" and from there to ok — the exact
silence the change was about. 3.0.1 decides readability before grep runs, with
head -c 1, which fails for an unreadable file and for a directory alike.
Measured afterwards: alpine:3.20 235 passed, debian:13 236 passed, macOS 235
passed.

Changed on merge: rebased onto main (2.1.1 at the time), and SHA256SUMS
regenerated over both scripts — the file carries two lines since the PowerShell
edition landed. Nothing else was touched.

Closing this because it landed under a different commit id, not because
anything is outstanding.

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.

2 participants