fix(contracts): require the release manifest path to resolve to itself (R-7.3)
isValidReleaseManifestUrl only rejected `//`, `?`, `#`, `\`, `%2f`/`%5c` and literal dot segments. The WHATWG URL parser strips tab/CR/LF and resolves `%2e` dot segments, so "/\t/evil.example/m.json" resolved to https://evil.example/m.json and "/a/%2e%2e/b.json" to "/b.json". The value is now also resolved against a fixed base and must keep that origin and have a pathname identical to the input. RED: "runtime configuration boundary > rejects invalid config" cases for a tab, a newline, "/a/%2e%2e/b.json" and "/a/%2E/b.json" failed (validation succeeded) before the fix. Added accept cases for normal same-origin paths. Gates: check:architecture, check:types:app/test/node, lint, test:component, test:runtime-schema, test:contract pass; test:unit passes except the environment-dependent removal-fixture.test.ts (needs generated artifacts/release files; unrelated). tests/release, tests/platform/release and tests/integration also pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
691cf37486
commit
b31daab324
@@ -32,9 +32,19 @@ export function isValidReleaseManifestUrl(value: string): boolean {
|
||||
return false;
|
||||
}
|
||||
if (/%2f|%5c/i.test(value)) return false;
|
||||
return !value
|
||||
.split("/")
|
||||
.some((segment) => segment === "." || segment === "..");
|
||||
if (value.split("/").some((segment) => segment === "." || segment === "..")) {
|
||||
return false;
|
||||
}
|
||||
// R-7.3. The URL parser strips tab/CR/LF and resolves `%2e` dot segments, so
|
||||
// "/\t/evil.example/m.json" becomes a cross-origin URL. The path must
|
||||
// resolve to exactly itself on the page's origin.
|
||||
const base = "https://release-manifest.invalid";
|
||||
try {
|
||||
const resolved = new URL(value, base);
|
||||
return resolved.origin === base && resolved.pathname === value;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const capabilityOverrideArtifactSchema = z
|
||||
|
||||
Reference in New Issue
Block a user