← Back to Pull requests

fix: P0 multipart parser bypass and fail-closed baseline configuration #163

Closed
unknown closed this pull request without merging on Nov 16, 2026 22:35 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 21:06 UTC
Author

P0: Multipart parser bypass + fail-closed baseline

Two critical safety gaps found during a differential parity analysis of corazawaf/coraza (Go) vs coraza-rs (Rust). These combine into a confirmed WAF bypass: a valid multipart request silently stops Rust inspection while Go blocks it.

CRIT-1 — Multipart parser bypass (commit 654f89a)

A multipart part with an empty header block (valid per RFC 2046, accepted by Go's mime/multipart) causes the Rust parser to error out with "malformed MIME header: no blank line after headers" and stop inspecting all subsequent parts. A SQLi field placed after such a part is blocked by Go Coraza (rule 949110) and allowed by coraza-rs.

Root cause: find_header_end only recognized \r\n\r\n / \r\n\n / \n\r\n / \n\n as header terminators. Data starting with \r\n or \n (empty header block) never matched.

Fix: find_header_end now treats data starting with \r\n or \n as an empty header block. Two prefix checks before the existing scan — no loop or allocation overhead. All three callers go through this path, so they agree on where part data starts.

CRIT-2 — No fail-closed baseline configuration (commit 23a3fad)

Neither envoy-coraza build (default nor CRS) ships the equivalent of Go's coraza.conf-recommended. This means:

  • Rules 200002/200003/200009 (REQBODY_ERROR, MULTIPART_STRICT_ERROR, URI_PARSE_ERROR) are absent — body parse errors are silently ignored

  • Rules 200000/200001/200006 (body processor selection for XML/JSON) are absent — CRS ships its own JSON selector only for AWS and +json content types

  • Several ported advisory fixes (GHSA-r3rm-qphw-hh76, GHSA-3wr7-993q-jrff, GHSA-x26q-wvhg-fh4m) set error flags that nothing acts on
  • Fix: Ships a coraza.conf-recommended equivalent embedded in both envoy-coraza builds. Rules 200000–200006 and 200009 are included. Policy documentation updated with recommended SecLang configuration.

    Connector fix (commit 2bb49df)

    envoy-libperfusion connector test pinning empty-header multipart behavior, ensuring the parser fix is exercised through the connector path.

    Verification

  • CRIT-2 confirmed valid: inspected both build variants, all connectors, Dockerfiles, embedded rules, example configs, README policy, and Istio demo — no baseline rules shipped anywhere

  • 21 new tests + 1 extended + 1 widened

  • Full test suite: 2,232 tests passed, 0 failures

  • No performance regression: parser fix is two prefix checks with no loop or allocation

  • Connector tests pass
  • Changes

    21 files changed, +1,512 / -46 lines

    ---
    AI-generated. Review for accuracy.

    @rikatz requested from Slack

    Chai persona: AI Gateway Engineer

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added a built-in recommended security configuration to every build, with request and response inspection, parsing limits, and fail-closed handling for selected errors. It can be loaded explicitly before rule sets.
    Updated examples to show the recommended configuration used with the rule engine and, where enabled, OWASP CRS.
    Bug Fixes
    Improved handling of multipart form parts with empty headers, preserving later fields for inspection. Malformed or unterminated multipart requests are handled according to the configured blocking policy.
    Documentation
    * Expanded guidance on configuration behavior, overrides, resource requirements, and security checks.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 451 lines (+338 / -113) across 5 files Reviewer: redhat-chai-bot Review duration: 88m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.69) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.69 · 451 lines diff across 5 files
    0.69
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.069
    Real PR Conversation Timeline
    1 comments
    "Review active on #163"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68.6% (HIGH) · Higher = larger blast radius
    68.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.1% · Safe to merge
    27.1%