Skip to content

BUG: Security-Policy scores the contents of an unrelated security.md found elsewhere in the tree #5198

Open

Description

@tufantunc

What happened

Security-Policy scored my repository 3/10 with:

score is 3: security policy file detected:
Warn: no linked content found
Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy

The repository's SECURITY.md contains, at the analysed commit, 2 URLs matching the check's own reURL, 1 address matching reEML, and 93 substrings matching reDIG. All three security-policy probes should evaluate true.

The check appears to detect the correct file but scan a different one.

Repro

  • Repo: tufantunc/ssh-mcp (public)
  • Analysed commit: 8c008907e420461042f84de761501bbe6927c382
  • Scorecard v5.5.0, via ossf/scorecard-action@v2.4.4
  • Policy file: SECURITY.md at the repo root
  • Also present: .review-pro/node/security.md and .review-pro/ssh-mcp/security.md — unrelated code-review rubric files that happen to be named security.md

I edited SECURITY.md to add a plain email address and an explicit disclosure-timeline table, re-ran, and the score and both warnings were byte-identical. The run was fresh — Code-Review moved 1/19 → 1/20 and CI-Tests 22/29 → 23/29 in the same run.

Root cause (from reading the source)

Discovery and content-scanning use different matchers.

Discovery, checks/raw/security_policy.go — full-path, exact:

func isSecurityPolicyFilename(name string) bool {
	return strings.EqualFold(name, "security.md") ||
		strings.EqualFold(name, ".github/security.md") || ...

.review-pro/node/security.md correctly does not match, so the discovered policy file is the root SECURITY.md. Its path is then handed to the content pass:

err := fileparser.OnMatchingFileContentDo(c.RepoClient, fileparser.PathMatcher{
	Pattern:       data.files[idx].File.Path,   // "SECURITY.md"
	CaseSensitive: false,
}, checkSecurityPolicyFileContent, ...)

But isMatchingPath in checks/fileparser/listing.go:38-48 falls back to the basename:

filename := path.Base(fullpath)
match, err := path.Match(pattern, fullpath)
// No match on the fullpath, let's try on the filename only.
if !match {
	if match, err = path.Match(pattern, filename); err != nil { ... }
}

So the pattern security.md matches .review-pro/node/security.md via its basename. And checkSecurityPolicyFileContent stops at the first file with non-empty content:

// stop here found something, no need to look further (false)
return false, nil

Whichever security.md the file listing yields first wins. A dot-directory sorts before SECURITY.md.

Why this reconciles exactly

.review-pro/node/security.md is 23 lines with 0 URL matches, 0 email matches and 0 reDIG matches. Feeding it through the three probes:

Probe Condition Result Points
securityPolicyContainsLinks (urls + emails) > 0 false 0 of 6
securityPolicyContainsVulnerabilityDisclosure CountSecInfo(Text, false) > 1 false 0 of 1
securityPolicyContainsText FileSize > 1 && FileSize > linkedContentLen + (urls+emails)*2 true 3 of 3

Total: 3 — the observed score, including the counter-intuitive part where ContainsText passes while the other two fail, because it tests FileSize rather than the collected hits.

Impact

A project gets scored on the contents of an arbitrary file that merely shares a basename with a security policy. It is silent: the check reports "security policy file detected", so the maintainer sees a low score on a policy that plainly satisfies the documented criteria, and editing the real SECURITY.md changes nothing. security.md is not an unusual filename for docs, rubrics or templates in a subdirectory.

Suggested fix

Have the content pass address the exact path that discovery selected, rather than a pattern that can match elsewhere — e.g. fetch the file directly by path, or add an ExactPath option to PathMatcher that skips the basename fallback. The basename fallback is presumably load-bearing for other callers, so a per-call opt-out seems safer than changing isMatchingPath for everyone.

Note

I have not attached a debugger — the evidence is the published results, the source at v5.5.0, and the arithmetic above matching the observed score exactly. Happy to test a patch against the repo, which reproduces this on every run.

Activity

  1. daichunghy commented on Aug 29, 2026

    @daichunghy

    The exact-path boundary is the important part here. If discovery has already selected SECURITY.md, rerunning a basename matcher reopens ambiguity and makes the result depend on directory order. I would prefer an exact-path content fetch for this check, plus a regression fixture with root SECURITY.md and a nested security.md that contains no policy signals. That tests both correctness and keeps the general basename fallback untouched for other callers.

  2. zsltg commented on Oct 7, 2026

    @zsltg

    Another repository with the same defect: zsltg/iq at commit
    ee47cfcce6e0a3ce32eb76b54876d1463dc06a73, Scorecard v5.5.0 through
    ossf/scorecard-action@v2.4.4.

    Security-Policy scored 4 with Warn: no linked content found. The root
    SECURITY.md contains two URLs that match reURL. The repository also has
    .agents/security.md, an index file for coding agents with no URLs. The text
    probe and the disclosure probe passed, and only the link probe failed. This
    agrees with your analysis: the content pass matched .agents/security.md by its
    base name and stopped there.

    We ran the reURL pattern and the line scan from collectPolicyHits on our
    SECURITY.md, and they found both URLs.

    We renamed the file to work around the defect. After the rename, the same check
    scored 10 on commit a833917345ff7425d12b07b4505b0a97bae8f6dd, with no change
    to SECURITY.md. The first commit
    above still shows the problem.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions