Repository navigation
feat(rules): add security/tls-certificate for expiry, hostname, chain and key #712 - #716
Conversation
|
Reviewed the TLS probe, the rule and the crawler hook. I did not run the tests, and I only skimmed the docs and fixtures. The design is clean: the probe never throws, "not checked" is never a pass, and the logic is shared between the rule and the crawl. Findings:
No critical or high issues found. |
|
Reviewed the diff for the new
Test coverage is good. It covers the expiry thresholds, hostname, chain, key and www variant checks, the not-checked cases, the audit-stage pipeline, and the crawl root failure. It doesn't cover a stalled handshake (the timeout path) or a SAN containing an IP address. |
Maintainer review (2026-10-12)Verdict: ON HOLD pending design. Fix 1 changes how the probe reaches the engine. Do that first. Merge last of #714-#720. I reviewed head 1442e1c against main 2dca3b9. Main CI is green at that sha, so the red checks come from this PR. Acceptance criteria (#712)11 of 13 are met.
Fixes
PR hygiene
|
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 10:10pm (UTC) |
… and key #712 The original #716 work (rule, socket probe, crawl TLS cause, tests, docs), squashed onto main. Signed-off-by: Claude <[email protected]>
32374e8 to
b253a49
Compare
… and key #712 The original #716 work (rule, socket probe, crawl TLS cause, tests, docs), squashed onto main. Signed-off-by: Claude <[email protected]>
b253a49 to
94ab4a5
Compare
|
Review of #716 ( The design holds up. The egress guard runs before every handshake and the socket connects to the vetted address, with the name as SNI. Proxy environments report not checked instead of going around the proxy. The www/apex counterpart is limited to registrable domains. The cause lookup is memoized per origin and capped at 3 s.
Test coverage looks thorough. It covers real handshakes against fixtures generated at test time, egress refusals, a hung server and the pipeline. Please make sure |
…ts www/apex counterpart #712 Review follow-ups on #716: under --offline the rule's probe contacts the audited host only (the counterpart is unavailable, nothing resolved or sent); comments say why an unreachable counterpart reports nothing, that analyze reads the certificate as served now, and how the lookup and handshakes share one deadline; the options schema is indented as an object. Docs and the CHANGELOG entry name the --offline and analyze behaviour. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of the The design holds up. The handshake is injected, every address is vetted by the egress guard before connecting, and the socket connects to the vetted IP with the host name as SNI. Certificate text from the site is control-char stripped and length-clamped, and the SAN list is capped. The www/apex counterpart comes from the registrable domain only, so another tenant's name is never derived.
I found no blocking issues. |
… and key #712 The original #716 work (rule, socket probe, crawl TLS cause, tests, docs), squashed onto main. Signed-off-by: Claude <[email protected]>
…the egress guard #712 The shared packages opened raw TLS sockets (node:tls in utils, called from the rule and the crawl's TLS root failure), which go around the hosted engine's request-level network policy: a public site whose www name resolves to an internal or metadata address would be reached. - @squirrelscan/utils/tls-certificate is pure now: facts, meaning and a TlsProbeFn type, no socket code. A guard test asserts no shared package imports node:tls, and node:net only for isIP. - The handshake lives in apps/cli/src/audit/tls-probe.ts and is the only one: each name is resolved once (memoized per probe), link-local and metadata answers are refused, the www/apex counterpart of a public site must resolve public (the audited origin may resolve privately, the crawl requests it), and the socket connects to the checked address with the name as SNI. Behind an HTTP proxy from the environment it does not run. A refused target is unreachable/EGRESS_REFUSED and nothing is sent. - RunnerScope.tlsProbe -> ctx.tlsProbe on site rules; the CLI wires it for audit and analyze. With none (cloud, embedders) the rule reports "not checked" with the reason. - CrawlerConfig.tlsProbe for the TLS root-failure cause: one handshake per origin, only for a failure that can still become the root failure, at most 3 s or what the URL's watchdog has left. Without one the fetch's detail stands. The CLI wires it for audit and crawl. - wwwVariant derives the counterpart from the registrable domain only (tldts, private suffixes included): no www.blog.example.com, no www.pages.dev. - Hardening from the security review: the connect uses the URL parser's reading of the host and refuses one it reads differently (0x7f.1, a@b, x/y); socket errors use on("error"); certificate text loses control characters and is bounded (1000 names, 253 chars); messages list ten names and count the rest; the apex and www handshakes run at once (worst case one deadline); the guard test also covers export *, http2, dgram and Bun sockets. - Review follow-ups: error_days <= warn_days refine; "expired less than a day ago" instead of "1 day ago"; IPv6 SAN entries compared canonically; the not-checked message no longer writes the code alone in parentheses (#2231 guard); stalled-handshake and IP SAN tests. - Docs: [rule_options."security/tls-certificate"] (the [rules] table ignores options), the guard, the first-error limit, a templated cause; hub regenerated. CHANGELOG entry re-added. Canonical golden: 102743 -> 102744 findings, 311 -> 312 rules (skipped, not-https). Signed-off-by: Nik Cubrilovic <[email protected]>
…ts www/apex counterpart #712 Review follow-ups on #716: under --offline the rule's probe contacts the audited host only (the counterpart is unavailable, nothing resolved or sent); comments say why an unreachable counterpart reports nothing, that analyze reads the certificate as served now, and how the lookup and handshakes share one deadline; the options schema is indented as an object. Docs and the CHANGELOG entry name the --offline and analyze behaviour. Signed-off-by: Nik Cubrilovic <[email protected]>
…#712 Review of 4cb7dd8: a site audited as https://example.com./ was not the same host as example.com under --offline. siteOrigin now strips the root dot like the probe's targets; a comment says why the counterpart reports only its first problem. Signed-off-by: Nik Cubrilovic <[email protected]>
4cb7dd8 to
b0e9201
Compare
|
Reviewed the diff, mainly the probe, the rule and the runner and controller wiring. I didn't run the tests, and CI was still pending when I looked. The design holds up: shared packages hold no socket code, every handshake goes through the egress guard, and the connection is pinned to the vetted address. I found nothing that should block merge.
|
|
Replies to the review of b0e9201 (no blocking findings):
|
Signed-off-by: Nik Cubrilovic <[email protected]>
…index, rules index) Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the CLI wiring,
|
* origin/main: feat(contracts): free plan renders 2 pages at once, up from 1 (#1207) ci(deps): daily dependency advisory check files one issue when the release gate fails (#1217) docs(rules): the SEO rules page counts 26 structured data rules (#1213) build(deps): ignore GHSA-gcqx-w48m-w2h4 (deepmerge via ultracite, dev tooling only) to unblock the release gate (#1216) chore(release): v0.0.138 notes and version bump (#1212) feat(report,rules): link sections, component-aware findings, fix rollups, Page structure block (#1181) fix(classifier): parse homepage URLs safely, backslash paths are not the root (#1206) build(deps): ignore GHSA-wx4j-mvgx-mqwp (satori, docs build only) to unblock the release gate (#1210)
|
Reviewed the TLS probe ( No blocking issues. The design holds up:
Findings, all minor:
|
…no backtracking (CodeQL polynomial-redos) #712 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the diff, with most attention on
Strengths:
No blocking issues found. |
Summary
squirrel never looked at the certificate.
security/httpsonly checks the URL scheme, and a TLS failure during a crawl said only "check its expiry, hostname coverage, and that the full chain is served".This adds the
security/tls-certificaterule (site scope,skipOnPrivateTarget):example.comandwww.example.compair,blog.example.comhas none, andacme.pages.devpairs withwww.acme.pages.dev, neverwww.pages.dev.error_days(default 7), warns insidewarn_days(default 30).error_daysabovewarn_daysis refused. A pass shows the issuer, the expiry date and the days remaining.UNABLE_TO_VERIFY_LEAF_SIGNATURE).UNABLE_TO_GET_ISSUER_CERT_LOCALLYgets its own message, because the same code can mean an untrusted root.The crawl's TLS root failure now names the cause one handshake found (expired on a date, hostname not covered, missing intermediate, self-signed) instead of the generic list.
Closes #712
Design: the handshake is injected, and only the CLI injects it
The first version opened raw TLS sockets from
packages/utils(called by the rule and by the crawl's root-failure path), which goes around the hosted engine's request-level network policy. This version:@squirrelscan/utils/tls-certificateis the facts and their meaning plus aTlsProbeFntype. A guard test fails if any shared packagesrcimportsnode:tls,node:http2,node:dgram, socket parts ofnode:net(onlyisIPis allowed) or Bun's socket APIs.apps/cli/src/audit/tls-probe.ts, behind the same egress guard as the crawl's own hosts (repo#3430): each name is resolved once per probe, a link-local or cloud metadata answer is refused, and the socket connects to the checked address with the name as SNI, so a rebinding answer cannot move it. For the rule, the audited origin (host and port) may resolve privately because the crawl already requests it, while the counterpart of a public site must resolve to public addresses. A refused target isunreachablewith codeEGRESS_REFUSED, and nothing is sent. Behind an HTTP proxy from the environment it makes no direct connection.RunnerScope.tlsProbebecomesctx.tlsProbeon site rules (CLIauditandanalyze).CrawlerConfig.tlsProbefeeds the root-failure cause (CLIauditandcrawl): one handshake per origin, only for a failure that can still become the root failure, waiting at most 3 s or whatever the URL's watchdog has left. Without a probe (cloud, embedders, tests) the rule says "not checked" and the crawl keeps the fetch's own detail.Phase 2 (legacy TLS versions) is out of scope.
Golden constants (merge note)
packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts: findings 102743 to 102744, per-rule tally 311 to 312, and a tally pin for the rule (oneskipped,not-https: the synthetic origin is plain http and the harness injects no probe).healthScore.overallis unmoved at 51. Any site rule merged before this one shifts both again.Verification
Certificates are generated with openssl at test time and served from 127.0.0.1. Names resolve through injected resolvers. No live host or DNS server is contacted by the tests.
A live CLI run (
squirrel audit https://squirrelscan.com/ --offline --max-pages 1 --rule-include security/tls-certificate, isolated HOME) storedtls-certificate-expirypass: "Certificate valid until 2027-01-16, 80 days remaining, issued by Google Trust Services", through real DNS, the egress check and a pinned handshake.Acceptance Criteria
runSiteRuleswithRunnerScope.tlsProbe), with the real handshake covered separately in the CLI probe tests. Thesquirrelbinary path was run live against a public host (pass shown above).warn_daysanderror_daysoptions change the thresholds (fixture:warn_days = 60makes a 45-day certificate warn)example.comwherewww.example.comresolves and serves a certificate that does not cover it produces a warning namingwww.example.com; when the variant does not resolve, nothing is reportedlocalhostor a private-network host skips the ruledocs/rules/security/, including its optionsChecklist
Signed-off-byline (git commit -s).Docs:
docs/rules/security/tls-certificate.mdx(options under[rule_options."security/tls-certificate"], the egress check, the proxy and first-error limits) and the regenerated Security hub. Skill: no change needed; the rule needs no flag or agent action, and its "not checked" results carry their reason.