← Back to Pull requests

fix(tokenizer): reject VP8X WebP dimensions overflowing 32 bits #4031

Merged
liu-cong merged 2 files (38 lines) on Nov 07, 2026 21:50 UTC
View on GitHub
liu-cong liu-cong commented on Nov 06, 2026 01:34 UTC
Author

What type of PR is this?
/kind bug

What this PR does / why we need it:

webpDimensions reads the 24-bit VP8X canvas width - 1 and height - 1 fields without checking RFC 9649 Section 2.2's requirement that Canvas Width Canvas Height fits in 32 bits (<= 2^32 - 1). A malformed 30-byte VP8X header with 0xffffff in both fields reports a 16777216 x 16777216 image (2^48 pixels), inflating the multimodal image placeholder estimate to 2^38 tokens instead of falling back to the default resolution.

Reject VP8X headers whose width height exceeds math.MaxUint32.

The review playbook (docs/review/) caught this bug on PR #3664.

Release note _(write NONE if no user-facing change)_:
``release-note
NONE
`

Test plan:

  • Unit tests covering valid 32-bit VP8X canvas product boundaries (65535 x 65536, 16777216 x 255) and rejected overflows (65536 x 65536, 16777216 x 256, 16777216 x 16777216), plus fallback to the default image resolution in imageEstimator.placeholderCount`.
  • Diff: 38 lines (+30 / -8) across 2 files Reviewer: blacksoxx Review duration: 2656m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 38 lines diff across 2 files
    0.50
    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: 50%
    56%
    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
    Shallow Review Depth shallow_review_depth
    0.289
    Diff Size diff_size
    0.219
    Sensitive Paths sensitive_paths
    0.050
    Real PR Conversation Timeline
    3 items
    blacksoxx blacksoxx approved these changes on Nov 07, 2026 17:45 UTC
    Approved Reviewer

    Approve. The check matches RFC 9649 section 2.2 (canvas width times height at most 2^32 - 1) and the arithmetic is safe: each side is at most 2^24, so the product fits int64 before the comparison.

    Reviewed head 2abc4760 against main at c5429a30 (merge base f44cf142, 19 commits behind, no conflicts). Open, non-draft, mergeable at submission.

    Validation: go test -race ./pkg/epp/framework/plugins/requesthandling/dataproducer/tokenizer/... on this head ok; golangci-lint on the package, 0 issues. Differential: the updated webp_dims_test.go applied on main alone fails the three new reject rows and the base64 fallback assertion (webp_dims_test.go:116-118), and passes here. Not run: make presubmit.

    History: found by the review playbook on #3664, as the description says; no earlier fix in the all-state search for VP8X (100 results per query cap).

    I'd merge this; the decision is with the maintainers.

    ahg-g ahg-g approved these changes on Nov 07, 2026 21:37 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    liu-cong liu-cong
    Labels
    risk: low confidence: 57.0% 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: 49.5% (MEDIUM) · Higher = larger blast radius
    49.5%
    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: 57.0% · Lower = rushed or shallow review
    57.0%
    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: 21.3% · Safe to merge
    21.3%