以下防御php2shell的规则来源于GitHib,请注意在测试环境中验证后再部署到生产环境中使用。
# --- Rule 9900100: Block PHP_SESSION_UPLOAD_PROGRESS in multipart POST ---
# Primary attack trigger for both CVEs. Near-zero legitimate use.
SecRule REQUEST_METHOD "POST" \
"id:9900100, \
phase:2, \
deny, \
status:403, \
log, \
msg:'php2shell: PHP_SESSION_UPLOAD_PROGRESS in request body', \
tag:'CVE-2026-109618', \
tag:'CVE-2026-109619', \
tag:'php2shell', \
severity:'CRITICAL', \
chain"
SecRule REQUEST_BODY "@contains PHP_SESSION_UPLOAD_PROGRESS" \
"chain"
SecRule REQUEST_HEADERS:Content-Type "@contains multipart/form-data"
# --- Rule 9900101: Detect PHPSESSID in multipart POST body ---
# Session fixation via POST body. Alert only — some legacy apps may do this.
SecRule REQUEST_METHOD "POST" \
"id:9900101, \
phase:2, \
log, \
noauditlog, \
pass, \
msg:'php2shell: PHPSESSID in POST body (session fixation indicator)', \
tag:'CVE-2026-109618', \
tag:'php2shell', \
severity:'WARNING', \
chain"
SecRule REQUEST_BODY "@rx name=[\"']?PHPSESSID[\"']?" \
"chain"
SecRule REQUEST_HEADERS:Content-Type "@contains multipart/form-data"
# --- Rule 9900102: Block PHP code in upload filenames ---
# Session injection: PHP code stored in session file via filename field.
SecRule MULTIPART_FILENAME "@rx <\?(?:php|=)" \
"id:9900102, \
phase:2, \
deny, \
status:403, \
log, \
msg:'php2shell: PHP code in upload filename', \
tag:'CVE-2026-109618', \
tag:'php2shell', \
severity:'CRITICAL'"
# --- Rule 9900103: Block serialized PHP objects in upload filenames ---
# Handler mismatch attack: pipe + serialized object in filename.
SecRule MULTIPART_FILENAME "@rx \|[OaCr]:\d+:" \
"id:9900103, \
phase:2, \
deny, \
status:403, \
log, \
msg:'php2shell: serialized PHP object in upload filename', \
tag:'CVE-2026-109619', \
tag:'php2shell', \
severity:'CRITICAL'"
# --- Rule 9900104: Detect PHP OOM in response (exploitation indicator) ---
# Response-side: detects successful OOM trigger.
SecRule RESPONSE_BODY "@rx Allowed memory size.{1,50}exhausted" \
"id:9900104, \
phase:4, \
log, \
pass, \
msg:'php2shell: PHP OOM detected in response (possible exploitation)', \
tag:'CVE-2026-109618', \
tag:'php2shell', \
severity:'HIGH'"
# --- Rule 9900105: Detect session destruction failure in response ---
# Direct evidence of CVE-2026-109619 stale state exploitation.
SecRule RESPONSE_BODY "@contains Session object destruction failed" \
"id:9900105, \
phase:4, \
log, \
pass, \
msg:'php2shell: session destruction failure (stale state exploitation)', \
tag:'CVE-2026-109619', \
tag:'php2shell', \
severity:'CRITICAL'"
# --- Rule 9900106: Block chunked multipart POST (OOM bypass) ---
# Missing Content-Length on multipart bypasses PHP's post_max_size check,
# enabling unlimited memory consumption during parsing.
SecRule REQUEST_METHOD "POST" \
"id:9900106, \
phase:1, \
deny, \
status:400, \
log, \
msg:'php2shell: chunked multipart POST (post_max_size bypass)', \
tag:'CVE-2026-109618', \
tag:'php2shell', \
severity:'HIGH', \
chain"
SecRule REQUEST_HEADERS:Content-Type "@contains multipart/form-data" \
"chain"
SecRule REQUEST_HEADERS:Transfer-Encoding "@contains chunked"版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。



