Doc_chelvyn/Mito/Sfa/Bug/2026-10-22_patch-php-cve-ph...

223 lines
9.1 KiB
Markdown
Raw Permalink Normal View History

---
judul: Insiden Security — Patch PHP 8.3 untuk PHP2Shell (CVE-2026-109618 & CVE-2026-109619)
proyek: SFA CMS
terkait: Mito
server: VPS MITO (16.79.56.41, ip-172-31-21-236) — semua aplikasi PHP di server ini
kategori: Bug
status: Solved — PHP 8.3.26 → 8.3.36
tipe: dokumen-internal
tags:
- sfa
- cms
- security
- php
- cve
- server
diperbarui: 2026-10-22
---
> Index: [[SFA — Index]] · Kategori: **Bug** · Server: [[SFA CMS — Deployment VPS MITO]]
# Insiden Security: PHP2Shell — RCE di PHP sebelum kode aplikasi jalan
**Tanggal:** 22 Oktober 2026
**Server/Environment:** VPS MITO (`16.79.56.41`, Ubuntu 24.04.3) — PHP dari PPA `ondrej/php`, nginx + PHP-FPM
**Sumber:** [mallory.ai — PHP RCE Rapid Response](https://mallory.ai/blog/php-rce-rapid-response)
**Status:** ✅ Solved — semua paket `php8.3-*` naik ke **8.3.36**
---
## Ringkasan
Pada 21-10-2026 PHP merilis patch untuk dua celah yang disebut **PHP2Shell**:
| CVE | Jenis |
|---|---|
| CVE-2026-109618 | Memory corruption saat memory exhausted |
| CVE-2026-109619 | State basi yang terbawa antar-request |
Penyerang **tanpa login** bisa menjalankan kode di server lewat request HTTP, **sebelum kode
aplikasi jalan**. Jadi framework (Laravel/Filament) tidak bisa melindungi. Yang kena: PHP-FPM, mod_php,
CGI, FrankenPHP, LiteSpeed. PHP CLI (artisan, cron, queue worker) tidak kena selama tidak
melayani HTTP.
Versi yang sudah di-patch:
| Branch | Rentan sebelum | Patch |
|---|---|---|
| 8.5 | 8.5.12 | **8.5.12** |
| 8.4 | 8.4.27 | **8.4.27** |
| 8.3 | 8.3.36 | **8.3.36** ← server ini |
| 8.2 | 8.2.35 | **8.2.35** |
| ≤ 8.1 | semua | hanya ada patch source, tidak ada rilis resmi |
Server MITO menjalankan **PHP 8.3.26 (build 1 Okt 2025) lewat PHP-FPM**, jadi rentan.
> [!danger] Satu binary PHP dipakai semua aplikasi PHP di server ini
> Upgrade ini ikut mengubah **instalasi lama production** `cms.mito.co.id` & `cms.stein.co.id`
> ([[SFA CMS — Deployment VPS MITO#5. Instalasi Lama yang Masih Hidup — JANGAN DIGANGGU|§5]]).
> Kode & config-nya tidak disentuh, tapi PHP-FPM & queue worker-nya ikut di-restart. Keduanya sudah
> dicek normal setelah upgrade (lihat [Verifikasi](#verifikasi)).
---
## Alur Penanganan
Alur ini bisa dipakai ulang di server lain yang menjalankan PHP.
```mermaid
flowchart TD
A["Cek versi: php -v &amp; php-fpm8.3 -v"] --> B{"Versi ≥ patch?<br/>8.3.36 / 8.4.27 / 8.5.12 / 8.2.35"}
B -- "ya" --> OK0["Aman, tidak perlu tindakan"]
B -- "tidak (8.3.26)" --> C{"Melayani HTTP?<br/>FPM / mod_php / CGI"}
C -- "tidak, CLI saja" --> OK1["Tidak rentan<br/>tetap upgrade saat maintenance"]
C -- "ya, PHP-FPM" --> D["Backup /etc/php<br/>php-etc-backup-YYYY-MM-DD-HHMM.tgz"]
D --> E{"Ada tanda sudah dieksploitasi?<br/>child process aneh, file .php baru di public/,<br/>FPM crash / SIGSEGV, lonjakan 502"}
E -- "ya" --> X["STOP: perlakukan sebagai insiden<br/>isolasi server, simpan bukti, rotasi secret"]
E -- "tidak" --> F{"Patch tersedia di apt?<br/>apt-cache policy php8.3-fpm"}
F -- "belum" --> M["Mitigasi sementara:<br/>session.upload_progress.enabled=0<br/>batasi akses (VPN / allowlist IP)"]
F -- "ya, 8.3.36" --> G["apt-get install --only-upgrade<br/>--force-confold php-common php8.3-*"]
G --> H["Tambah 99-php2shell-mitigation.ini<br/>php-fpm8.3 -t → restart php8.3-fpm"]
H --> I["supervisorctl restart all<br/>(queue worker)"]
I --> J{"Verifikasi: versi 8.3.36,<br/>tidak ada binary lama di /proc,<br/>situs 200, laravel.log bersih?"}
J -- "ya" --> OK2["✅ Selesai"]
J -- "tidak" --> R["Rollback config dari backup<br/>cek log FPM / nginx"]
S["Server MITO / SFA lain<br/>(production, staging)"]
classDef ok fill:#d1fae5,stroke:#059669,color:#064e3b
classDef err fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#374151,stroke-dasharray:4 3
class OK0,OK1,OK2 ok
class X,R err
class S todo
```
Hijau = selesai / aman · Merah = gagal atau berhenti · Abu-abu putus-putus = belum dikerjakan
---
## Langkah yang Dijalankan
### 1. Cek kondisi awal
```bash
php -v # PHP 8.3.26 (cli) (built: Oct 1 2025)
systemctl list-units | grep -E "php|nginx" # nginx + php8.3-fpm aktif
apt-cache policy php8.3-fpm # Candidate: 8.3.36-1+ubuntu24.04.1+deb.sury.org+1 (PPA ondrej)
```
Pool PHP-FPM yang aktif:
| Pool | Socket | User | Dipakai oleh |
|---|---|---|---|
| `sfa_mito` | `/run/php/php8.3-fpm-sfa_mito.sock` | `ubuntu` | SFA CMS baru `/var/www/sfa_mito` (`default_server`, akses lewat IP) |
| `www` | `/run/php/php8.3-fpm.sock` | `www-data` | Instalasi lama `cms.mito.co.id` & `cms.stein.co.id` |
### 2. Backup config
```bash
sudo tar czf /home/ubuntu/php-etc-backup-$(date +%F-%H%M).tgz /etc/php
# → /home/ubuntu/php-etc-backup-2026-10-22-0743.tgz
```
### 3. Cek tanda sudah dieksploitasi (sebelum patch)
| Cek | Hasil |
|---|---|
| Proses non-FPM yang di-spawn oleh worker php-fpm | Tidak ada |
| Proses milik `www-data` selain FPM/nginx | Hanya 2 queue worker `artisan queue:work` (dari supervisord), normal |
| FPM crash / `SIGSEGV` di journal & `php8.3-fpm.log` (14 hari) | Tidak ada |
| Response 502 di `access.log` nginx | 0 |
| File `.php` di folder `public/` yang berubah 7 hari terakhir | Tidak ada |
| File `.php` yang berubah 3 hari terakhir (di luar `vendor/`, `storage/`) | Semua kode aplikasi `sfa_mito` dari deploy (migration Customer Registration, controller, command), sesuai riwayat deploy |
Kesimpulan: **tidak ada tanda server sudah dibobol.**
> [!note] Scan otomatis di nginx `error.log`
> Ada request dari `178.249.209.166` ke `/.git/config`, `/.npmrc`, `/.git-credentials`, dll. Semuanya
> ditolak `access forbidden by rule`. Ini scanner biasa, bukan exploit PHP2Shell.
### 4. Upgrade
```bash
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --only-upgrade \
-o Dpkg::Options::="--force-confold" \
php-common $(dpkg -l | awk '/^ii\s+php8\.3/{print $2}')
```
- `--only-upgrade`: hanya paket PHP yang sudah terpasang, tidak menambah paket baru.
- `--force-confold`: `php.ini` & pool config yang sudah ada **tidak ditimpa** default paket.
- Paket: `php8.3`, `-bcmath`, `-cli`, `-common`, `-curl`, `-fpm`, `-gd`, `-intl`, `-mbstring`,
`-mysql`, `-opcache`, `-readline`, `-xml`, `-zip` → `8.3.36-1+ubuntu24.04.1+deb.sury.org+1`;
`php-common` → `2:101~`.
### 5. Mitigasi tambahan
File baru `/etc/php/8.3/fpm/conf.d/99-php2shell-mitigation.ini`:
```ini
; CVE-2026-109618/109619 defense-in-depth (PHP2Shell)
session.upload_progress.enabled = 0
```
Aman untuk Laravel karena fitur upload progress milik session PHP tidak dipakai.
| Saran artikel | Dipakai? | Alasan |
|---|---|---|
| `session.upload_progress.enabled=0` | ✅ | Tidak ada efek samping |
| `memory_limit=-1` lewat `php_admin_value` | ❌ | Patch sudah menutup celahnya. `-1` justru membuat satu request bisa menghabiskan RAM server, padahal server ini dipakai bareng 4 instance Odoo Docker |
| `post_max_size` kecil | — | Sudah `8M` |
| `fatal_error_backtraces=0` | — | Hanya untuk PHP 8.5 |
### 6. Restart
```bash
sudo php-fpm8.3 -t # configuration file ... test is successful
sudo systemctl restart php8.3-fpm
sudo supervisorctl restart all # sfa-worker-mito, sfa-worker-stein (queue:work instalasi lama)
```
---
## Verifikasi
| Cek | Hasil |
|---|---|
| `php -v` | `PHP 8.3.36 (cli) (built: Oct 21 2026 14:32:55)` |
| `php-fpm8.3 -v` | `PHP 8.3.36 (fpm-fcgi) (built: Oct 21 2026 14:32:55)` |
| Master FPM pakai binary baru | Start 07:45:02; satu-satunya mapping `(deleted)` adalah `/dev/zero` (shared memory OPcache, normal) |
| `session.upload_progress.enabled` | `Off` |
| `php8.3-fpm`, `nginx` | `active`; pool `sfa_mito` & `www` jalan |
| Supervisor | `sfa-worker-mito` & `sfa-worker-stein` `RUNNING` |
| `https://cms.mito.co.id/` | 302 → `/login` **200** |
| `https://cms.stein.co.id/` | 302 → `/login` **200** |
| `laravel.log` setelah upgrade (`sfa-cms`, `sfa-cms-stein`, `sfa_mito`) | 0 ERROR |
| Log PHP-FPM | `ready to handle connections`, tanpa error |
> [!note] `mitodev.sinerka.id` bukan PHP
> Domain ini di-proxy ke **Odoo** (`/web/database/selector`), jadi tidak terpengaruh upgrade PHP.
> Halaman database selector Odoo ini masih terbuka publik. To-do-nya sudah tercatat di [[SFA — Index]]
> (`list_db = False`).
---
## Rollback (kalau dibutuhkan)
```bash
# Kembalikan config
sudo tar xzf /home/ubuntu/php-etc-backup-2026-10-22-0743.tgz -C /
sudo rm /etc/php/8.3/fpm/conf.d/99-php2shell-mitigation.ini
sudo systemctl restart php8.3-fpm
```
Downgrade binary ke 8.3.26 **tidak disarankan** karena versi itu rentan RCE. Kalau aplikasi bermasalah
setelah upgrade, perbaiki di sisi aplikasi.
---
## Tindak Lanjut
- [ ] Cek & patch **server lain** yang menjalankan PHP (production / staging SFA, server client lain). Pakai alur di atas
- [ ] Pantau seminggu: `journalctl -u php8.3-fpm | grep -i signal`, lonjakan 502, file `.php` baru di `public/`
- [ ] Pasang `unattended-upgrades` untuk PPA `ondrej/php` (atau minimal cek bulanan). PHP di server ini tertinggal **10 patch release / ±1 tahun**
- [ ] Artikel menyebut `composer audit`, Trivy, dan Dependabot **tidak** mendeteksi CVE ini. Cek versi harus manual pakai `php -v`