fix(http): reject "." and ".." path values in V3 and V2 (R-3.1)
A path value of "." or ".." survives encodeURIComponent unchanged, and URL
resolution (V3 `new URL`, V2 `pathname =` assignment) then collapses it into
a parent path that still sits under the base URL, so `URL_ORIGIN_ESCAPED`
never fired. `/members/{m}` with m=".." pointed at the project instead.
The V3 bridge now returns PATH_VALUE_INVALID and the V2 request builder
returns PATH_PARAMETER_INVALID for exactly those two values.
RED before fix: tests/unit/http-contract-bridge.test.ts "rejects the dot
segment ..." and tests/unit/request-builder.test.ts "rejects the dot segment
..." returned ok/success with a parent URL.
Gates: check:architecture, check:types:app, check:types:test, lint,
test:component pass. test:unit passes except removal-fixture.test.ts, which
needs generated artifacts/ release evidence absent in a fresh worktree
(unrelated to this change).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
810849e496
commit
ebbd50d4fb
@@ -189,7 +189,14 @@ function projectRequestChecked<Input, WireOutput, Problem>(
|
||||
missing = true;
|
||||
return "";
|
||||
}
|
||||
if (value.includes("/") || value.includes("\\")) {
|
||||
// A dot segment survives encodeURIComponent and URL resolution would
|
||||
// move the request to a parent path that still passes the base check.
|
||||
if (
|
||||
value.includes("/") ||
|
||||
value.includes("\\") ||
|
||||
value === "." ||
|
||||
value === ".."
|
||||
) {
|
||||
invalid = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ export function buildRequestTarget(
|
||||
if (
|
||||
serialized.length === 0 ||
|
||||
serialized.length > 512 ||
|
||||
// Dot segments are not encoded and pathname assignment normalizes them.
|
||||
serialized === "." ||
|
||||
serialized === ".." ||
|
||||
[...serialized].some((character) => {
|
||||
const code = character.codePointAt(0) ?? 0;
|
||||
return code < 32 || code === 127;
|
||||
|
||||
Reference in New Issue
Block a user