Add virtual patches for PHP2Shell, Log4Shell, Shellshock and other CVEs #13

Merged
james merged 1 commit from virtual-patches into main 2026-10-22 20:20:56 +00:00
Owner

Adds Coraza virtual-patch rules for named, widely exploited CVEs, with PHP2Shell first.

What changes

  • internal/waf/rules/virtual-patches.conf (new, embedded in the binary): one rule per CVE. Each adds a critical finding (+5) at any paranoia level and names its CVE in msg, so the model and the decision log see which exploit a request resembles.
  • waf.go: loads the file before CRS's REQUEST-949, so the score is in the total. It also keeps rule ids 1000000–1099999 in MatchedRules. Before this, Evaluate dropped every id outside the CRS range.
  • Pre-filter (suspicion.go): adds matching markers, so CENTINELA_WAF=header deployments also escalate these requests.
  • README: a "Virtual patches" section with the rule table and how to add a rule.

Rules

Rule CVE CRS coverage before
1009618 PHP2Shell (CVE-2026-109618/109619): PHP_SESSION_UPLOAD_PROGRESS field none (scored 0–3)
1044228 Log4Shell (CVE-2021-44228/45046), including obfuscated lookups 944150 (skips the raw Cookie header)
1006271 Shellshock (CVE-2014-6271) 932170/932171
1022965 Spring4Shell (CVE-2022-22965) 944260, PL2, exact published path only
1005638 Struts S2-045 (CVE-2017-5638) no dedicated rule
1026134 OGNL injection (Confluence CVE-2022-26134, Struts 2) partial
1042889 Text4Shell (CVE-2022-42889) partial
1001823 / 1004577 PHP-CGI argument injection (CVE-2012-1823 / CVE-2024-4577) none

The PHP2Shell rule follows the ColibriSec advisory. This PR leaves out the advisory's second rule (1009619, MULTIPART_STRICT_ERROR), because the WAF already scores that case as 200003.

Heartbleed has no rule. It is a TLS heartbeat bug and never reaches HTTP inspection, so the fix is to patch OpenSSL where TLS terminates.

Notes for review

  • These rules only add to the score. They block nothing by themselves: the model decides, or CENTINELA_WAF_HARD_BLOCK if it is set. When CRS also matches, both scores count.
  • 1009618 matches only the default session.upload_progress.name.

Testing

  • TestVirtualPatchesMatchExploits: each rule fires and scores on its exploit shape. With the rules file unloaded, this test fails.
  • TestVirtualPatchesIgnoreBenign: no patch fires on look-alikes. These are a file upload, ${name} text, ?-1 and ?-sort=, a CSS class= param, a JSON body and a mid-word soft hyphen.
  • go test ./... passes.
Adds Coraza virtual-patch rules for named, widely exploited CVEs, with PHP2Shell first. ## What changes - **`internal/waf/rules/virtual-patches.conf`** (new, embedded in the binary): one rule per CVE. Each adds a critical finding (+5) at any paranoia level and names its CVE in `msg`, so the model and the decision log see which exploit a request resembles. - **`waf.go`**: loads the file before CRS's `REQUEST-949`, so the score is in the total. It also keeps rule ids 1000000–1099999 in `MatchedRules`. Before this, `Evaluate` dropped every id outside the CRS range. - **Pre-filter** (`suspicion.go`): adds matching markers, so `CENTINELA_WAF=header` deployments also escalate these requests. - **README**: a "Virtual patches" section with the rule table and how to add a rule. ## Rules | Rule | CVE | CRS coverage before | |---|---|---| | 1009618 | PHP2Shell (CVE-2026-109618/109619): `PHP_SESSION_UPLOAD_PROGRESS` field | none (scored 0–3) | | 1044228 | Log4Shell (CVE-2021-44228/45046), including obfuscated lookups | 944150 (skips the raw Cookie header) | | 1006271 | Shellshock (CVE-2014-6271) | 932170/932171 | | 1022965 | Spring4Shell (CVE-2022-22965) | 944260, PL2, exact published path only | | 1005638 | Struts S2-045 (CVE-2017-5638) | no dedicated rule | | 1026134 | OGNL injection (Confluence CVE-2022-26134, Struts 2) | partial | | 1042889 | Text4Shell (CVE-2022-42889) | partial | | 1001823 / 1004577 | PHP-CGI argument injection (CVE-2012-1823 / CVE-2024-4577) | none | The PHP2Shell rule follows the [ColibriSec advisory](https://colibrisec.org/php2shell-cve-2026-109618-cve-2026-109619-technical-analysis-mitigation-patching/). This PR leaves out the advisory's second rule (1009619, `MULTIPART_STRICT_ERROR`), because the WAF already scores that case as 200003. Heartbleed has no rule. It is a TLS heartbeat bug and never reaches HTTP inspection, so the fix is to patch OpenSSL where TLS terminates. ## Notes for review - These rules only add to the score. They block nothing by themselves: the model decides, or `CENTINELA_WAF_HARD_BLOCK` if it is set. When CRS also matches, both scores count. - 1009618 matches only the default `session.upload_progress.name`. ## Testing - `TestVirtualPatchesMatchExploits`: each rule fires and scores on its exploit shape. With the rules file unloaded, this test fails. - `TestVirtualPatchesIgnoreBenign`: no patch fires on look-alikes. These are a file upload, `${name}` text, `?-1` and `?-sort=`, a CSS `class=` param, a JSON body and a mid-word soft hyphen. - `go test ./...` passes.
Add virtual patches for PHP2Shell, Log4Shell, Shellshock and other CVEs
All checks were successful
security-scan / security-scan (pull_request) Successful in 1m22s
test / go (pull_request) Successful in 3m59s
0baa442132
The embedded WAF now loads internal/waf/rules/virtual-patches.conf, Coraza
rules for named, widely exploited CVEs. Each adds a critical finding at any
paranoia level and names its CVE, so the model and the decision log see which
exploit a request resembles.

- PHP2Shell (CVE-2026-109618/109619): the PHP_SESSION_UPLOAD_PROGRESS field,
  which CRS does not score. The multipart strict-error rule from the advisory
  is already covered by 200003.
- Log4Shell, Shellshock, Spring4Shell, Struts S2-045, Confluence/Struts OGNL,
  Text4Shell, and PHP-CGI argument injection (CVE-2012-1823, CVE-2024-4577).

Evaluate kept only CRS rule ids, so it now also keeps 1000000-1099999. The
pre-filter gains matching markers for deployments without the embedded WAF.

🔎 ojo scan results

No findings.

<!-- ojo-scan-summary --> ### 🔎 ojo scan results No findings.
james merged commit b586989812 into main 2026-10-22 20:20:56 +00:00
james deleted branch virtual-patches 2026-10-22 20:20:56 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ColibriSec/centinela!13
No description provided.