5 mincritical
Dissecting a PHP web server rootkit
A Linux rootkit targets BIG-IP APM via CVE-2025-53521, injecting a fileless PHP web shell into Apache memory and providing a local socket backdoor. The implant hooks Apache's APR module loader to inject a web shell into PHP file memory mappings, bypassing disk-based detection. It also creates a local UNIX socket backdoor to /bin/bash. The malware uses RC4 for string obfuscation and custom ELF loading to execute before the host process main().
Sens:■ ImmediateConf:high
Detection / HunterZ.ai
Immediate Actions
- Apply F5 remediation guidance for CVE-2025-53521 on affected BIG-IP APM systems.
- Capture volatile memory evidence from suspected compromised Apache processes before restarting services.
- Block POST requests to apm_css.php3, full_wt.php3, and webtop_popup_css.php3 if not required.
Key Takeaways
- Malware uses RC4 with a 16-byte key (TrswBWIl90Z5e38n) to decrypt operational strings at runtime.
- Custom ELF loader intercepts __libc_start_main to execute before the host application's main().
- Web shell is injected into memory for three specific BIG-IP APM PHP files: apm_css.php3, full_wt.php3, webtop_popup_css.php3.
- Local UNIX socket backdoor created at /run/bigtlog.pipe with authentication token Kzwd6jM5.
- Web shell checks for magic prefix BSOHAzPB in request body and returns HTTP 201 with text/css content type.
Attack Chain
- Initial Access: Exploit CVE-2025-53521 unauthenticated RCE in BIG-IP APM
- Persistence: First-stage loader infects /usr/sbin/httpd and persists across BIG-IP upgrades
- Execution: Custom ELF loader intercepts __libc_start_main to run before main()
- Hooking: Implant hooks apr_dso_load to detect libphp loading, then patches libphp relocations
- Web Shell: mmap() hook prepends PHP web shell to in-memory representation of targeted .php3 files
- Backdoor: apr_time_now hook triggers UNIX socket at /run/bigtlog.pipe redirecting to /bin/bash
Affected Systems
- F5 BIG-IP APM systems with Apache and PHP
- Linux 32-bit (x86) environments
- Apache web servers with libphp module
Vulnerabilities (CVEs)
| CVE | Product | Severity | Description |
|---|---|---|---|
| CVE-2025-53521 | F5 BIG-IP APM | Critical | Unauthenticated remote code execution when an access policy is configured on a virtual server. |
Detection Engineering Assessment
Hunting Hypotheses
| Hypothesis | Telemetry | Stage | FP Risk |
|---|---|---|---|
| Apache worker processes reading /proc/self/maps followed by mprotect() calls on libphp memory regions indicate in-process hooking (T1055). | Process memory access and protection change events. | Defense Evasion | Low — legitimate Apache workers rarely inspect or modify their own memory mappings. |
| PHP endpoints returning HTTP 201 with Content-Type text/css indicate in-memory web shell responses (T1505.003). | Apache access logs and HTTP response headers. | Execution | Medium — some applications may legitimately return CSS from PHP scripts. |
| Apache worker processes creating UNIX domain sockets under /run and spawning /bin/bash indicate local backdoor activation (T1059.004). | Process execution and file creation logs. | Persistence | Low — Apache workers do not normally create IPC sockets or spawn interactive shells. |
| Requests to .php3 endpoints with POST bodies containing a magic prefix indicate web shell activation attempts (T1505.003). | Apache access logs and HTTP request body inspection. | Execution | Medium — .php3 files may be legitimately accessed in BIG-IP APM environments. |
Required Log Sources
- Apache access logs
- Process execution logs
- Memory protection change events
- File integrity monitoring
- UNIX socket creation logs
- HTTP response headers and status codes
Control Gaps
- File integrity monitoring cannot detect in-memory web shell injection
- Network-based detection misses local UNIX socket backdoor
- Static file scanning cannot detect runtime memory modifications
- Signature-based AV cannot detect RC4-encrypted strings and runtime patching
Recommendations
Infrastructure Hardening
- Disable .php3 execution in Apache config if not required: Require all denied for .php3 files.
- Set ptrace_scope to 1 to reduce cross-process inspection and injection opportunities.
- Restrict dangerous PHP functions where operationally feasible.
- Minimize long-lived PHP execution paths in Apache configurations.
User Protection
- Monitor Apache worker processes for /proc/self/maps access and subsequent memory protection changes.
- Alert on Apache processes creating UNIX sockets under /run or spawning /bin/bash.
- Alert on PHP endpoints returning HTTP 201 with text/css content type.
- Incorporate process memory collection into incident response for critical web servers.
MITRE ATT&CK Mapping
MITRE ATT&CK Mapping13 techniques
Tactic
Execution
Tactic
Persistence
Tactic
Privilege Escalation
Tactic
Stealth
Tactic
Collection
Tactic
Unmapped
Showing defanged values
- cveCVE-2025-53521Unauthenticated remote code execution when an access policy is configured on a virtual server.
- filenameapm_css.php3BIG-IP APM PHP file targeted for in-memory web shell injection.
- filenamefull_wt.php3BIG-IP APM PHP file targeted for in-memory web shell injection.
- filenamewebtop_popup_css.php3BIG-IP APM PHP file targeted for in-memory web shell injection.
- file_path/mnt/tm_installBIG-IP upgrade/install-image workflow path targeted by first-stage loader.
- file_path/run/bigtlog.pipeLocal UNIX domain socket used as interactive backdoor.
- file_path/usr/sbin/httpdApache binary infected by first-stage loader for persistence.
- sha25626bd5b0722d1dbab5db749a063c49bc8638653ac2addfead7a9cb3d6d57bccc9SHA256 hash of the analyzed second-stage Linux implant binary.