Blue Bank 暴露 www.bluebank.example.com/axis/getBalance.jws,需防範 SOAP 請求中的惡意輸入。
<Location /axis/getBalance.jws>
SecFilterInheritance Off
SecFilterDefaultAction "deny,log,status:500"
SecFilterScanPOST On
SecFilterCheckURLEncoding On
SecFilterCheckUnicodeEncoding On
# 具體規則...
</Location>
SecFilterInheritance Off:關閉繼承規則,建立乾淨規則空間。SecFilterScanPOST On:啟用 POST Body 檢查(Web Services 走 POST)。SecFilterSelective POST_PAYLOAD "<\s*id[^>]*>" chain
SecFilterSelective POST_PAYLOAD "<\s*id[^>]*>.{6,}" "deny,status:500"
限制 <id> 內容長度 ≤ 5 字符。測試:12123 通過,121234 返回 500,請求未達到 Web Service 層。
SecFilterSelective POST_PAYLOAD "<\s*id[^>]*>[%'\\\"]" "deny,status:500"
攔截包含 %、單引號、雙引號、反斜槓的 id 值。
SecFilterSelective POST_PAYLOAD "<!ENTITY" "deny,status:500"
SecFilterSelective POST_PAYLOAD "<!DOCTYPE" "deny,status:500"
防範 XML 實體注入攻擊(Billion Laughs、XXE)。
SecFilterSelective SOAPAction "!^\"https://bluebank.example.com/axis/getBalance\"$" "deny,status:500"
僅允許預期的 SOAPAction,阻斷未知調用。
mod_security 作為「護盾」部署在 Apache 前端,攔截惡意請求於 Web Service 容器之前,零代碼入侵業務邏輯,集中管理安全策略。