Skip to content

httpcaddyfile: reject conflicting client_auth when merging TLS policies - #8306

Merged
steadytao merged 4 commits into
caddyserver:masterfrom
sam-kota:client-auth-merge-conflict
Nov 4, 2026
Merged

steadytao merged 4 commits into
caddyserver:masterfrom
sam-kota:client-auth-merge-conflict

Conversation

@sam-kota

@sam-kota sam-kota commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

consolidateConnPolicies only reported a client auth conflict when the first of two same-matcher TLS policies had none. When both set client_auth differently, the merge kept the first and silently dropped the second, so a stricter mTLS setting could vanish without any warning.

Repro, adapts with no error on master:

example.com/public/* {
	tls {
		client_auth {
			mode request
		}
	}
	respond "public"
}

example.com/admin* {
	tls {
		client_auth {
			mode require_and_verify
			trust_pool file /path/to/ca.pem
		}
	}
	respond "admin"
}

The adapted config ends up with one policy for sni: example.com with only mode: request, and GET /admin returns 200 without a client certificate (checked end to end with the same config on localhost + tls internal). An example.com block plus an example.com:443 block hits the same path. This now fails to adapt with the existing "conflicting client auth configuration" error, same as the other conflicting fields. The case where only one of the two policies sets client auth behaves as before. Added a test that fails before and passes after.

Assistance Disclosure

The bug was surfaced by AI-assisted analysis, with the patch, and the test. I reviewed them before submitting. The repro above was adapted against master and this branch, and the new test was run against both; go build ./..., go test -short -race ./... and golangci-lint run pass in CI on linux, mac, windows.

@francislavoie

Copy link
Copy Markdown
Member

Site addresses like example.com/public/* are deprecated and are slated for removal because it adds significant complexity like this. I don't think we need to fix stuff having to do with this pattern. If you can show this bug without using path matching in the site address, then we could consider it, but otherwise we don't need to handle it.

@steadytao

Copy link
Copy Markdown
Member

Assistance disclosure must also be explicit**

@sam-kota

sam-kota commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Done

Comment thread caddyconfig/httpcaddyfile/httptype.go Resolved
@sam-kota
sam-kota requested a review from steadytao November 3, 2026 17:01
@steadytao
steadytao merged commit c1c0ee5 into caddyserver:master Nov 4, 2026
27 checks passed
@francislavoie francislavoie added the bug 🐞 Something isn't working label Nov 4, 2026
@francislavoie francislavoie added this to the v2.11.9 milestone Nov 4, 2026
francislavoie pushed a commit that referenced this pull request Nov 5, 2026
…es (#8306)

* httpcaddyfile: reject conflicting client_auth when merging TLS policies
* httpcaddyfile: use host and host:port site addresses in client auth conflict test
* httpcaddyfile: enhance client auth consolidation test to handle conflicting configurations
* httpcaddyfile: remove unnecessary blank line in conflict error handling

(cherry picked from commit c1c0ee5)
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants