fix(security): gate subdirectories of the shallow static/img walk - #849
Merged
Merged
Conversation
static/img is walked with recurse: false, and walk() silently dropped every subdirectory it met in that mode. assetRootPaths only knows the three subdirectories that exist today, and checkForUngatedStaticEntries() only inspects the static/ root, so a new subdirectory under static/img was neither an asset root nor recursed into nor reported: it shipped to the site origin with no gate at all. A shallow walk covers only the files sitting directly in the directory, so every subdirectory below it must be an asset root with its own assetDirs entry. One that is not is now an error, the same rule checkForUngatedStaticEntries() already applies at the static/ root. Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "sec-check" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Fix
scripts/validate-architecture-assets.mjsgatesstatic/because everything in it ispublished verbatim at the site origin.
static/imgis walked withrecurse: false, andwalk()silently dropped every subdirectory it met in that mode:assetRootPathsonly knows the three subdirectories that exist today (architectures,cncf-projects,awards), andcheckForUngatedStaticEntries()only inspects thestatic/root —imgis ingatedTopLevelDirs, so it passes. A new subdirectory understatic/imgwas therefore neither an asset root, nor recursed into, nor reported: itshipped to the site origin with no gate at all.
This applies the rule
checkForUngatedStaticEntries()already enforces at thestatic/root one level down. A shallow walk covers only the files sitting directly in the
directory, so every subdirectory below it must be an asset root with its own
assetDirsentry; one that is not is now an error naming the file to edit.
static/imgis the only shallowly walked entry, and its three real subdirectories arereturned via
assetRootPathsbefore the new branch, so no current asset is affected —the validator still reports
Validated 82 architecture asset(s).and exits 0 against thechecked-in tree.
Files and functions claimed
scripts/validate-architecture-assets.mjs—walk()(plus theassetDirsheadercomment describing the shallow
static/imgwalk)tests/validate-architecture-assets.test.mjs— the shallow-static/img-walk clusterNo overlap with open PR #847, which is test-only on
tests/mdx-escape.test.mjs.Verification
Reproduced on
6465e97before the fix — the validator, the full unit suite and aproduction build were all green with
static/img/blog/pwn.htmlpresent, and the filelanded in
build/img/blog/pwn.html, served astext/htmlfrom the site origin.After the fix:
node scripts/validate-architecture-assets.mjs→ exit 0 against the real tree(82 assets, one pre-existing
foreignObjectwarning)npm run test:unit→ 1501 tests, 1499 pass, 0 failnpm run test:unit:coverage:check→ exit 0npx prettier --checkon both changed files → cleantwo new security tests, and no others
The existing test
does not descend into subdirectories of the shallow static/img walkpinned the gap as intended behaviour and is replaced by tests asserting the error.
Closes #848
Filed by sec-check agent (ACMM L4/L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=sec-check backend=copilot model=claude-opus-5 copilot=1.0.88