Skip to content

security/tls-certificate: run through HTTPS_PROXY and fail the rule instead of aborting on a broken start-URL certificate #1259

Closed

Description

@deniskern

Summary

Two gaps keep security/tls-certificate (v0.0.139, #712) from replacing our own certificate monitor:

  1. Behind an HTTP proxy the rule disappears. We run every audit through an egress proxy (HTTPS_PROXY set, it enforces our outbound network policy). The rule docs say it reports not checked there; in practice it is absent from issues, passedRules and notChecked in -f json, so there is no trace of it at all. A CONNECT tunnel through the proxy would allow the same handshake end to end: the proxy only relays bytes, the client still does TLS with SNI and reads the server certificate.
  2. A broken certificate on the audited host aborts the audit instead of failing the rule. expired.badssl.com, wrong.host.badssl.com, self-signed.badssl.com and rsa1024.badssl.com all end with ✗ Cannot reach https://…/: SSL/TLS error - certificate issue and no JSON output. The worst case (expired or wrong certificate on the main host) therefore never produces a security/tls-certificate failure, only a failed run.

Reproduce (v0.0.139, macOS arm64)

Direct, rule passes:

squirrel audit https://www.brunobanani.com --http -m 1 --rule-include security/tls-certificate --includePassed -f json
# "passedRules":[{"ruleId":"security/tls-certificate",...}]

Same command with any CONNECT proxy (we used a 10-line Node http server handling connect):

HTTPS_PROXY=http://127.0.0.1:18899 HTTP_PROXY=http://127.0.0.1:18899 \
  squirrel audit https://www.brunobanani.com --http -m 1 --rule-include security/tls-certificate --includePassed -f json
# "summary":{"passed":0,"warnings":0,"failed":0,"skipped":0}, no passedRules, no notChecked entry

The crawl itself works through the proxy (all page fetches go through it), only the rule is dropped.

Broken main-host certificate:

squirrel audit https://expired.badssl.com --http -m 1 -f json
# ✗ Cannot reach https://expired.badssl.com/: SSL/TLS error - certificate issue  (exit 1, empty stdout)

Request

  1. Do the rule's handshake through a CONNECT tunnel when HTTPS_PROXY / HTTP_PROXY is set (respecting NO_PROXY), with the same resolved-address checks applied by the proxy side being out of scope. If that is not wanted, at least emit the documented not checked entry in notChecked so JSON consumers can see the gap.
  2. When the start URL fails on a TLS error, still emit a JSON report whose security/tls-certificate result fails with the cause (expired on , hostname not covered, self-signed, incomplete chain), instead of only aborting. The 0.0.139 TLS-cause detection already finds that cause.

Why

With both, the rule covers what we monitor ourselves today (expiry, trust, hostname, plus the www/apex counterpart we currently miss), so we could drop our own certificate check and keep a single source.

Triage notes (maintainers, 2026-10-29)

Verified against main (v0.0.139 plus later merges):

  1. Proxy case is a docs-versus-behaviour gap, not just a missing feature. apps/cli/src/audit/tls-probe.ts returns unavailable ("an HTTP proxy is set in the environment ...") and the rule emits an info check with value not-checked. But the report's not-checked list (packages/report/src/not-checked.ts) only collects skipped checks carrying a NOT_CHECKED skip reason, so the TLS entry never reaches notChecked in -f json, the console or the other formats. The rule page promises "reports not checked"; JSON consumers see nothing. That is the fallback the reporter asked for, and it is a bug on its own.
  2. A broken start-URL certificate aborts before any rule runs. The reachability preflight fails on a TLS error and exits with the cause. The cause detection (packages/crawler/src/tls-cause.ts, the 3 second one-handshake probe) already finds expired, hostname, self-signed and incomplete-chain, so the rule's verdict can be produced from it.
  3. Thresholds are already tunable ([rule_options."security/tls-certificate"]: warn_days, default 30, and error_days, default 7, documented on the rule page). Other limits are fixed today: the RSA minimum (2048 bits, and only RSA is judged today: ECDSA, Ed25519 and DSA keys are not), the www/apex counterpart check and the 3 second probe deadline. A user asked for configurable thresholds and the maintainer asked for key types and minimums too, so the options below add the ones that are hard-coded. The probe currently exposes only the RSA modulus size (rsaBits in packages/utils/src/tls-certificate.ts); key type and curve, signature algorithm and negotiated protocol need to be read from the peer certificate and socket.
  4. CONNECT tunnel risk: the handshake must go through the proxy and never around it, NO_PROXY must be respected, and the runtime must support TLS over an already-open tunnel socket (spike this on the pinned Bun first). If it does not work reliably, ship item 1 (visible not checked with the reason) and keep the tunnel as a follow-up.

Suggested PRs, in order: (a) visible not checked entry (small, ships first), (b) report instead of abort on a TLS-broken start URL, (c) CONNECT tunnel handshake behind a proxy, (d) the key and certificate options (key type allow-list and per-type minimums, signature and protocol limits where the probe exposes them, counterpart check). Not in v0.0.140.

Acceptance Criteria

  • With HTTPS_PROXY set and no tunnel support, squirrel audit ... -f json lists security/tls-certificate in notChecked with the reason, and the console and markdown reports show the same "Not checked" line; the rule page text matches
  • With HTTPS_PROXY or HTTP_PROXY set, the rule makes its handshake through a CONNECT tunnel (SNI and hostname verification intact) and reports pass, warn or fail as it does without a proxy; a host matched by NO_PROXY is probed directly
  • A proxy that refuses or fails the CONNECT (403, 407, 502, timeout) gives a not checked entry with that reason, never a crash and never a pass; no direct socket is opened while a proxy applies
  • squirrel audit https://expired.badssl.com -f json (and wrong.host, self-signed, rsa1024) emits a JSON report in which security/tls-certificate fails or warns with the cause (expired on , hostname not covered, self-signed, incomplete chain, weak key), instead of printing only Cannot reach ... and no JSON; the exit code stays non-zero
  • An unreachable host that is not a TLS problem (DNS failure, refused connection) behaves exactly as today
  • The key and certificate limits are configurable under [rule_options."security/tls-certificate"], each validated with a clear error and documented with defaults: key_types (allow-list of rsa, ecdsa, ed25519, dsa; default ["rsa", "ecdsa", "ed25519"], so a DSA key warns by default), rsa_min_bits (default 2048), ecdsa_min_bits (default 256, the curve size), dsa_min_bits (default 2048, only meaningful when dsa is allowed), reject_weak_signature (boolean, default true: SHA-1 or MD5 signed certificates warn), min_tls_version (default TLSv1.2, a handshake that negotiates lower warns) and check_counterpart (boolean, default true; false skips the www/apex handshake). Signature algorithm and negotiated protocol options ship only if the probe can read them reliably (spike first); otherwise they are listed as follow-ups
  • The key check names the key type and size in its message (RSA 1024 bits, ECDSA P-256, Ed25519, DSA 1024 bits) and the tls-certificate-key check warns when the type is not in key_types or the size is below the matching minimum; the existing warn_days, error_days defaults and the error_days <= warn_days check are unchanged
  • The rule page documents the proxy behaviour, the not-checked entry, the failure-instead-of-abort behaviour and every option with a squirrel.toml example
  • Tests: local TLS fixture servers (expired, wrong host, self-signed, weak key), a CONNECT proxy fixture (accepting, refusing, NO_PROXY), and a JSON-report test for each path
  • CHANGELOG bullet under Unreleased per PR; each PR states whether the squirrelscan skill changes

Activity

  1. nc9 commented on Oct 29, 2026

    @nc9
    Contributor

    This is a good one - thanks. I also got an email this morning asking if the thresholds can be tuned in config - i'll add that to this issue!

  2. added
    bug
    rules
    size: L
    on Oct 29, 2026
  3. added theissue type on Oct 29, 2026
  4. nc9 commented on Oct 29, 2026

    @nc9
    Contributor

    Thanks for the detailed report, @deniskern. I checked both gaps against main and confirmed them, and I added triage notes, a split into PRs and acceptance criteria to the issue description.

    • The proxy case is worse than a missing feature: the rule does record not checked, but that entry never reaches notChecked in the reports, so the docs promise something JSON consumers cannot see. That fix ships first.
    • A broken start-URL certificate will produce a report whose security/tls-certificate fails with the cause, instead of aborting.
    • The CONNECT tunnel through HTTPS_PROXY (respecting NO_PROXY) is planned; it depends on the runtime handling TLS over an open tunnel, so it gets a spike first.
    • The expiry thresholds are already configurable: warn_days (30) and error_days (7) under [rule_options."security/tls-certificate"]. I'm adding the limits that are fixed today (rsa_min_bits, check_counterpart). If you need another one tuned, say which.

    None of this is in v0.0.140.

  5. nc9 commented on Oct 30, 2026

    @nc9
    Contributor

    Checked against main (23a34c1, v0.0.144). Ticked what holds (the visible not-checked entry, the CONNECT tunnel with NO_PROXY handling, refused CONNECT). Open: a broken start-URL certificate still aborts instead of emitting a report with a failing security/tls-certificate; the new rule options (key_types, rsa_min_bits, ecdsa_min_bits, dsa_min_bits, reject_weak_signature, min_tls_version, check_counterpart) do not exist (only RSA is judged, at a fixed 2048 bits); the key check does not name type and size for ECDSA, Ed25519 or DSA; the rule page does not document the failure behaviour or the options; there are no JSON-report tests for expired, wrong-host or self-signed start URLs.

    nik

  6. nc9 commented on Oct 31, 2026

    @nc9
    Contributor

    Verified against main after v0.0.147 (broken start-URL certificate reported as failing, key and certificate options). Met: criteria 1 to 9 (proxy CONNECT behaviour, not-checked reporting, start-URL certificate failures with exit 5, the seven options with tests and docs). Open: criterion 10, the per-PR statement on whether the agent skill changes is not checkable from the repo; and the start-URL e2e has no incomplete-chain case (the wrong-host, self-signed, expired and weak-key cases are covered). Leaving this open for those.

    nik

  7. nc9 commented on Nov 4, 2026

    @nc9
    Contributor

    Acceptance check against main 7c31d5b (proxy work first released in v0.0.143, start-URL failure and options in v0.0.147, all in v0.0.161):

    Criteria 1 to 9 were already ticked; I re-ran their tests on this main: apps/cli/tests/audit/tls-probe.test.ts 67 pass (CONNECT accept, 403 refusal, hang, garbage, NO_PROXY), apps/cli/tests/cli/audit-tls-start-url-1259-e2e.test.ts 8 pass (expired, wrong host, self-signed, RSA-1024, xml and console, rule-exclude, plain-HTTP port, closed port), packages/rules/tests/tls-certificate.test.ts 63 pass, tls-certificate-pipeline.test.ts 11 pass, packages/report/tests/not-checked-tls-1259.test.ts 4 pass. The rule page documents all seven options. A missing intermediate is covered at the cause level (packages/crawler/tests/tls-cause.test.ts "a server that omits its intermediate names the missing chain", tls-probe.test.ts "a leaf served without its intermediate is an incomplete chain"); the start-URL e2e has no incomplete-chain fixture, which no criterion asks for.

    # Criterion Result Evidence
    10 CHANGELOG bullet per PR; each PR states whether the skill changes PASS CHANGELOG.md has a bullet for each part (not-checked entry and lifetime-relative expiry, the broken start-URL certificate, the key and certificate options), and the descriptions of PR #1306, #1401 and #1402 each say "Skill: none" or "Skill change: none"

    Ticked criterion 10 and closing.

    nik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclirulessize: L

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions