Skip to content
Exploit for Improperly Controlled Sequential Memory Allocation in Php

Exploit for Improperly Controlled Sequential Memory Allocation in Php

Sploitus • November 2, 2026

Kumpulan **custom decoders, rules, auditd policies, dan SCA policies** untuk Wazuh guna mendeteksi

eksploitasi **PHP2Shell (CVE-2026-109618 / CVE-2026-109619)** pada server web berbasis PHP

(Apache/`mod_php`, Nginx + PHP-FPM, maupun PHP di dalam container Docker).

| Nama | Wazuh PHP2Shell Detection Rules |

| Jenis | Custom content Wazuh (decoders + rules + auditd + SCA) |

| Target | Wazuh Manager >= 4.9 dan Wazuh Agent Linux |

| Cakupan serangan | Reconnaissance, arming probe (log poisoning / session file), OOM/crash signal, ModSecurity, post-exploitation (reverse shell, download payload), FIM webshell |

| MITRE ATT&CK | T1190, T1595.002, T1592.004, T1499, T1505.003, T1059.004, T1005 |

| Referensi CVE | GHSA-w8hw-w9fx-j79w, GHSA-6wmf-4rv5-p3rp |

| Compliance | NIST SP 800-53, PCI DSS v4.0, TSC |

│ └── php2shell.rules # Audit execve oleh user web (www-data)

│ ├── 0170-nginx_decoders.xml # Decoder nginx error log + ModSecurity

│ ├── 0375-web-accesslog_decoders.xml # Decoder access log (dengan & tanpa params)

│ └── php-fpm_decoders.xml # Decoder log PHP-FPM warning

│ ├── 100-modsec_custom_rules.xml # Rule ModSecurity (id 100000-100008)

│ └── 111-php2shell_rules.xml # Rule utama PHP2Shell (id 111000-111141)

│ ├── sca_php2shell_php_runtime.yml # Hardening runtime PHP

│ ├── sca_php2shell_web_server.yml # Hardening web server & host

│ └── sca_php2shell_docker_runtime.yml # Variant untuk container Docker

└── log_samples/ # Contoh log untuk pengujian

| 111000-111004 | 3-10 | Recon: scanner UA, akses `phpinfo`, parameter `qXXXXXXX` (transport 9bie), HTTP 500, path sesi di parameter |

| 111105 | 10 | Log poisoning (path menunjuk `access.log`/`error.log`) |

| 111020-111029 | 7-12 | Error PHP: body melebihi `post_max_size`, multipart flood, session rusak, heap corruption, OOM |

| 111040-111041 | 7 | ModSecurity menolak body multipart/JSON |

| 111050-111051 | 12 | Segfault PHP worker, OOM killer |

| 111052-111053 | 12 | Post-exploit: download payload & reverse shell via auditd |

| 111054-111055 | 8-10 | FIM: file PHP baru/berubah di `/var/www` |

| 111100-111141 | 10-15 | Korelasi multiple event per source IP / host |

| 100000-100008 | 0-14 | Normalisasi event ModSecurity (Nginx) |

- Wazuh Manager dan Wazuh Agent sudah terpasang dan saling terhubung.

- Akses root (atau `sudo`) pada manager dan agent.

- Web server log tersedia: access log Apache/Nginx, error log, dan log PHP-FPM.

- (Opsional) ModSecurity + OWASP CRS aktif pada Nginx/Apache.

- (Opsional) Docker CLI bagi agent yang memantau container (SCA Docker).

sudo cp /var/ossec/etc/ossec.conf /root/wazuh-backup/

