Fix CNCFProjectCard href allowlist bypass in renderProjectCards() - #250
Open
mrbobbytables wants to merge 1 commit into
Open
mrbobbytables wants to merge 1 commit into
mrbobbytables wants to merge 1 commit into
Conversation
renderProjectCards() in scripts/import-architectures.mjs picked the URL
for every published <CNCFProjectCard> with a bare substring test
(link.includes('cncf.io/projects/')). Since String.prototype.includes
matches anywhere in a URL, an upstream architecture Markdown file could
embed a link such as
https://evil.example/r?u=cncf.io/projects/kubernetes/ and have it
selected as the card href, pointing a CNCF-branded card at an
attacker-controlled origin.
Add scripts/lib/project-card-links.mjs exporting isCncfProjectHref(),
which uses real URL parsing to require https, no userinfo, a host of
cncf.io or a cncf.io subdomain, and a /projects path. Wire it into
renderProjectCards() in place of the substring check, and add unit
tests covering the reported bypass, a lookalike host, a userinfo
bypass, an http downgrade, and the legitimate cncf.io project URL.
Fixes #247
Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
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.
Summary
Fixes #247.
renderProjectCards()inscripts/import-architectures.mjspicked the URL for every published<CNCFProjectCard>with a bare substring test:String.prototype.includesmatches anywhere in a URL — query string, fragment, path, or userinfo — so any host can satisfy it. Content comes from the upstreamcncf/architecturerepo, imported unattended daily and published without link review, so a crafted upstream Markdown link (e.g.https://evil.example/r?u=cncf.io/projects/kubernetes/) could make a CNCF-branded card link to an attacker-controlled origin.Fix
scripts/lib/project-card-links.mjsexportingisCncfProjectHref(), which uses realURLparsing to require:https:protocol, no userinfo, a hostname ofcncf.ioor a*.cncf.iosubdomain, and a/projectspath.renderProjectCards()in place of the substring check, with the same fallback to the constructedwww.cncf.ioURL when no upstream link qualifies.tests/project-card-links.test.mjscovering: the reported bypass URL, acncf.io.evil.examplelookalike host, a userinfo bypass, anhttp://downgrade, a non-/projectscncf.io path, a non-URL string, and the legitimatehttps://www.cncf.io/projects/kubernetes/.All 50 cards currently generated in
docs/architectures/*.mdalready usehttps://www.cncf.io/projects/<slug>/, so this produces no output change for today's upstream data — it only closes the bypass.Scope
Deliberately scoped to
renderProjectCards()only, per the issue's scope note. The separatelogo=hot-linking issue and PR #195 (mirrorProjectAssets()/sanitizeArchitectureAssets()) are untouched.Testing
npm run test:unit— all 63 tests pass (8 new)npx prettier --checkon changed files — passes— hive: backend=copilot model=claude-sonnet-5
🐝 Hive Agent:
contributor| SHA:47705c9