plugin/file: reject SOA owners that do not match the zone (#8555)

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
houyuwushang
2026-09-17 08:49:58 +08:00
committed by GitHub
parent 73198897ef
commit 84a93a0b89
10 changed files with 302 additions and 29 deletions

View File

@@ -192,8 +192,11 @@ func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) {
seenSOA := false
for rr, ok := zp.Next(); ok; rr, ok = zp.Next() {
if !seenSOA {
if s, ok := rr.(*dns.SOA); ok {
if s, ok := rr.(*dns.SOA); ok {
if dns.CanonicalName(canonicalEscape(s.Hdr.Name)) != dns.CanonicalName(canonicalEscape(z.origin)) {
return nil, fmt.Errorf("file %q has SOA owner %s that does not match origin %s", fileName, s.Hdr.Name, z.origin)
}
if !seenSOA {
seenSOA = true
// -1 is valid serial is we failed to load the file on startup.