Skip to content

fix: complete DNSSEC validation correctness#128

Merged
poyrazK merged 5 commits intomainfrom
fix/api-http-security-issues
May 2, 2026
Merged

fix: complete DNSSEC validation correctness#128
poyrazK merged 5 commits intomainfrom
fix/api-http-security-issues

Conversation

@poyrazK
Copy link
Copy Markdown
Owner

@poyrazK poyrazK commented May 2, 2026

Summary

Fixes 5 DNSSEC validation correctness issues across 3 files:

# Issue Impact
#95 ValidateDNSKEYFormat only validated ECDSA keys, skipped RSA/Ed25519 Invalid RSA/Ed25519 keys passed validation
#96 NSEC3 owner name validation errors silently ignored Invalid NSEC3 proofs not rejected
#101 Trust anchor matching only checked key tag + algorithm, not public key Key tag collision could bypass trust anchor
#90 SignRRSet hardcoded Flags=256 (ZSK), ignored KSK vs ZSK distinction Wrong DNSKEY flags when signing
(findings) Zone-level cache invalidation broken on cluster nodes Other nodes couldn't flush L1 on zone updates

Changes

  • dnssec_verify.go: ValidateDNSKEYFormat now validates RSA SHA-256 and Ed25519 key formats in addition to ECDSA. NSEC3 owner name errors are now propagated instead of silently discarded.
  • dnssec_validator.go: Trust anchor matching now verifies full public key bytes, not just key tag + algorithm.
  • dnssec_service.go: SignRRSet uses key.KeyType to set correct DNSKEY flags (257 for KSK/SEP, 256 for ZSK).
  • redis.go/server.go: Zone-level cache invalidation now publishes just the zone name (no type suffix) so other cluster nodes correctly flush their L1.

Test plan

  • go build ./... passes
  • go test ./... -race passes (all 17 packages)

poyrazK added 2 commits May 2, 2026 14:28
Zone invalidation: when qType is empty, publish zone name only (no ":qType"
suffix) so other cluster nodes correctly flush their entire L1 cache instead
of calling Invalidate with a malformed key.

startInvalidationListener: detect zone-level messages (no colon) and flush
the full L1 cache rather than attempting a per-record invalidation.

Also restore doc comments on PushToDLQ and PopFromDLQ that were removed
during prior cleanup.
- ValidateDNSKEYFormat: validate RSA and Ed25519 keys in addition to ECDSA
  Previously only extractECDSAPublicKey was called, allowing malformed
  RSA/Ed25519 keys to pass validation silently.

- NSEC3 owner name errors: propagate VerifyNSEC3OwnerName errors instead
  of discarding them. Owner name hash mismatches are fatal for validation.

- Trust anchor matching: verify public key bytes in addition to key tag
  and algorithm. Prevents key-tag collision attacks bypassing trust anchors.

- SignRRSet ZSK hardcode: use key.KeyType ("KSK" vs "ZSK") to set correct
  DNSKEY Flags (257 for KSK/SEP, 256 for ZSK). Previously always used 256.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Warning

Rate limit exceeded

@poyrazK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 1 second before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84964b99-f4db-4948-b712-6f2776b60b93

📥 Commits

Reviewing files that changed from the base of the PR and between e140584 and e19af85.

📒 Files selected for processing (7)
  • internal/core/services/dnssec_service.go
  • internal/core/services/dnssec_validator.go
  • internal/core/services/dnssec_validator_test.go
  • internal/dns/packet/dnssec_verify.go
  • internal/dns/packet/dnssec_verify_test.go
  • internal/dns/server/redis.go
  • internal/dns/server/server.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-http-security-issues

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 24 minutes and 1 second.

Comment @coderabbitai help to get the list of available commands and usage tips.

poyrazK added 3 commits May 2, 2026 15:51
- Add ValidateNSEC3Proof tests (WildcardMatch, ValidNXDOMAIN, NoData,
  InvalidOwnerName) to cover the NXDOMAIN/no-data validation path
- Add ValidateNSEC3WildcardProof tests (Valid, EmptyRecords, WrongWildcardHash)
- Add nsec3CoversHash and decodeBase32Hash tests (already at 100%)
- Add TestValidateWithTrustAnchor_PublicKeyMismatch to cover the public
  key comparison branch added in PR #128 (keytag + algorithm + public key)
- Fix TestValidateDNSKEYFormat_RSASHA256_TooSmall to use truncated bytes
  instead of small generated key (crypto/rsa rejects < 1024-bit keys)
- Replace impossible TestValidateNSEC3Proof_NoCoveringNSEC3 with comment
  explaining why owner==queryHash+wrap always covers
- Add missing bytes import to dnssec_verify_test.go

Coverage: ValidateNSEC3Proof 0%->72%, ValidateNSEC3WildcardProof 0%->85%,
nsec3CoversHash 0%->100%, decodeBase32Hash 0%->100%
Copy link
Copy Markdown
Owner Author

@poyrazK poyrazK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay to merge

@poyrazK poyrazK merged commit 63322f8 into main May 2, 2026
7 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.

1 participant