Skip to content

feat(cli,config): opt-in tls_proxy_resolves_names for the TLS check behind a proxy #1317 - #1353

Closed
nc9 wants to merge 3 commits into
mainfrom
fix/tls-proxy-names-1317
Closed

nc9 wants to merge 3 commits into
mainfrom
fix/tls-proxy-names-1317

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Closes #1317

[crawler] tls_proxy_resolves_names (default off): behind HTTPS_PROXY / HTTP_PROXY, security/tls-certificate can ask the PROXY to resolve the audited host and its www/apex counterpart. The CONNECT is then host:443 by name, with no local resolution, the name stays the SNI and verification name, and everything else is unchanged:

  • only the audited host and its www./apex counterpart take this path (isAuditedHostOrCounterpart); a name from page content or any other subdomain is still resolved, vetted and pinned here and CONNECTed by address;
  • an IP literal, a metadata hostname and anything refusedWithoutLookup refuses are never CONNECTed by name (they take the normal vetted path and are refused before a byte is sent, in both modes);
  • a refusing, hanging or garbled proxy still gives "Not checked" with PROXY_*; proxy credentials never reach a result.

Setting: [crawler] tls_proxy_resolves_names (config key, no CLI flag), plumbed to every createTlsProbe call (audit, analyze, crawl). Optional in the zod schema so hand-built configs and cloud runs are unchanged. Docs state the SSRF trade-off (where those names resolve is the proxy's decision): docs/configuration/crawler.mdx and the new "When the proxy owns DNS" section of docs/rules/security/tls-certificate.mdx.

Tests (apps/cli/tests/audit/tls-probe.test.ts, real CONNECT proxy fixture): off by default (address CONNECT, local lookup); on: audited host by name with no lookup; www and apex both directions; page-derived host vetted + CONNECT by address, sibling subdomain with a metadata answer refused; IP literal and metadata name refused in both modes with nothing sent; refusing/hanging/garbage proxy not checked and the proxy password absent from the result; a real certificate through the by-name tunnel is verified against the name. 64 pass. Gates: tsgo (cli, config), cli format:check + lint, docs validate, config tests.

Docs + CHANGELOG under Unreleased. Skill (squirrelscan/skills): none (a config key for an uncommon proxy setup).

… the audited host and its www/apex counterpart for the TLS check #1317

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1353: I found no blocking issues. The by-name path is limited to the audited host and its www/apex counterpart. IP literals, metadata names and anything refusedWithoutLookup refuses still fall through to the vetted path. The option is optional in the schema and plumbed to all createTlsProbe call sites. I read the diff and the surrounding code only. I did not run the tests.

  • (low) apps/cli/src/audit/tls-probe.ts:150: isAuditedHostOrCounterpart ignores the port. A probe of example.com:8443 (or any other port) on the audited name is also handed to the proxy by name. The name is still the audited site's, so the trade-off in the docs covers it. Consider also requiring port === site.port, which would match the allowPrivateTarget policy, or say in the docs that the port is not checked.
  • (nit) apps/cli/src/controllers/crawl.ts: the crawl and audit-time probes are created with allowPrivateNetwork: true and no siteUrl. site is then undefined, so the opt-in never applies there. A proxy that owns DNS still gets address CONNECTs from those two probes. If that is intended, a one-line comment or docs note would help.
  • (nit) apps/cli/tests/audit/tls-probe.test.ts: the metadata-name case only asserts on proxy.seen through a string filter. Asserting proxy.seen is empty in the loop would be stricter. Also a test with mixed-case or trailing-dot hostnames would pin the lowercase comparison.
  • (nit) A PR description step for AGENTS.md: the secret-scan baseline check (detect-secrets) is not listed among the commands run. The s3cret test literal may need // pragma: allowlist secret.

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of #1353 (opt-in tls_proxy_resolves_names)

  • (medium) apps/cli/src/controllers/audit.ts:1139 and apps/cli/src/controllers/crawl.ts:297: these createTlsProbe calls get proxyResolvesNames but no siteUrl. With site undefined, isAuditedHostOrCounterpart always returns false, so the setting does nothing for the TLS-failure diagnosis during a crawl. Behind a name-only proxy, that diagnosis still CONNECTs by address and gets refused. The docs and CHANGELOG say the setting applies in audit, analyze and crawl. Either pass siteUrl (the start URL) at those two sites, or limit the docs to the rule-time probe. Tests only cover the probe with siteUrl set, so nothing catches this.
  • (low) tls-probe.ts:~150: the by-name path ignores the port. Any port on the audited host is CONNECTed by name, though allowPrivateTarget elsewhere requires portOf(url) === site.port. It's probably harmless because the host is the same, but matching the port would be consistent. Alternatively, document that the port is not checked.
  • (low) The by-name branch skips policy.allowHost, but refusedWithoutLookup already applies it, so this is fine. A short comment saying so would help the next reader.
  • (nit) Add a test for a trailing-dot or mixed-case hostname, since hostname has its trailing dot stripped but is compared against a lowercase site. isAuditedHostOrCounterpart lowercases it, so this should pass. A test would pin it.
  • (nit) Tests: a case with NO_PROXY matching the audited host (direct path, not by name) would round out coverage.

No security problems found beyond the SSRF trade-off, which is documented and defaults to off.

… audited port only; docs say the crawl probe never requests by name #1317

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Reviewed the diff and the surrounding code in tls-probe.ts, wwwVariant and refusedWithoutLookup. I did not run the tests.

The design holds up. The by-name path is gated on all of these:

  • proxy kind
  • the opt-in setting
  • audited host or its wwwVariant counterpart
  • the audited site's port
  • not an IP literal
  • refusedWithoutLookup returning false

It fails closed when siteUrl is absent, so the crawl-time probe never takes it. The tests cover the negative shapes (sibling subdomain, www.www, other port, metadata name, IP literal) and check that the proxy password never reaches a result.

  • (low) apps/cli/src/audit/tls-probe.ts isAuditedHostOrCounterpart: it lowercases hostname but does not strip a trailing root dot, while siteOrigin does. A example.com. target just falls back to the vetted address path, so it fails safe. Normalizing the same way would make the opt-in apply consistently.
  • (nit) apps/cli/src/cli/commands/config.ts:61 lists the settable crawler.* keys in its help text. Check whether crawler.tls_proxy_resolves_names should be added there, and whether apps/cli/src/self/completion.ts offers config keys.
  • (nit) The isIP(hostname) === 0 check is redundant, since refusedWithoutLookup already refuses IP literals under the default policy. It is harmless as defence in depth, and a short comment saying so would help.

No blocking issues.

@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as de2410c0 77196c74 8ee22f55 via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
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.

security/tls-certificate: opt-in proxy-resolves-names mode for the TLS handshake behind HTTPS_PROXY (follow-up to #1259)

1 participant