Repository navigation
feat: ban clients attempting PHP2Shell (v0.2.9) - #14
Merged
Merged
Conversation
Every known PHP2Shell variant pushes PHP past memory_limit with a multipart POST. web.php2shell-attempt reads the lines that step leaves with a client address, and bans: - Apache mod_php: "[client ...] PHP Fatal error: Allowed memory size ... in Unknown on line 0". "Unknown on line 0" means PHP ran out of memory while parsing the request, before any script ran. Application OOMs name a script and line, and are not attempts. - nginx in front of php-fpm: the worker exits after that fatal error, and nginx logs "upstream sent unexpected FastCGI record ... client: ..., request: "POST ..."". php-fpm's own log has no client address. - the public scanner's php2shell-* User-Agent, read only from a combined-format access line. Both log formats were reproduced locally against php:8.3-apache and php:8.3-fpm behind nginx with memory_limit = 4M and a benign 24 MB form POST, not taken from exploit traffic. Each line is one offense. Identical lines in a pass are numbered so the registry does not collapse them, so five in the ban window ban in the pass that reads them. From nginx lines only the timestamp, client and request are kept: server: and host: can be this server's own address, and every address in a sample gets an offense. The vuln.php2shell alert also names the interim workaround, session.upload_progress.enabled = 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
web.php2shell-attempt(src/detectors/php2shell.rs) bans clients whose requests run PHP out of memory before any script runs. Every known PHP2Shell variant (CVE-2026-109618, CVE-2026-109619) relies on that step: multipart POSTs pastmemory_limit(Sansec, Calif).[client …] PHP Fatal error: Allowed memory size … in Unknown on line 0upstream sent unexpected FastCGI record … client: …, request: "POST …"(php-fpm's own log has no client address)php2shell-*User-Agent, combined-format access lines onlyLab:
php:8.3-apache, andnginx:alpinein front ofphp:8.3-fpm, withmemory_limit = 4Mand a benign 24 MB form POST. No exploit code was used. An application OOM reads… in /var/www/html/oom.php on line 1and is not matched.Ban mechanics
(repeat N)), so registry dedup does not collapse an nginx burst into one offense.client:andrequest:are kept.server:andhost:can be this server's own address, and every address in a sample gets an offense.The
vuln.php2shellalert now also names the interim workaround,session.upload_progress.enabled = 0.The version is bumped to 0.2.9.
Review fixes on the branch
"php2shell-report.pdf"could ban an innocent client. It is now restricted to the combined access-log shape.detect_log_anomaliesinto one offense. Repeats are now numbered, and the ban-path test runs through the registry.Verification
cargo test: 460 + 8 + 108 passed, 0 failed, 1 ignored.cargo clippy --all-targets -- -D warningsandcargo fmt --checkare clean.cd website && npm run build: OK.stackdog sniff --onceagainst the lab:php:8.1-clicontainer got the Criticalvuln.php2shellalert from itsPHP_VERSION;Not verified
🤖 Generated with Claude Code