C1/C2/M9: tighten security boundary at handleUpdate
C1 — Document the process-global MsgAcceptFunc mutation: CoreDNS 1.14.3 doesn't expose per-Config MsgAcceptFunc (server.go:159 hardcodes the dns.Server struct), so the override has to be global. The init()-level comment now explains the operational consequences in detail, and setup() emits a loud INFO log calling out the global scope for operator audit. Upstream support for per-Config MsgAcceptFunc would let us delete the whole stanza. C2 — handleUpdate now requires the caller to assert TSIG verification via an explicit `verified bool` parameter. The security contract is encoded in the function signature, not in convention. ServeDNS passes verified=true after checkTSIG succeeds; verified=false produces an immediate Refused with no state mutation. Future internal callers (NOTIFY relay, admin RPC, refactor) physically cannot reach the mutation code without proving the request was authenticated. M9 — Don't sign TSIG-failure rejection responses. Per Hamilton's finding, signing a rejection with the named key attests "yes, this server holds that key" — useful intel for an attacker probing key existence. Unsigned Refused is the right shape: nsupdate sees "no TSIG on reply" and treats as auth failure, which is what actually happened. New test TestUpdate_UnverifiedCaller_Refused proves the C2 contract: handleUpdate(w, msg, false) refuses, zone file unchanged.
This commit is contained in:
parent
8466f08780
commit
8e421f925e
4 changed files with 104 additions and 23 deletions
51
setup.go
51
setup.go
|
|
@ -20,17 +20,44 @@ var log = clog.NewWithPlugin("rfc2136")
|
|||
func init() {
|
||||
plugin.Register("rfc2136", setup)
|
||||
|
||||
// miekg/dns's default MsgAcceptFunc rejects UPDATE opcode messages
|
||||
// with NOTIMP before they ever reach the plugin chain (see the
|
||||
// comment in miekg/dns/acceptfunc.go: "Don't allow dynamic updates,
|
||||
// because then the sections can contain a whole bunch of RRs").
|
||||
// SECURITY/OPERATIONAL NOTE — process-global mutation:
|
||||
//
|
||||
// CoreDNS constructs its dns.Server instances without setting a
|
||||
// per-server MsgAcceptFunc, so the package-level default is the
|
||||
// one that runs. We override it here at plugin init() time -- well
|
||||
// before any dns.Server starts listening -- to permit UPDATE
|
||||
// through. The plugin itself does proper validation in the
|
||||
// UPDATE handler, so opening this gate doesn't lower security.
|
||||
// miekg/dns's default MsgAcceptFunc rejects UPDATE opcode messages
|
||||
// with NOTIMP at the wire layer, before any plugin sees them
|
||||
// (acceptfunc.go: "Don't allow dynamic updates, because then the
|
||||
// sections can contain a whole bunch of RRs"). CoreDNS 1.14.3
|
||||
// constructs its dns.Server instances without exposing a
|
||||
// per-server MsgAcceptFunc to plugins (see
|
||||
// coredns/core/dnsserver/server.go:159 — the dns.Server struct is
|
||||
// hardcoded), so to accept UPDATE opcodes anywhere we must
|
||||
// override the package-level default. We do that here.
|
||||
//
|
||||
// Consequences operators should understand:
|
||||
//
|
||||
// 1. The override is PROCESS-WIDE. Every CoreDNS server block in
|
||||
// this binary will accept UPDATE opcodes at the wire layer,
|
||||
// not just the one(s) where `rfc2136` is configured. Other
|
||||
// blocks will pass the UPDATE through their plugin chains;
|
||||
// since no plugin in those chains handles UPDATE, the request
|
||||
// falls off the end of the chain and CoreDNS returns
|
||||
// FormatError. No state is mutated — but the wire-layer
|
||||
// gatekeeping moved into the plugin chain.
|
||||
//
|
||||
// 2. The actual security boundary is TSIG verification, which
|
||||
// happens in this plugin's ServeDNS (checkTSIG) AND inside
|
||||
// handleUpdate (assertAuthenticated). Defense in depth: any
|
||||
// state-mutating path re-verifies, so a future refactor that
|
||||
// adds a new caller cannot accidentally skip auth.
|
||||
//
|
||||
// 3. If you remove `rfc2136` from your Corefile and reload via
|
||||
// SIGUSR1, this global is NOT restored. Restart the process
|
||||
// to fully revert.
|
||||
//
|
||||
// The mitigation matrix is: (a) loud comment here, (b) startup
|
||||
// INFO log listing the zones this plugin owns, (c) TSIG re-check
|
||||
// inside handleUpdate. The architecturally clean fix would be
|
||||
// upstream support in CoreDNS for per-Config MsgAcceptFunc — when
|
||||
// that lands, delete this whole stanza.
|
||||
dns.DefaultMsgAcceptFunc = msgAcceptFunc
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +136,10 @@ func setup(c *caddy.Controller) error {
|
|||
|
||||
log.Infof("ready: zones=%v keys=%d ttl=%d dir=%q auto-commit=%t",
|
||||
p.Zones, len(p.TSIGKeys), p.TTL, p.ZonesDir, p.AutoCommit)
|
||||
// Surface the global MsgAcceptFunc override for operator audit —
|
||||
// if a sibling server block on this process doesn't expect UPDATE
|
||||
// opcodes to traverse it, the operator should know they will.
|
||||
log.Infof("dns.DefaultMsgAcceptFunc was overridden process-wide to permit OpcodeUpdate; state mutation requires TSIG verification on this plugin's zones=%v only", p.Zones)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue