fix(image): reject unrecognized deployment IDs - #2764
Conversation
The optimizer accepted any top-level dpl parameter while dropping it from source and transform semantics, allowing cache-key variants to repeat identical image work. Require dpl to match the configured deployment ID in canonical raw form and reject empty query segments before asset fetches. Preserve generated configured deployment URLs while blocking decoded aliases.
|
@codex review |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78f2fad175
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Performance benchmarksCompared 1 improved · 0 regressed · 5 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Overview
dplonly when it matches the configured deployment ID in the canonical emitted form.dplaliases return 400 without consuming image backend work.Why
The image loader emits deployment IDs as a top-level
dplparameter. The optimizer previously allowlisted that parameter but discarded it when constructing the source and transform tuple. An unauthenticated caller could therefore varydplacross distinct request URLs while repeating the same fetch and image transform.The parameter parser owns this decision because every dev, Node, App Router, Pages Router, and configured optimizer path crosses it before image I/O.
What changed
dpldplMaintainer review path
packages/vinext/src/server/image-optimization.tsfor the decoded identity and raw canonical-form checks.tests/shims.test.tsfor malicious parser inputs and the proof that asset I/O is not reached.tests/image-optimization-parity.test.tsfor preserved valid deployment-ID behavior.Validation
The regression tests were first run against the vulnerable implementation and failed while showing both attacker variants reached
fetchAsset. They pass after the fix with zero asset calls.vp test run tests/shims.test.ts: 1,271 passed.vp test run tests/image-component.test.ts: 65 passed.vp test run tests/image-optimization-parity.test.ts: 7 passed across App and Pages Router fixtures.vp test run tests/static-image-emission.test.ts -t "preserves managed image URLs under basePath and assetPrefix": passed.vp check packages/vinext/src/server/image-optimization.ts tests/shims.test.ts tests/image-optimization-parity.test.ts: format, lint, and types passed.vp run vinext#build: passed.Risk / compatibility
dplare unchanged.