Skip to content

caddyhttp: shield specific hostnames from a covering wildcard's client auth - #7920

Open
SillyZir wants to merge 1 commit into
caddyserver:masterfrom
SillyZir:auto-fix/7860
Open

caddyhttp: shield specific hostnames from a covering wildcard's client auth#7920
SillyZir wants to merge 1 commit into
caddyserver:masterfrom
SillyZir:auto-fix/7860

Conversation

@SillyZir

@SillyZir SillyZir commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #7860.

TLS connection policies are first-match by SNI, so a policy for a wildcard hostname (*.example.com with client_auth) also applied client authentication to more specific hostnames served by their own site blocks (public.example.com) — sites that never asked for mTLS.

The adapter now emits an empty shielding connection policy for such hostnames, hoisted directly above the first client-auth-bearing policy whose wildcard SNI covers them, so first-match exempts them from the client-auth requirement. Two cases produce the shield:

  • site blocks whose TLS config yields a connection policy with no settings (previously discarded as having no effect);
  • site blocks with no TLS connection policy at all — the reported case — for which an empty policy is now synthesized.

Deliberately scoped to client authentication. Other wildcard policy settings — certificate selection in particular — are ones a covered hostname generally wants to inherit (the tls_automation_wildcard_shadowing behavior is preserved and its fixture still passes unchanged). Client auth is the setting that inverts the security posture of a site that never configured it, so only that triggers shielding. SNI matchers that fail to decode now emit an adapt warning rather than being silently skipped.

The new adapt fixture (tls_client_auth_wildcard_not_inherited_by_specific_host.caddyfiletest) covers the exact scenario from the issue: with this change the specific hostname's empty policy precedes the wildcard's client-auth policy; on master no such policy is emitted at all. Full caddyfile_adapt suite and caddyconfig package tests pass.

Files: caddyconfig/httpcaddyfile/httptype.go, caddytest/integration/caddyfile_adapt/tls_client_auth_wildcard_not_inherited_by_specific_host.caddyfiletest

Assistance Disclosure
This patch was developed with AI assistance. It was reviewed and tested before submission (affected package tests pass), and is submitted from a human-owned account that takes responsibility for the change.

…t auth

A connection policy for a wildcard hostname (e.g. *.example.com with
client_auth) is first-match by SNI, so it also applied client
authentication to more specific hostnames served by their own site
blocks (public.example.com) — sites that never asked for mTLS.

Two cases produce the shielding empty policy that fixes this:

  - site blocks whose TLS config yields a connection policy with no
    settings (previously discarded as having no effect);
  - site blocks with no TLS connection policy at all — the reported
    case — for which an empty policy is now synthesized.

Either way the empty policy is hoisted directly above the first
client-auth-bearing policy whose wildcard SNI covers the hostname, so
first-match shields it from the client-auth requirement.

Deliberately scoped to client authentication: other wildcard policy
settings, such as certificate selection, are ones a covered hostname
generally WANTS to inherit (see tls_automation_wildcard_shadowing);
sni matchers that fail to decode emit an adapt warning instead of
being silently skipped.

Fixes caddyserver#7860
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.

mTLS on wildcard also enables mTLS on specific subdomain

1 participant