Repository navigation
fix(security): hold data/metrics.json URLs to a host allow-list - #756
Closed
hivecommons-hive[bot] wants to merge 1 commit into
Closed
hivecommons-hive[bot] wants to merge 1 commit into
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
scripts/validate-metrics.mjs was the only validator guarding a rendered href that applied no host allow-list: checkUrl() asserted an absolute https URL with no userinfo and stopped, so any host passed. Every URL in data/metrics.json is rendered under hard-coded anchor text -- 'cncf/architecture' in src/components/ReferenceArchitectures, 'Source' in src/components/MetricsDashboard -- so a plain https URL on a host that is not CNCF's publishes as a CNCF-labelled link to an unrelated origin. That is the same sink shape validate-case-studies.mjs and validate-radar-reports.mjs already pin with ALLOWED_HOST_SUFFIXES. Pin the host to cncf.io or github.com after the existing userinfo check, which keeps the more specific userinfo diagnostic for a spoofed-userinfo URL. Both hosts are already the only ones present in data/metrics.json, so this is a no-op for the current data. Closes #752 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 |
Member
|
Superseded by #753, which consolidates the open security-fix PRs (commit cherry-picked unmodified, authorship and DCO preserved). |
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-metrics.mjswas the only validator guarding a renderedhrefthat applied no host allow-list. Its
checkUrl()asserted an absolute URL,protocol === 'https:', and the absence of userinfo — and stopped. Any hostsatisfying those passed, so
https://evil.example/xwas a valid value for everyURL field in
data/metrics.json.Those fields are all rendered as links whose anchor text is hard-coded, so
the visible label and the real destination are independent:
src/components/ReferenceArchitectures/index.js:27— textcncf/architecture, hrefsources.architectures.repositorysrc/components/ReferenceArchitectures/index.js:31— text is the short revision, href`${repository}/commit/${revision}`src/components/MetricsDashboard/index.js:55,111,132,184— textSource ↗, hrefreferenceArchitectureLifecycle.sourceUrl/metric.sourceUrl/series.sourceUrl/chart.sourceUrlMetricsDashboardalso prints fixed copy reading "collected from public CNCFrepositories", asserting a provenance nothing checked.
This is the sink shape the repository already decided needs an allow-list rather
than a scheme test:
scripts/validate-case-studies.mjs:14andscripts/validate-radar-reports.mjs:15both pinALLOWED_HOST_SUFFIXES = ['cncf.io']for precisely this reason.validate-metrics.mjsnever got that half of the treatment.What changed
scripts/validate-metrics.mjsonly:ALLOWED_HOST_SUFFIXES = ['cncf.io', 'github.com'],userinfo check, and makes that check
returnso a spoofed-userinfo URL keepsits more specific diagnostic instead of gaining a second, vaguer one.
github.comis in the list becausesources.*.repository,sources.*.sourceUrland several
metric.sourceUrlvalues legitimately point athttps://github.com/cncf/....Every host in
data/metrics.jsontoday is alreadygithub.comorlandscape.cncf.io, so this is a no-op for the current data —npm run validate:metricsstill reportsValidated 2 metrics.Side effect worth noting:
sources.*.revisionis unvalidated and isconcatenated into
`${repository}/commit/${revision}`. Withrepositoryhost-pinned, an arbitrary
revisioncan now only vary the path on an allowedhost rather than the origin.
Tests
New file
tests/validate-metrics-host-allowlist.test.mjs(10 cases), keptseparate from
tests/validate-metrics.test.mjsso this does not collide withthe open test PRs on that file:
github.comandcncf.iosubdomains across every URL fieldcheckUrl()call sitesnotcncf.ioandevil-github.com— suffix matching is dot-bounded,not a bare
endsWithallow-list error
data/metrics.jsonsatisfies the allow-listVerification on this branch:
TZ=UTC node --test tests/validate-metrics-host-allowlist.test.mjs tests/validate-metrics.test.mjs— 38/38 passTZ=UTC node tests/tools/coverage-report.mjs --check 97 --check-source 99— exit 0;scripts/validate-metrics.mjsat 100.00% lines / 98.11% branchnpx prettier --checkon both touched files — cleannpm run validate:metrics—Validated 2 metricsScope / non-overlap
Touches exactly two paths:
scripts/validate-metrics.mjsand the newtests/validate-metrics-host-allowlist.test.mjs. No open PR touches either.scripts/validate-launch-metrics.mjshas the same shape butdata/launch-metrics.jsonis not rendered by any component, so it has no hrefsink and is deliberately out of scope.
Closes #752
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