sudo cp decoders/*.xml /var/ossec/etc/decoders/

sudo chown wazuh:wazuh /var/ossec/etc/decoders/*.xml

sudo chmod 660 /var/ossec/etc/decoders/*.xml

sudo cp rules/*.xml /var/ossec/etc/rules/

sudo chown wazuh:wazuh /var/ossec/etc/rules/*.xml

sudo chmod 660 /var/ossec/etc/rules/*.xml

> Rule `100-modsec_custom_rules.xml` bergantung pada decoder `nginx-errorlog-modsec`, pastikan file

### 4. Nonaktifkan Decoder Bawaan yang Digantikan

Tambahkan blok berikut di `` pada `/var/ossec/etc/ossec.conf` agar decoder bawaan

`0170-nginx_decoders.xml` dan `0375-web-accesslog_decoders.xml` tidak bentrok:

### 5. Deploy Auditd Rules (Wazuh Agent / Server Web)

sudo cp auditd/php2shell.rules /etc/audit/rules.d/

Sesuaikan UID user web pada file tersebut bila berbeda (`euid=33` = `www-data` pada Debian/Ubuntu,

`euid=48` = `apache` pada RHEL family). Cek dengan `id -u www-data`.

### 6. Konfigurasi Log Collection pada Agent

Tambahkan `localfile` di `/var/ossec/etc/ossec.conf` agent:

Aktifkan juga FIM untuk web root (diperlukan rule 111054/111055):

sudo cp sca/*.yml /var/ossec/etc/shared/default/

sudo chown wazuh:wazuh /var/ossec/etc/shared/default/*.yml

sudo chmod 660 /var/ossec/etc/shared/default/*.yml

Pastikan agent berada pada group `default` dan blok `` aktif pada `agent.conf`/`ossec.conf`:

Untuk container, gunakan `sca_php2shell_docker_runtime.yml` dan pastikan agent dapat mengakses Docker socket.

Uji decoder & rule dengan sample log yang disediakan:

sudo /var/ossec/bin/wazuh-logtest -q `firewall-drop` membutuhkan `srcip`, sehingga hanya rule dengan source IP yang dapat memicu.

> Rule berbasis kernel/auditd (`php2shell_crash_signal`, `php2shell_post_exploit`) tidak dapat

> memicu `firewall-drop` karena tidak membawa IP sumber.

- Paket `iptables` tersedia (atau `nftables` jika konfigurasi Wazuh disesuaikan).

- Script active response bawaan `firewall-drop` ada di `/var/ossec/active-response/bin/firewall-drop`.

- Agent berjalan sebagai root agar dapat menulis rule iptables.

### Konfigurasi Agent (`/var/ossec/etc/ossec.conf`)

php2shell_recon|php2shell_http|modsecurity

| `command` | `firewall-drop` | Nama command active response |

| `location` | `local` | Blokir pada host agent yang menerima event |

| `rules_group` | `php2shell_recon\|php2shell_http\|modsecurity` | Group dipisah `\|` (OR) |

| `timeout` | `1800` | Durasi blokir dalam detik (30 menit) |

Jika ingin hanya rule tertentu yang memblokir, gunakan ``:

### Konfigurasi Terpusat dari Manager (`agent.conf`)

Agar berlaku untuk semua agent dalam group, letakkan pada `/var/ossec/etc/shared//agent.conf`:

php2shell_recon|php2shell_http|modsecurity

# pada agent: pastikan rule iptables terbentuk setelah simulasi rule

# pada manager: pastikan active response tercatat

sudo tail -f /var/ossec/logs/active-responses.log

Setelah `timeout` habis, `firewall-drop` menghapus blokir secara otomatis.

- **Whitelist IP internal** (load balancer, monitoring, reverse proxy) di

`/var/ossec/etc/lists/` atau dengan rule level `0` untuk menghindari self-block.

- Blokir pada `location local` hanya melindungi host tersebut. Untuk memblokir di satu titik masuk,

gunakan `location server` pada manager dengan skenario `firewall-drop` terpusat.

- `modsecurity` mencakup rule level rendah (100002 level 5, 100006 level 6); pastikan threshold

tidak memblokir pengguna sah akibat false positive (atur `rules_id` bila perlu).

| Rule tidak terpicu | Cek decoder dengan `wazuh-logtest`, pastikan `decoder_exclude` sudah di-set pada manager |

| Rule URL/params tidak match | Decoder access log baru mengisi `field params`; gunakan `` bukan `` |

| Rule auditd tidak terpicu | Pastikan `auditd` aktif, key `php2shell_exec` ter-load, dan log audit dikumpulkan agent |

| FIM tidak melapor | Pastikan `/var/www` ada di `` |

| SCA tidak muncul | Cek status di dashboard, pastikan policy berada di folder `shared` group agent |

| Active response tidak memblokir | Cek `iptables` tersedia, agent berjalan sebagai root, dan `rules_group` tertulis benar |

Dirilis di bawah [MIT License](LICENSE). Copyright (c) 2026 Ridwan Na'im.