Skip to content

fix(dnssec): add defensive nil checks#7997

Merged
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/dnssec-ns-nil-check
Apr 1, 2026
Merged

fix(dnssec): add defensive nil checks#7997
yongtang merged 1 commit into
coredns:masterfrom
thevilledev:fix/dnssec-ns-nil-check

Conversation

@thevilledev

Copy link
Copy Markdown
Collaborator

1. Why is this pull request needed and what does it do?

Add length checks for req.Ns before accessing req.Ns[0] in the Delegation and NameError/NoData code paths of Sign().

Currently response.Typify guarantees len(req.Ns) >= 1 for these response types. It requires SOA or NS records in the authority section to classify a response as such, so this cannot be triggered in practice. The guards are added as defense-in-depth in case Typify's classification logic changes in the future.

2. Which issues (if any) are related?

Fixes #7991

3. Which documentation changes (if any) need to be made?

None.

4. Does this introduce a backward incompatible change or deprecation?

No.

Add length checks for req.Ns before accessing req.Ns[0] in the
Delegation and NameError/NoData code paths of Sign().

Currently response.Typify guarantees len(req.Ns) >= 1 for these
response types. It requires SOA or NS records in the authority
section to classify a response as such, so this cannot be
triggered in practice. The guards are added as defense-in-depth
in case Typify's classification logic changes in the future.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
@thevilledev thevilledev marked this pull request as ready for review April 1, 2026 19:03
@thevilledev thevilledev requested review from Isolus and miekg as code owners April 1, 2026 19:03
@yongtang yongtang merged commit 6d6c50d into coredns:master Apr 1, 2026
13 checks passed
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.

plugin/dnssec: potential panic on access to req.Ns[0]

2 participants