Skip to content

feat(rules): add security.txt and version-disclosure rules (#713) - #717

Merged
nc9 merged 1 commit into
mainfrom
claude/713-security-txt-version-disclosure
Oct 13, 2026
Merged

nc9 merged 1 commit into
mainfrom
claude/713-security-txt-version-disclosure

Conversation

@nc9

@nc9 nc9 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two passive security rules and the header passthrough they need.

  • security/security-txt reads /.well-known/security.txt (RFC 9116) and the legacy /security.txt.
    • A catch-all HTML page at the canonical path warns; it never passes.
    • Missing file (404 or 410): warn. A 401/403 (often a WAF or bot rule), 429 or 5xx is not checked, never missing.
    • Contact or Expires missing: warn. Expires in the past, or not a strict RFC 3339 date-time (2027, Oct 1 2027, 2027-02-30T... all warn): warn. More than one Expires: warn.
    • Legacy-only location and an unsigned file are info. A valid file with a future Expires passes.
    • When the body is longer than the 2 KB excerpt, a field not found in that excerpt is reported as info, not a warning.
  • security/version-disclosure warns when Server, X-Powered-By, X-AspNet-Version, X-AspNetMvc-Version or X-Generator carries a dotted version (at least major.minor). A product name with no version (nginx, cloudflare) and a single number (Drupal 9) are not reported. One finding per distinct header value across the site, its pages in the standard item sourcePages (collected in a Set); the value is cut at 120 characters in the message and kept whole in value. Page records stored before the four new headers were recorded (a cached or older crawl) do not pass: a version-disclosure-unrecorded check says they were not checked, and a versioned Server is still reported. SiteData pages carry versionHeadersRecorded for this, set the same way on both engines.
  • Header passthrough. buildHeadersMap now forwards the four version-revealing headers to rules, which previously saw only server. They are stored on the page record as optional fields, so existing stored records still load. No SQLite schema change: headers are stored as JSON.
  • Docs pages for both rules under docs/rules/security/, wired into the Security nav and index.

Cost note: both security.txt paths join the well-known probe sweep, so an audit that runs the security rules sends two extra GETs per origin (the canonical path and the legacy path).

The discovery-probe contracts changed as a result. --rule-exclude ax and ax/* now send the two security.txt probes, because the security rule reads them. Those expectations were updated, and the plugin probe test now also excludes security/* so it still isolates the plugin's probe.

Changes from the maintainer review (2026-10-12):

  • Rebased onto main after feat(rules): add reliability/broken-resources and the Reliability category #703 #714 and feat(rules): add links/broken-anchors for in-page anchor links #718. Golden gate: streaming-rules-canonical-golden.test.ts 101738 -> 101740 findings and 303 -> 305 tally rows, with comments; both tally rows are pinned (security-txt info: the harness sends no discovery probes; version-disclosure skipped: the synthetic records predate the headers). healthScore.overall stays 51.
  • Docs quote the template {header} header reveals a software version: {value} and describe the status, RFC 3339, duplicate and older-crawl behaviour.
  • version-disclosure: message value capped, pages in item sourcePages, a Set per finding, not-checked on older records.
  • security-txt: only 404/410 are missing; strict RFC 3339 Expires; duplicate Expires warns; the quoted Expires is capped.
  • isHtml formatted; CHANGELOG line under [Unreleased] / ### Added.
  • Egress and credentials: no new destinations. The two security.txt paths join the existing well-known probe sweep, which requests the audited host only (its existing custom-header and redirect handling applies), and version-disclosure only reads stored headers.

Agent skill: yes, the squirrelscan agent skill (squirrelscan/skills) should learn the two rules; the maintainer files that as a private issue. Per-category counts (Security +2) are left for the maintainer's batched docs PR.

Closes #713

Verification

bun install --frozen-lockfile

(cd packages/rules && bun test tests/security-txt.test.ts tests/version-disclosure.test.ts tests/discovery-probes.test.ts)  # 52 pass, 0 fail
(cd packages/audit-engine && bun test tests/build-headers-map.test.ts)                    # 7 pass
(cd packages/audit-engine && bun test tests/streaming-rules-canonical-golden.test.ts)     # 1 pass
(cd packages/audit-engine && bun test tests/streaming-rules-golden.test.ts tests/streaming-pre-rules-golden.test.ts)  # 11 pass
(cd apps/cli && bun test tests/commands/audit-discovery-probes-wiring.test.ts)            # 10 pass
(cd packages/report && bun test tests/merged-message-numbers-2231.test.ts tests/merge-check-messages.test.ts tests/locked-rules-coverage.test.ts)  # 56 pass
tsgo --noEmit: core-contracts, crawler, rules, audit-engine, apps/cli  # clean
(cd apps/cli && bun run format:check && bun run lint)                 # clean
bun run scripts/test-suites.ts --check                                # every test file covered
(cd docs && bun run check)                                            # tangly check --strict: all checks passed

The rule and test files are oxfmt- and oxlint-clean (the rules package has no format or lint script of its own).

No end-to-end crawl was run against a live or fixture site. The acceptance fixtures are unit tests that feed the rule the probe and header data a crawl would produce.

Acceptance criteria

  • Fixture: no /.well-known/security.txt produces a security/security-txt warning (unit test)
  • Fixture: a catch-all site that answers /.well-known/security.txt with its HTML homepage produces the same warning, not a pass (unit test)
  • Fixture: a file with Contact: and a future Expires: passes; an Expires: in the past warns (unit test)
  • Fixture: Server: Apache/2.4.41 (Ubuntu) and X-Powered-By: PHP/7.4.3 each produce a security/version-disclosure warning naming the header and value (unit test)
  • Fixture: Server: nginx with no version produces no finding (unit test)
  • X-Powered-By and the ASP.NET version headers reach rules alongside server (build-headers-map test)
  • Both rules have docs pages under docs/rules/security/

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review of #717 (security/security-txt and security/version-disclosure). I read the diff and the rule sources. I did not run the tests.

The two rules are cleanly structured. The catch-all HTML handling and the truncated-excerpt downgrade to info are well thought out. The header plumbing (fetcher → crawler → adapter) is consistent, and the new header fields are optional so older records still load. I found nothing that should block merge.

  • (medium) version-disclosure.ts: pages crawled before this change have no xPoweredBy etc. (the fields are optional). A cached or old crawl will then report "pass" for X-Powered-By, X-AspNet-Version and X-Generator, even though they were never captured. Consider noting this in the pass message, or skipping when none of the new fields were recorded.
  • (low) security-txt.ts: Date.parse is lenient. It accepts forms like 2027 or Oct 1 2027, which RFC 9116 does not allow (it requires RFC 3339). An invalid Expires can therefore pass. A stricter regex check would match the "not a valid date-time" message.
  • (low) security-txt.ts: only the first Expires is checked, and RFC 9116 allows exactly one. A duplicate Expires or a Canonical mismatch goes unreported. This is optional.
  • (low) version-disclosure.ts: finding.pages.includes makes the page loop O(pages × distinct findings). That is fine for typical sites. A Set per finding would avoid the cost on large crawls.
  • (low) version-disclosure.ts: a Server value such as Apache (Ubuntu) is not flagged, but Apache/2 is also not flagged because the regex needs major.minor. Single-number versions in product/version form are common (Apache/2, openresty/1), so you may want to match those too.
  • (nit) security-txt.ts: isHtml is a long line that probably needs a prettier/biome reformat. Check lint.
  • (nit) Test coverage: tests exist for both rules, the headers map and the probe wiring. A test for legacy-only plus canonical-HTML, and one for the missing-new-header case above, would round it out.

@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer review (2026-10-12)

Verdict: needs fixes (low to medium). Reviewed at head c72c8fd against main 2dca3b9. Main CI is green at that sha, so the red checks come from this PR.

Acceptance criteria (#713)

All 7 are met by unit tests in security-txt.test.ts, version-disclosure.test.ts and build-headers-map.test.ts. Nothing was run through an HTTP fixture or an end-to-end crawl.

Fixes

  1. Golden gate. This one test fails "Audit engine golden tests" and the "Audit engine tests" step of "CLI tests". The apps/cli tests step itself passes.
    • File: packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts.
    • expect(v1.findings.length).toBe(101736); (line 154). CI received 101738. The two new rules are site-scoped, so each adds one whole-crawl check. Raise the number by 2 and add a comment line in the existing style, for example // 101736 -> 101738: security/security-txt and security/version-disclosure are site-scoped and each add one whole-crawl check (#713). <their status on the fixture>.
    • expect(v1.perRuleTally.length).toBe(301); (line 176) fails next. Raise it by 2 and extend the tripwire comment.
    • These numbers are relative to the main you rebase on. Other rule PRs edit the same two lines, so rebase and read them again after each merge.
    • Verify with cd packages/audit-engine && bun test tests/streaming-rules-canonical-golden.test.ts. healthScore.overall must stay 51, or the comment must explain why it moved.
  2. Docs template. docs/rules/security/version-disclosure.mdx:16 quotes a filled example: Server header reveals a software version: Apache/2.4.41 (Ubuntu). Quote the template instead: {header} header reveals a software version: {value}.
  3. version-disclosure output.
    • Cap value in the message. A site sets that header, so it can be several KB long.
    • Put the pages in the standard pages field, or in items with sourcePages, not only in details.pages. Otherwise the report cannot list them.
    • Use a Set per finding instead of pages.includes, which is O(pages x findings).
  4. version-disclosure on older crawls. Page records from a cached or older crawl lack the new optional header fields, so they read as a pass. When no page record has the fields defined, report "not checked" instead of passing.
  5. security-txt status handling.
    • Today any status above 0 at the canonical path, other than 200, reads as "missing". Treat only 404 and 410 as missing. A WAF 403, a 429 or a 5xx should be not checked.
    • Date.parse accepts values that are not RFC 3339, such as 2027 or Oct 1 2027. Check Expires with a strict RFC 3339 pattern.
    • Optional: report a duplicate Expires.
  6. Open review-bot findings. All are covered above except two:
    • Apache/2 with no minor version is not matched. That is a design choice, already stated in the docs.
    • The long isHtml line needs the formatter.

PR hygiene

  • CHANGELOG: add one line under ## [Unreleased] / ### Added, ending with squirrelscan/squirrelscan#713.
  • PR description: add a line saying whether the squirrelscan agent skill (squirrelscan/skills) needs a change.
  • Attribution:
    • Remove the Co-Authored-By: and Claude-Session: trailers from the commit, and keep Signed-off-by:.
    • Remove the "Generated with Claude Code" footers and the session URL from the PR body.
    • No attribution lines of any kind in commit or PR text.
  • Docs: quote message templates with placeholders, never filled examples. No em-dashes.
  • Rule counts: leave the per-category counts in the README and docs tables alone. The maintainer updates them in one docs PR after these rule PRs merge.

Merge order

Third, after #714 and #718, and before #716. #716 conflicts with this PR in docs/rules/security/index.mdx and will rebase on it.

@github-actions

Copy link
Copy Markdown
Contributor

Auto-review did not complete

The claude-review job failed before posting a review. This PR has not been auto-reviewed. Run a review manually (/review) before merging.

  • Result: success / is_error=true after 1 turns, 0 permission denial(s), $0.00
  • Job log

Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal):

Show partial review

You've hit your session limit · resets 10:10pm (UTC)

Adds two passive security rules:

- security/security-txt checks /.well-known/security.txt (RFC 9116) and the
  legacy /security.txt. A catch-all HTML page at the canonical path warns
  rather than passes. Contact and a future Expires are required; Expires must
  be a strict RFC 3339 date-time (Date.parse alone took `2027` and rolled
  `2027-02-30` over), and a second Expires warns. Only 404 and 410 read as
  missing: a 401/403 (often a WAF), 429 or 5xx is not checked. An unsigned file
  and a legacy-only location are informational.
- security/version-disclosure warns when Server, X-Powered-By,
  X-AspNet-Version, X-AspNetMvc-Version or X-Generator carries a dotted
  version number. One finding per distinct value, its pages in a Set and in the
  standard item sourcePages; the value is cut at 120 characters in the message.
  Page records stored before the four new headers were recorded do not pass:
  the rule says they were not checked (Server is still judged).

The page header map now forwards X-Powered-By, X-AspNet-Version,
X-AspNetMvc-Version and X-Generator to rules, which previously saw only
server. The fetcher and crawler store them on the page record (null when not
sent); the field is optional, so existing stored records still load, and
SiteData pages carry versionHeadersRecorded so the rule can tell the two apart
on both engines.

Both security.txt paths join the well-known probe sweep, which requests the
audited host only. The rule-exclude and discovery-probe contracts now expect
them when ax is excluded, because the security rule reads them.

Golden gate: 101738 -> 101740 findings and 303 -> 305 tally rows on main with
#703 and #706 (security-txt
info: no discovery probes in the harness; version-disclosure skipped: the
synthetic records predate the headers); healthScore.overall stays 51.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the claude/713-security-txt-version-disclosure branch from d5769a8 to d0984bb Compare October 12, 2026 23:40
@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewed the diff (rules, header passthrough, adapter, tests, docs). I found no blocking issues. The design is careful: the catch-all HTML trap, 404/410-only missing, the truncated-excerpt downgrade to info, strict RFC 3339 parsing and the old-record 'unrecorded' path all look right. I did not run the tests.

  • (low) packages/audit-engine/src/adapter.ts (~1429): the new recordsVersionHeaders function and its JSDoc were inserted between the existing buildHeadersMap docblock (the Set-Cookie fix(rules): read element-separated text in schema/rating-scope #739 #748 note) and buildHeadersMap itself. That docblock is now attached to the wrong function. Move the new function above that comment.
  • (low) security-txt.ts: when the canonical path answers 403, 429 or 5xx and /security.txt has a valid file, the result is the 'legacy-only' info. That claims the file is served only at the legacy location, but the canonical path was never actually checked. Consider saying 'canonical not checked' in that case, or only emitting legacy-only when canonical is 404/410.
  • (low) security-txt.ts: Contact: with an empty value counts as present, and only the first Expires is validated when there are duplicates. Both are minor. Filtering empty values would be stricter.
  • (nit) version-disclosure.ts: pages.some(versionHeadersRecorded) makes a mixed crawl count as fully recorded, so older records are silently treated as 'not sent'. That is probably fine, but it deserves a comment.
  • (nit) Test coverage looks good for the new rules and the buildHeadersMap passthrough. A test for the legacy-with-non-404-canonical case from the second point above would pin the behavior down.

@nc9
nc9 merged commit 7d772c1 into main Oct 13, 2026
15 checks passed
@nc9
nc9 deleted the claude/713-security-txt-version-disclosure branch October 13, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New rules: security.txt and version-revealing server headers

1 participant