]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 weeks ago[9.20] fix: dev: Pass empty string instead of NULL to ns_client_dumpmessage()
Ondřej Surý [Wed, 6 May 2026 11:31:40 +0000 (13:31 +0200)] 
[9.20] fix: dev: Pass empty string instead of NULL to ns_client_dumpmessage()

Pass "" instead of NULL to ns_client_dumpmessage() to get the log message printed.

Backport of MR !1022

Merge branch 'backport-ondrej/fix-ns_client_dumpmessage-calls-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!1023

3 weeks ago[9.20] [CVE-2026-3593] sec: usr: Add system test for HTTP/2 SETTINGS frame flood
Aydın Mercan [Wed, 6 May 2026 07:23:43 +0000 (10:23 +0300)] 
[9.20] [CVE-2026-3593] sec: usr: Add system test for HTTP/2 SETTINGS frame flood

A use-after-free vulnerability in the DNS-over-HTTPS implementation could cause named to crash when a client sends a flood of HTTP/2 SETTINGS frames while a DoH response is being written. This affects servers with DoH (DNS-over-HTTPS) enabled.

ISC would like to thank Naresh Kandula Parmar (Nottiboy) for reporting this.

For: https://gitlab.isc.org/isc-projects/bind9/-/issues/5755

Backport of https://gitlab.isc.org/isc-private/bind9/-/merge_requests/949

Merge branch '5755-security-heap-user-after-free-http2-settings-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!992

3 weeks agoPass empty string instead of NULL to ns_client_dumpmessage()
Ondřej Surý [Wed, 6 May 2026 08:12:35 +0000 (10:12 +0200)] 
Pass empty string instead of NULL to ns_client_dumpmessage()

The two new call sites added by the CLASS-validation work passed NULL
as the reason, but ns_client_dumpmessage() bails out early on a NULL
reason — so the message dump never happened. The intent was to dump
the message and let the follow-up ns_client_log() carry the reason
text, so pass "" to suppress the prefix without short-circuiting the
dump.

(cherry picked from commit 3401cbd16f44b4ecb8b57dc9d1951037db6d0e32)

3 weeks ago[9.20] chg: usr: Fix CPU spikes and slow queries when cache approaches memory limit
Ondřej Surý [Tue, 5 May 2026 12:55:39 +0000 (14:55 +0200)] 
[9.20] chg: usr: Fix CPU spikes and slow queries when cache approaches memory limit

When the cache grew close to the configured max-cache-size, every
subsequent entry triggered all worker threads to run cache cleanup at
once, causing CPU spikes and a drop in query throughput. Cleanup is now
spread probabilistically across inserts as memory approaches the limit,
so the work is distributed evenly instead of piling up at the threshold.

Backport of MR !1002

Merge branch '5891-improve-overmem-cleaning-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!1000

3 weeks agoFix use-after-free in DoH write buffer after HTTP/2 send
Aydın Mercan [Tue, 10 Mar 2026 11:48:02 +0000 (14:48 +0300)] 
Fix use-after-free in DoH write buffer after HTTP/2 send

After the send callback completes, the UV request is freed but
the HTTP/2 socket's write buffer still points to the freed memory.
If nghttp2 subsequently needs to send frames (e.g. SETTINGS ACK),
the server_read_callback reads from the dangling buffer.

Clear the write buffer before freeing the UV request.

(cherry picked from commit 6afc4270e0323a52262802d553dda8233df36d42)

3 weeks ago[9.20] [CVE-2026-5946] sec: usr: Disable recursion, UPDATE, and NOTIFY for non-IN...
Ondřej Surý [Mon, 4 May 2026 10:46:34 +0000 (12:46 +0200)] 
[9.20] [CVE-2026-5946] sec: usr: Disable recursion, UPDATE, and NOTIFY for non-IN views

Recursion, dynamic updates (UPDATE), and zone change notifications
(NOTIFY) are now disabled for views with a class other than IN
(such as CHAOS or HESIOD); authoritative service for non-IN zones
(e.g. version.bind in class CHAOS) continues to work as before.
Servers configured with recursion yes in a non-IN view will log a
warning at startup, and named-checkconf flags the same condition.
UPDATE and NOTIFY messages that specify the meta-classes ANY or NONE
in the question section are now rejected with FORMERR.

This addresses a set of closely related security issues collectively
identified as CVE-2026-5946. ISC would like to thank Mcsky23 for
bringing these issues to our attention.

Backport of https://gitlab.isc.org/isc-private/bind9/-/merge_requests/936

Merge branch 'each-security-disable-chaos-recursion-security-bind-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!1009

3 weeks agoMake isc_mem_isovermem() probabilistic
Ondřej Surý [Sun, 19 Apr 2026 19:36:43 +0000 (21:36 +0200)] 
Make isc_mem_isovermem() probabilistic

Replace the hysteretic hi_water/lo_water switch with a stochastic
check: always false below lo_water, always true at or above hi_water,
linearly ramped probability in between.  This spreads cache cleaning
across many inserts instead of triggering a thundering herd once the
hi_water mark is crossed (which causes every addrdataset to enter the
LRU purge path simultaneously and serializes lookups behind the node
write locks).

The is_overmem atomic and its stores are no longer needed and are
removed.  The existing tests that asserted specific hysteretic state
transitions are simplified to check only the deterministic boundaries.

(cherry picked from commit ee24d2a1c3361dcc1c48fb29bb2e0b91bc3405e8)

3 weeks agoAdd system test for HTTP/2 SETTINGS frame flood
Aydın Mercan [Mon, 9 Mar 2026 12:48:34 +0000 (15:48 +0300)] 
Add system test for HTTP/2 SETTINGS frame flood

Send a valid DoH query followed by a flood of SETTINGS frames to
trigger a use-after-free in the write buffer.  Under ASan, named
will abort if the bug is present.

(cherry picked from commit 680e57c8c7110828da22cbc94115a10e8dec2523)

3 weeks ago[9.20] [CVE-2026-3039] sec: usr: Fix GSS-API resource leak
Ondřej Surý [Fri, 1 May 2026 06:39:28 +0000 (08:39 +0200)] 
[9.20] [CVE-2026-3039] sec: usr: Fix GSS-API resource leak

Fixed a memory leak where each GSS-API TKEY negotiation leaked a security context inside the GSS library. An unauthenticated attacker could exhaust server memory by sending repeated TKEY queries to a server with tkey-gssapi-keytab configured. The leaked memory was allocated by the GSS library, bypassing BIND's memory accounting.

Multi-round GSS-API negotiation (GSS_S_CONTINUE_NEEDED) is now rejected, as BIND never supported it correctly and Kerberos/SPNEGO completes in a single round.

Also implemented missing RFC 3645 requirement: the client now verifies that mutual authentication and integrity flags are granted by the GSS-API mechanism (Section 3.1.1).

Closes: https://gitlab.isc.org/isc-projects/bind9/-/issues/5752
Backport of !965

Merge branch 'backport-5752-fix-memory-leak-in-TKEY-negotiation-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!974

3 weeks agoMake the RD flag optional in isctest.query()
Evan Hunt [Tue, 24 Feb 2026 00:27:52 +0000 (16:27 -0800)] 
Make the RD flag optional in isctest.query()

Add an 'rd' parameter (default True) to isctest.query.create() so
that non-recursive queries can be sent with rd=False.

(cherry picked from commit 12e511310024aac38ce223ee47b5108f06caf8f9)

3 weeks ago[9.20] fix: dev: Fix crash in resolver when SIG(0)-signed responses are received...
Ondřej Surý [Fri, 1 May 2026 06:32:14 +0000 (08:32 +0200)] 
[9.20] fix: dev: Fix crash in resolver when SIG(0)-signed responses are received under load

A resolver could crash when handling a SIG(0)-signed response if the
matching client query was cancelled while signature verification was
still in progress — for example, when the recursive-clients quota
was exhausted. This has been fixed.

Closes isc-projects/bind9#5819

Merge branch 'backport-5819-fix-heap-use-after-free-in-resquery_response_continue-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!1001

3 weeks agoFix output token and GSS context leaks in TKEY/GSS-API error paths
Ondřej Surý [Fri, 10 Apr 2026 10:51:31 +0000 (12:51 +0200)] 
Fix output token and GSS context leaks in TKEY/GSS-API error paths

In dst_gssapi_acceptctx(), rename outtoken to outtokenp (matching BIND
convention for output pointer parameters) and free the allocated output
token buffer on error in the cleanup path.

In process_gsstkey(), route the empty-principal error path through
cleanup via CLEANUP() instead of returning early, so that the output
token, GSS context, and TSIG key are all freed consistently by the
existing cleanup block.

(cherry picked from commit 6c46c85d02849fb659584275313529794039f433)

3 weeks agoTest server behavior when sending various UPDATE requests
Evan Hunt [Mon, 9 Mar 2026 04:50:04 +0000 (15:50 +1100)] 
Test server behavior when sending various UPDATE requests

Send update messages for zones with CLASS0, ANY and NONE.  The class
ANY UPDATE also attempts to delete a KX record in an existing IN
class zone to trigger a REQUIRE.

Test that the server is still running.

(cherry picked from commit 1fa1e84d286d5a6d9d3b72ed1c2c29142f40c81d)

3 weeks ago[9.20] [CVE-2026-3592] sec: usr: Limit resolver server list size
Colin Vidal [Thu, 30 Apr 2026 18:49:27 +0000 (20:49 +0200)] 
[9.20] [CVE-2026-3592] sec: usr: Limit resolver server list size

When resolving a domain with many nameservers that share overlapping IP addresses (e.g., 10 NS records all pointing at the same set of addresses), BIND could previously waste time querying duplicate addresses and build up excessively large server lists. Deduplicate addresses in the resolver's server list so that each unique IP is only queried once per resolution attempt, regardless of how many NS records point to it and cap the number of addresses stored per nameserver name to 6 (combined A and AAAA), preventing memory and CPU overhead from domains with unusually large NS/glue sets.

Closes isc-projects/bind9#5641

Backport of !909

Merge branch 'backport-5641-selfpointedglue-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!951

3 weeks agoFix use-after-free in resolver SIG(0) async verification path
Ondřej Surý [Tue, 17 Mar 2026 03:45:16 +0000 (04:45 +0100)] 
Fix use-after-free in resolver SIG(0) async verification path

When a SIG(0)-signed response triggers async ECDSA verification via
dns_message_checksig_async(), the respctx_t holds a raw pointer to
the resquery_t. If the fetch context is shut down while verification
is in flight (e.g. due to recursive-clients quota exhaustion), the
query is destroyed and the callback dereferences a dangling pointer.

Take a reference on the resquery_t when initializing the respctx_t,
and release it in both cleanup paths. The query's own reference to
the fetch context keeps the fctx alive transitively.

(cherry picked from commit 5b58caf5a2cd39d57a51b7b0373bfbc4877a96f9)

3 weeks agoAdd regression test for GSS-API context leak via TKEY CONTINUE
Ondřej Surý [Fri, 20 Mar 2026 07:43:28 +0000 (08:43 +0100)] 
Add regression test for GSS-API context leak via TKEY CONTINUE

Send crafted SPNEGO NegTokenInit tokens that propose the krb5
mechanism without a mechToken.  This causes gss_accept_sec_context()
to return GSS_S_CONTINUE_NEEDED, which on unfixed code leaks the
GSS context handle (~520 bytes per query).

The test verifies that the server rejects the negotiation (TKEY
error != 0, no continuation token) rather than returning a CONTINUE
response (error=0 with output token).

(cherry picked from commit 2f2fb32d737e12c817880d584145cdf85dbc8d06)

3 weeks agoTest UPDATE behavior in CHAOS and other non-IN classes
Evan Hunt [Tue, 17 Mar 2026 20:45:11 +0000 (13:45 -0700)] 
Test UPDATE behavior in CHAOS and other non-IN classes

Send various UPDATE requests that are known to have caused
crashes previously with deliberately misconfigured non-IN
zones; confirm that UPDATE is not processed.

(cherry picked from commit e2f7ba2a4b6e7e5dba2fb1a2c9b2f0323e9a88be)

3 weeks ago[9.20] [CVE-2026-5950] sec: usr: Avoid unbounded recursion loop
Colin Vidal [Thu, 30 Apr 2026 15:55:16 +0000 (17:55 +0200)] 
[9.20] [CVE-2026-5950] sec: usr: Avoid unbounded recursion loop

A bug during bad server handling could cause the resolver to enter an infinite loop, continuously sending queries to an upstream server with no exit condition, until the resolver query timeout was hit. This has been fixed.

ISC would like to thank Billy Baraja (BielraX) for bringing this issue to our attention.

Closes isc-projects/bind9#5804

Backport of !985

Merge branch 'backport-5804-incr-query-counters-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!981

3 weeks agoAdd SRTT-based server selection system test
Colin Vidal [Wed, 4 Mar 2026 17:25:32 +0000 (18:25 +0100)] 
Add SRTT-based server selection system test

Verify that the resolver selects authoritative servers in increasing
SRTT order.  Four servers are configured with increasing response
delays.  100 queries are sent, expecting most to go to the fastest
server (ns2).  Then ns2 stops responding, another 100 queries are
sent and should go to ns3 (the next fastest), and so on through
ns4 and ns5.  Each query uses a unique name to avoid cache hits.

(cherry picked from commit a8d11e14f5b4e4d53219ba751d1b741162b0b84b)

3 weeks agoFix GSS-API context leak in TKEY negotiation
Ondřej Surý [Tue, 17 Mar 2026 23:10:35 +0000 (00:10 +0100)] 
Fix GSS-API context leak in TKEY negotiation

Reject multi-round GSS-API negotiation (GSS_S_CONTINUE_NEEDED) in
dst_gssapi_acceptctx().  Each call to gss_accept_sec_context()
allocates a context inside the GSS library; without this fix, the
context handle was passed back to process_gsstkey() which did not
store it persistently, leaking it on every incomplete negotiation.

An unauthenticated attacker could exhaust server memory by sending
repeated TKEY queries with GSSAPI tokens, each leaking one GSS
context.  The leaked memory is allocated by the GSS library via
malloc(), bypassing BIND's memory accounting.

In practice, Kerberos/SPNEGO (the only mechanism used with BIND)
completes in a single round, so rejecting continuation does not
affect real-world deployments.  See RFC 3645 Section 4.1.3.

(cherry picked from commit 3d8e0d068f08694282c5ecd3bd6c332de6c75485)

3 weeks agoTest CHAOS view recursion behavior
Evan Hunt [Tue, 17 Mar 2026 20:45:11 +0000 (13:45 -0700)] 
Test CHAOS view recursion behavior

Check that recursive and forward queries to views of type CHAOS
are REFUSED, but that authoritative queries are answered correctly.

(cherry picked from commit f33927cd3dd1195f3e70f5798ff7c384f265867e)

3 weeks ago[9.20] sec: usr: Fix outgoing zone transfers' quota issue
Arаm Sаrgsyаn [Thu, 30 Apr 2026 12:48:42 +0000 (12:48 +0000)] 
[9.20] sec: usr: Fix outgoing zone transfers' quota issue

Unauthorized clients could consume outgoing zone transfers quota
and block authorized zone transfer clients. This has been fixed.

Backport of MR !971

Fixes isc-projects/bind9#3589

Merge branch 'backport-3859-security-xfrout-quota-fix-9.20' into 'security-bind-9.20'

See merge request isc-private/bind9!996

3 weeks agorctx_resend() increment query counters
Colin Vidal [Tue, 7 Apr 2026 20:18:58 +0000 (22:18 +0200)] 
rctx_resend() increment query counters

Calls to `rctx_resend()` are done internally within the resolver, in
flow which are not supposed to happens more than once. For instance,
if some query fails, and a specific flag "F" wasn't set, then set the
flag and try again. This wouldn't occur more than once because if the
query fails the next attempt, the flag "F" would be set already, so the
resolver would move to the next server (or give up).

However, a subtle bug missing checking a flag, for instance, could lead
to an unbounded loop re-trying to query the same server. This is now
impossible as `rctx_resend()` also increment the query counters (so if
such case occurs, it would stop once the maximum limit is reached).

The dns_resstatscounter_retry are also only incremented if the
`fctx_query()` succeeds, similar to as is done in `fctx_try()`.

(cherry picked from commit f3e74304889a2e8b69c8e88fc9a383589decda32)

3 weeks agoAdd system test for self-pointed glue deduplication
Colin Vidal [Thu, 5 Feb 2026 10:20:11 +0000 (11:20 +0100)] 
Add system test for self-pointed glue deduplication

Test the resolver's behavior with self-pointed glue where each NS
has the same set of addresses.  Verify that addresses are
deduplicated and each unique IP is only queried once.

Also test the ADB address limit knob (-T adbaddrslimit=).

(cherry picked from commit c21fc6cb95d77312d6fb891f17ce9df41a25af6d)

3 weeks agoSkip "deny-answer-address" for non-IN addresses
Evan Hunt [Tue, 17 Mar 2026 20:24:43 +0000 (13:24 -0700)] 
Skip "deny-answer-address" for non-IN addresses

Ensure that we don't attempt an ACL match for answer addresses
when handling a class-CHAOS zone. This is an additional line of
defense for YWH-PGM40640-74.

(cherry picked from commit e62673c765b52307c800e86f0185fe52b573c145)

3 weeks agoApply XFR-out quota after ACL is checked
Aram Sargsyan [Tue, 31 Mar 2026 13:00:00 +0000 (13:00 +0000)] 
Apply XFR-out quota after ACL is checked

Unauthorized clients can consume XFR-out quota and block authorized
XFR clients. Apply the quota after ACL is checked.

(cherry picked from commit 5615e6c47a2cd00d82d48b568cc55a4b89daa330)

3 weeks agoRefactor incrementing query counters
Colin Vidal [Tue, 7 Apr 2026 20:18:10 +0000 (22:18 +0200)] 
Refactor incrementing query counters

Move the logic incrementing the query counter and the global query
counter into a dedicated helper function.

(cherry picked from commit 05d6da2de54c093689e675e81ae898ee41220666)

3 weeks agoRemove duplicate addresses from the resolver SLIST
Colin Vidal [Wed, 4 Feb 2026 09:18:42 +0000 (10:18 +0100)] 
Remove duplicate addresses from the resolver SLIST

The SLIST (essentially `fctx->finds`, forwarders and dual-stack
alternatives aside) can have duplicate server addresses when multiple
in-domain nameservers share the same IP addresses:

  sub.example.          NS      ns1.sub.example.
  sub.example.          NS      ns2.sub.example.
  ns1.sub.example.      A       1.2.3.4
  ns1.sub.example.      A       5.6.7.8
  ns2.sub.example.      A       1.2.3.4
  ns2.sub.example.      A       5.6.7.8

If both 1.2.3.4 and 5.6.7.8 fail to return a valid answer, the resolver
would query each address twice.

The problem is fixed by replacing the two-phase server selection (sort
each find list by SRTT, sort finds by head SRTT) with a single linear
scan in nextaddress() that finds the lowest-SRTT unmarked, non-duplicate
address across all find lists.

The old approach had a correctness bug: after sorting, the resolver
picked the next address from the "current" find list rather than
globally.  For example, with find lists [1, 15, 26] and [3, 4, 5], the
second pick would be SRTT 15 instead of the correct SRTT 3.

The new approach is both simpler and correct: each call to nextaddress()
walks all addresses, skips marked and duplicate entries, and returns the
one with the lowest SRTT.  While this walk is repeated for each server
attempt, it operates on a small bounded list and is negligible compared
to the network I/O of querying the server.

(cherry picked from commit b1c5856a3764b4025e93f8baf06c45c8fa029752)

3 weeks agoReject meta-classes in UPDATE and NOTIFY messages
Mark Andrews [Tue, 3 Mar 2026 23:00:56 +0000 (10:00 +1100)] 
Reject meta-classes in UPDATE and NOTIFY messages

NOTIFY and UPDATE messages must specify a data class in the
QUESTION/ZONE section.  NONE and ANY are meta-classes and not
appropriate here.  Return FORMERR if either is used.

Rejecting messages with a query class of NONE addresses YWH-PGM40640-72,
YWH-PGM40640-82, and YWH-PGM40640-83.  Rejecting messages with a query
class of ANY addresses YWH-PGM40640-87, YWH-PGM40640-88, and
YWH-PGM40640-117.

Fixes: isc-projects/bind9#5778
Fixes: isc-projects/bind9#5782
Fixes: isc-projects/bind9#5783
Fixes: isc-projects/bind9#5797
Fixes: isc-projects/bind9#5798
Fixes: isc-projects/bind9#5853
(cherry picked from commit c66a1b1e1bfd6c79d7b9bc8d4a59e69f4faa1563)

3 weeks agoAdd xfr quota starvation system test
Alessio Podda [Mon, 13 Apr 2026 13:55:38 +0000 (15:55 +0200)] 
Add xfr quota starvation system test

Add a starvation test that tries to starve the XFR quota with
unautorized requests.

(cherry picked from commit 53135592b7ff6c272b6577b2e7747258628442e3)

3 weeks agoAdd reproducer for BADCOOKIE resend loop
Matthijs Mekking [Thu, 9 Apr 2026 09:32:07 +0000 (11:32 +0200)] 
Add reproducer for BADCOOKIE resend loop

Run malicious server: resend_loop/ans3/ans.py

Start BIND: ns4

Send single query to test.example

The resolver will repeatedly resend queries until the fetch timeout
expires, resulting in resulting in thousands of qrysent while the quota
counter remains 0.

(cherry picked from commit 7eeb463bc58cbd71419aaf189d7829f2dfd8d055)

3 weeks agoLimit the number of addresses returned per ADB find
Colin Vidal [Thu, 5 Feb 2026 08:46:01 +0000 (09:46 +0100)] 
Limit the number of addresses returned per ADB find

Add a hard limit on the number of addresses that ADB returns from a
single NS lookup (dns_adbfind_t).  This mitigates a flood attack
where an attacker controls a zone with many addresses for a
nameserver, each returning an invalid response.  The global
max-query count (default 50) also limits this, but significant harm
can be done before that limit is reached.

The default limit is now 6 (v4 and/or v6) addresses for an ADB find (so,
ADB looking up for A/AAAA addresses of a name server name). It can be
overridden for testing via 'named -T adbaddrslimit=N'.

(cherry picked from commit 3ec37fc69356ee682bee7f67940613ac31d93d7b)

3 weeks agoValidate DNS message CLASS early in request processing
Ondřej Surý [Wed, 4 Mar 2026 09:46:58 +0000 (10:46 +0100)] 
Validate DNS message CLASS early in request processing

Reject requests with unsupported or misused CLASS values before
further processing.  Only IN, CH, HS, RESERVED0 (for DNS Cookies),
ANY (for TKEY negotiation), and NONE (for DNS UPDATE) are accepted;
all other classes return NOTIMP.  Misuse of NONE or ANY outside
their allowed contexts returns FORMERR.

This adds further protection against bugs of the same general class
as YWH-PGM40640-70 and YWH-PGM40640-73.

(cherry picked from commit 0a687451505037e9f9a850c9cb113aed4995b03f)

3 weeks agoDisable UPDATE and NOTIFY for non-IN classes
Evan Hunt [Wed, 4 Mar 2026 21:24:52 +0000 (13:24 -0800)] 
Disable UPDATE and NOTIFY for non-IN classes

Return NOTIMP for UPDATE and NOTIFY requests received for views with a
class other than IN.  Only QUERY is now supported for non-IN views such
as CHAOS.

When running dns dns_rdata_tostruct() with types that are only defined
for class IN, ensure that the class is correct before proceeding.

Add an assertion that any zone being updated is of class IN. (Note
that previously, a DLZ zone could have its class value set incorrectly
to NONE; this has been fixed.)

This addresses YWH-PGM40640-70 and YWH-PGM40640-73 (as well as any
similar problems that might have occurred in the future) by minimizing
the code paths that can be reached by rdata classes other than IN, so it
is safe for the implementation to assume that rdatatypes that are only
defined for class IN, such as SVCB or WKS, have been parsed and
validated, and not accepted as unknown/opaque data.

Fixes: isc-projects/bind9#5777
Fixes: isc-projects/bind9#5779
(cherry picked from commit a6d8e330ed6cf0021bff3f00aa1dc7a296f5aec0)

3 weeks agoDisable recursion for non-IN classes
Evan Hunt [Tue, 3 Mar 2026 22:00:38 +0000 (14:00 -0800)] 
Disable recursion for non-IN classes

Force recursion off, and set allow-recursion/allow-recursion-on ACLs
to none, for views with a class other than IN. Log a configuration
warning if recursion is explicitly enabled for a non-IN view.

This addresses YWH-PGM40640-74 and YWH-PGM40640-75 by preventing any
attempt at recursive processing in a class-CHAOS view, ensuring that
server addresses used for recursive queries and received in recursive
responses are of the expected format.

Fixes: isc-projects/bind9#5780
Fixes: isc-projects/bind9#5781
(cherry picked from commit 7becff1a14684a68208c92b3b0315c045c05ad75)

3 weeks ago[9.20] fix: dev: Check validator name when adding EDE text
Mark Andrews [Thu, 7 May 2026 02:01:04 +0000 (12:01 +1000)] 
[9.20] fix: dev: Check validator name when adding EDE text

When a validator is being shut down, the associated name
`val->name` is set to NULL.  This could cause a crash if a worker
thread subsequently added an EDE code with `val->name` in the
extra text.

`validator_addede()` now checks whether the name is NULL before
trying to add it to the extra text.

Closes #5613

Backport of MR !11945

Merge branch 'backport-each-validator-log-after-shutdown-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11977

3 weeks agocheck for val->name == NULL when adding EDE text
Evan Hunt [Fri, 1 May 2026 18:12:54 +0000 (11:12 -0700)] 
check for val->name == NULL when adding EDE text

When a validator is being shut down, the associated name
`val->name` is set to NULL.  This could cause a crash if a worker
thread subsequently added an EDE code to the response containing
val->name in the extra text.

`validator_addede()` now checks whether the name is NULL before
trying to add it to the extra text.

(cherry picked from commit 2c608705274df6ac0737a1444992c39ab2562011)

3 weeks ago[9.20] fix: usr: Fix a bug in allow-query/allow-transfer catalog zone custom properties
Arаm Sаrgsyаn [Wed, 6 May 2026 21:02:40 +0000 (21:02 +0000)] 
[9.20] fix: usr: Fix a bug in allow-query/allow-transfer catalog zone custom properties

The :iscman:`named` process could terminate unexpectedly when
processing a catalog zone with an invalid ``allow-query`` or
``allow-transfer`` custom property (i.e. having a non-APL type)
coexisting with the valid property. This has been fixed.

Closes #5941

Backport of MR !11954

Merge branch 'backport-5941-catz-catz_process_apl-bug-fix-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11975

3 weeks agoFix a bug in catz_process_apl()
Aram Sargsyan [Mon, 4 May 2026 22:34:01 +0000 (22:34 +0000)] 
Fix a bug in catz_process_apl()

The allow-transfer/allow-query catalog zone custom properties support
only APL RRtypes. All other types are correctly rejected by the
catz_process_apl() function. However, when an APL RRtype is processed
by that function, and another (non-APL) RRtype is then attempted to be
processed, there is an assertion failure happening in the prologue
of the function because `*aclbp != NULL` (i.e. an APL has been already
processed). Move the code to do type checking before the affected
REQUIRE assertion.

(cherry picked from commit 67e0090371b4bd4c8933b8644f68a3dbc592a214)

3 weeks agoAdd a catz test with invalid allow-transfer property
Aram Sargsyan [Mon, 4 May 2026 22:27:56 +0000 (22:27 +0000)] 
Add a catz test with invalid allow-transfer property

Check that invalid/unexpected RRtypes coexisting with a valid APL
RRtype does not cause an assertion failure.

(cherry picked from commit a4f05a26ad923de94d9311b631122f6de18e7f5e)

3 weeks ago[9.20] fix: usr: Fix a memory leak issue in the catalog zones
Arаm Sаrgsyаn [Wed, 6 May 2026 19:35:18 +0000 (19:35 +0000)] 
[9.20] fix: usr: Fix a memory leak issue in the catalog zones

The :iscman:`named` process could leak small amounts of memory
when processing a catalog zone entry which had defined custom
primary servers with TSIG keys using both the regular ``primaries``
custom property syntax and the legacy alternative syntax (``masters``)
at the same time. This has been fixed.

Closes #5943

Backport of MR !11951

Merge branch 'backport-5943-catz-primaries-tsig-key-name-leak-fix-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11973

3 weeks agoFix a memory leak issue in catz_process_primaries()
Aram Sargsyan [Mon, 4 May 2026 11:45:21 +0000 (11:45 +0000)] 
Fix a memory leak issue in catz_process_primaries()

Free the old version of the keyname (if it exists) before setting
the new one.

(cherry picked from commit 4576a67a935b59191119e1b3f8f1ebce1521f3c8)

3 weeks agoAdd a catz test with a duplicate primaries entry (alternative syntax)
Aram Sargsyan [Mon, 4 May 2026 11:40:57 +0000 (11:40 +0000)] 
Add a catz test with a duplicate primaries entry (alternative syntax)

This new check ads a catalog member zone with both variants of
the labeled primaries/masters property. This should not cause
any issues.

(cherry picked from commit 4f5f4b77c76eb205a3e270f7c9956289841e8735)

3 weeks ago[9.20] fix: dev: Make BIND9 compatible with OpenSSL 4
Arаm Sаrgsyаn [Wed, 6 May 2026 14:36:43 +0000 (14:36 +0000)] 
[9.20] fix: dev: Make BIND9 compatible with OpenSSL 4

OPENSSL_cleanup() in OpenSSL 4 doesn't free the memory, and that is
not compatible with BIND 9's memory leak detection code. Don't use
custom allocation/deallocation functions for OpenSSL's internal memory
management.

See https://github.com/openssl/openssl/pull/29721

Closes #5808

Backport of MR !11865

Merge branch 'backport-5808-openssl4-compat-fix-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11896

3 weeks agoRemove OpenSSL memory tracking support from the tls.c module
Aram Sargsyan [Thu, 16 Apr 2026 17:31:04 +0000 (17:31 +0000)] 
Remove OpenSSL memory tracking support from the tls.c module

OPENSSL_cleanup() in OpenSSL 4 doesn't free the memory, and that is
not compatible with BIND 9's memory leak detection code. Don't use
custom allocation/deallocation functions for OpenSSL's internal memory
management in the tls.c module.

See https://github.com/openssl/openssl/pull/29721

(cherry picked from commit 4ede6edc547109af81dc5c5ec25cf3ff7991bc10)

3 weeks ago[9.20] fix: usr: Implement seamless outgoing TCP connection reuse
Ondřej Surý [Wed, 6 May 2026 13:09:09 +0000 (15:09 +0200)] 
[9.20] fix: usr: Implement seamless outgoing TCP connection reuse

The resolver can and will reuse outgoing TCP connections to the same host, as recommended by RFC 7766. This prevents a whole class of attacks that abuse the fact that establishing a TCP connection is expensive and it is fairly easy to deplete the outgoing TCP ports by putting them into TIME_WAIT state.

The number of pipelined queries per connection is capped at 256 to limit the impact of a connection drop.

Backport of MR !11845

Merge branch 'backport-3741-reuse-tcp-connections-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11846

3 weeks agoInclude disptype and transport in dispatch hash key
Ondřej Surý [Thu, 9 Apr 2026 15:35:09 +0000 (17:35 +0200)] 
Include disptype and transport in dispatch hash key

Move disptype and transport into dispatch_hash() and dispatch_match()
so that the match function is the single source of truth for whether
two TCP dispatches are interchangeable.  This replaces the post-loop
disptype filter in dispatch_gettcp() and makes the disptype field in
struct dispatch_key actually used.

(cherry picked from commit 46547966839926313abdb4f4de57a8e94a64f0c0)

3 weeks agoDo not reuse shared TCP dispatches for zone transfers
Ondřej Surý [Thu, 19 Mar 2026 04:06:47 +0000 (05:06 +0100)] 
Do not reuse shared TCP dispatches for zone transfers

Zone transfers (XFRIN) need a dedicated TCP connection because they
are long-lived and stream the entire zone.

(cherry picked from commit 6e78094ebd8ebc31b71d62af6671d600aecb68e3)

3 weeks agoUse sequential per-dispatch message IDs for TCP
Ondřej Surý [Sun, 15 Mar 2026 06:52:34 +0000 (07:52 +0100)] 
Use sequential per-dispatch message IDs for TCP

TCP dispentries no longer use the global QID hash table at all.
Responses are matched by scanning disp->active, and sequential
per-dispatch IDs (bounded by the pipelining limit) are unique
within a single dispatch by construction.  Since TCP delivers
only data we asked for on a specific connection, the per-peer
uniqueness that the global table enforced was never actually
needed for TCP.

DNS_DISPATCHOPT_FIXEDID is plumbed through dns_request_createraw
-> get_dispatch -> dns_dispatch_createtcp so FIXEDID TCP requests
always get a fresh isolated dispatch — the caller-supplied ID
then cannot collide with any other in-flight query either.

(cherry picked from commit 3e364aec2bd55c1a08cad786e9b9efa27120368a)

3 weeks agoLimit TCP pipelining per shared dispatch
Ondřej Surý [Sun, 15 Mar 2026 06:23:33 +0000 (07:23 +0100)] 
Limit TCP pipelining per shared dispatch

Cap the number of in-flight queries on a single shared TCP dispatch.
When the limit is reached, the dispatch is removed from the hash
table so subsequent queries get a fresh connection.  The existing
dispatch continues serving its queries until they complete.

This bounds the blast radius of a connection drop: at most N queries
fail simultaneously instead of all queries to that server.

The default limit is 256.  It can be overridden for testing via
'named -T tcppipelining=N'.

(cherry picked from commit 385ceabe8f9d50c13f6781fbed79807ed77da69d)

3 weeks agoDisable TCP pipelining in tcp and masterformat system test
Ondřej Surý [Sun, 15 Mar 2026 07:57:26 +0000 (08:57 +0100)] 
Disable TCP pipelining in tcp and masterformat system test

Set tcppipelining=1 on recursive servers in the system tests to
restore one-query-per-connection behavior.  The tests relies on
specific connection and query counting that breaks with TCP
connection sharing.

(cherry picked from commit 05e8b58307db4333633226a3a38f3321368c41f7)

3 weeks agoImplement seamless TCP connection reuse in dns_dispatch
Ondřej Surý [Tue, 17 Feb 2026 10:05:33 +0000 (11:05 +0100)] 
Implement seamless TCP connection reuse in dns_dispatch

Previously, the user of dns_dispatch API had to first call
dns_dispatch_gettcp() and if that failed create a new TCP dispatch with
dns_dispatch_createtcp().  This has been changed and the TCP connection
reuse happens transparently inside dns_dispatch_createtcp().  There are
separate buckets for dns_resolver, dns_request and dns_xfrin units, so
these don't get mixed together.

(cherry picked from commit d5ee86b799893096b7e95e6426459fae3cf7ef00)

3 weeks ago[9.20] fix: usr: Fix a crash when reconfiguring while an NTA is being rechecked
Ondřej Surý [Wed, 6 May 2026 07:33:18 +0000 (09:33 +0200)] 
[9.20] fix: usr: Fix a crash when reconfiguring while an NTA is being rechecked

When named was reconfigured or shut down while a negative trust anchor
was being rechecked against authoritative servers, the in-flight recheck
could outlive the view that owned it and cause `named` to crash.  This
has been fixed.

Closes #5938

Backport of MR !11948

Merge branch 'backport-5938-ref-ntatable-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11966

3 weeks agoHold a reference to the NTA table for the lifetime of each NTA
Evan Hunt [Mon, 4 May 2026 07:05:27 +0000 (00:05 -0700)] 
Hold a reference to the NTA table for the lifetime of each NTA

Each dns__nta_t now references its parent ntatable in nta_create() and
releases it in dns__nta_destroy().  This avoids a use-after-free in
fetch_done() and other callbacks that dereference nta->ntatable: the
ntatable could otherwise be released by view destruction while an
in-flight resolver fetch still holds a reference to the NTA.

(cherry picked from commit 26c895cc9281d5cc36447d4a2c5464ad31137f76)

3 weeks ago[9.20] fix: usr: Prevent a crash when using both dns64 and filter-aaaa
Ondřej Surý [Wed, 6 May 2026 05:53:51 +0000 (07:53 +0200)] 
[9.20] fix: usr: Prevent a crash when using both dns64 and filter-aaaa

An assertion failure could be triggered if both `dns64` and the `filter-aaaa` plugin were in use simultaneously. This happened if the plugin triggered a second recursion process, which then attempted to store DNS64 state information in a pointer that had already been set by the original recursion process. This has been fixed.

Closes #5854

Backport of MR !11949

Merge branch 'backport-5854-dns64-aaaaok-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11967

3 weeks agoClear dns64_aaaaok immediately after use
Evan Hunt [Mon, 4 May 2026 05:00:39 +0000 (22:00 -0700)] 
Clear dns64_aaaaok immediately after use

The DNS64 state information stored in client->query.dns64_aaaaok
could cause an assertion failure in query_respond() if the server
was configured in such a way as to trigger a new recursion before
the query had been reset - for example, by using the filter-aaaa
plugin, which may need to recurse to find out whether an A record
exists.

This has been addressed by clearing DNS64 state information
immediately after the call to query_filter64().

(cherry picked from commit 7213b038f0beb2f4750b858113af1f9e18ae0520)

3 weeks ago[9.20] fix: dev: Fix a stack use-after-free in qpzone
Evan Hunt [Wed, 6 May 2026 00:01:08 +0000 (00:01 +0000)] 
[9.20] fix: dev: Fix a stack use-after-free in qpzone

In previous_closest_nsec(), a new qpreader was opened to search the NSEC
tree. It was possible for that to be used to update a QP iterator object
owned by the caller, and then be destroyed when the function returned.

This has been addressed by having the caller open the NSEC qpreader
instead.

Closes #5942

Merge branch '5942-qpiter-fix-bind-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11956

3 weeks agoFix a stack use-after-free in qpzone
Evan Hunt [Mon, 4 May 2026 23:23:42 +0000 (16:23 -0700)] 
Fix a stack use-after-free in qpzone

In previous_closest_nsec(), a new qpreader was opened to search the NSEC
tree. It was possible for that to be used to update a QP iterator object
owned by the caller, and then be destroyed when the function returned.

This has been addressed by having the caller open the NSEC qpreader
instead.

4 weeks ago[9.20] fix: usr: Reject record sets too large to serve in DNS
Ondřej Surý [Tue, 5 May 2026 19:18:27 +0000 (21:18 +0200)] 
[9.20] fix: usr: Reject record sets too large to serve in DNS

When BIND was asked to store a record set whose total size exceeds
what fits in a DNS message, it would allocate memory and build the
structure, then fail later at response time. Such oversized record
sets are now rejected at the time of storage with an error, avoiding
wasted work on data that can never be served.

Backport of MR !11963

Merge branch 'backport-ondrej/harden-buflen-overflow-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11964

4 weeks agoReject oversized RRsets at slab construction
Ondřej Surý [Wed, 8 Apr 2026 10:53:16 +0000 (12:53 +0200)] 
Reject oversized RRsets at slab construction

dns_rdataslab_fromrdataset(), dns_rdataslab_merge() and
dns_rdataslab_subtract() summed per-record storage into an
unsigned int with no upper-bound check.  An RRset whose total
encoded size exceeds DNS_RDATA_MAXLENGTH cannot fit in a DNS
message and is unservable; building its in-memory representation
only burns memory on data that will fail at response time, and at
the upper bound the running sum could in theory wrap.

Cap the running total at DNS_RDATA_MAXLENGTH and return ISC_R_NOSPACE
when exceeded.  Update the qpdb cache memory-purge test to use a
record size that fits within the new limit.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit f9d24b1b8548363b73a086de9d7038ac2517cd12)

4 weeks ago[9.20] rem: dev: Remove obsolete KEY record EXTENDED flag deprecated by RFC 3445
Ondřej Surý [Tue, 5 May 2026 12:24:06 +0000 (14:24 +0200)] 
[9.20] rem: dev: Remove obsolete KEY record EXTENDED flag deprecated by RFC 3445

KEY resource records originally defined EXTENDED flag that was removed
by RFC 3445 back in 2002. BIND still carried code to parse and emit it,
including the additional two-octet flags field that followed when the
EXTENDED bit was set. That handling has been removed and the affected
bit positions are now reserved.

Dropping the extended-flags handling also eliminates a possible crash
that could be reached when signing a zone containing an invalid key.

Closes #5900

Partial backport of MR !11961

Merge branch 'backport-5900-remove-keyflag-extended-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11962

4 weeks agoRemove DNS_KEYFLAG_EXTENDED
Evan Hunt [Thu, 30 Apr 2026 18:28:58 +0000 (11:28 -0700)] 
Remove DNS_KEYFLAG_EXTENDED

The DNS_KEYFLAG_EXTENDED flag was only legitimate for type KEY
and was eliminated by RFC 3445. Dropping the extended-flags
handling in pub_compare() also fixes a possible crash when
signing a zone whose journal contains a crafted DNSKEY: a
6-byte record with the EXTENDED bit set produced a memmove()
length that underflowed and ran off a stack buffer.

(cherry picked from commit 9c06f0a41de12fb4366db42c1dd4bbc785fe67b2)

4 weeks ago[9.20] fix: dev: Tidy up the cleanup path in check_signer()
Ondřej Surý [Tue, 5 May 2026 06:20:19 +0000 (08:20 +0200)] 
[9.20] fix: dev: Tidy up the cleanup path in check_signer()

When check_signer() processed a DNSKEY whose public-key data could not
be parsed, the early return on the parse error skipped the cleanup of
the cloned signature rdataset.  In every code path that currently
reaches this function the cloned rdataset holds no resources, so no
memory was actually leaked, but the cleanup is restructured so the
parse and the iteration cannot diverge again.

Closes #5869

Merge branch '5869-fix-memory-leak-in-check_signer-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11957

4 weeks agoTidy up cleanup path in check_signer()
Ondřej Surý [Fri, 10 Apr 2026 16:25:18 +0000 (18:25 +0200)] 
Tidy up cleanup path in check_signer()

The cloned signature rdataset was not disassociated on the early
return taken when dns_dnssec_keyfromrdata() fails to parse the DNSKEY
public-key data.  In every current caller val->sigrdataset reaches
check_signer() rdatalist-backed, so dns_rdataset_clone() copies the
struct without taking any reference and dns_rdataset_disassociate()
is a no-op -- no memory is actually leaked today.  Hoist the key
parse out of the per-RRSIG loop and let the function fall through
to a single cleanup path, so the parse and the iteration cannot
diverge again.

Assisted-by: Claude:claude-opus-4-7
4 weeks agoAdd a test with an active truncated key
Evan Hunt [Sun, 3 May 2026 07:41:58 +0000 (00:41 -0700)] 
Add a test with an active truncated key

Check that an invalid truncated key is handled correctly.

4 weeks ago[9.20] fix: usr: Prevent crafted queries from degrading RRL performance
Ondřej Surý [Tue, 5 May 2026 05:07:28 +0000 (07:07 +0200)] 
[9.20] fix: usr: Prevent crafted queries from degrading RRL performance

With response rate limiting enabled, an attacker sending queries from many
spoofed source addresses could steer entries into the same slot of the
internal rate-limit table and slow down query processing on the affected
server. The table now uses a per-process keyed hash so the placement of
entries cannot be predicted or influenced from the network.

Closes #5906

Backport of MR !11950

Merge branch 'backport-5906-rrl-hash-collision-dos-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11952

4 weeks agoUse a keyed hash for the RRL bucket table
Ondřej Surý [Wed, 29 Apr 2026 16:20:03 +0000 (18:20 +0200)] 
Use a keyed hash for the RRL bucket table

The previous hash_key() was a deterministic, unkeyed (<<1) + add over the
key words.  An off-path attacker could invert it offline and submit
queries whose source /24, qname hash, and qtype map to a single bucket;
under chaining this turns every lookup into an O(N) walk under
rrl->lock and starves legitimate query processing on the very feature
deployed to mitigate DoS.

Replace it with isc_hash32(), which is HalfSipHash-2-4 keyed by a
per-process random seed, so collision sets cannot be precomputed.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit a6b7ce29c4cfab2ab1d46f48f21f531d5ffde942)

4 weeks ago[9.20] fix: ci: Use "git push --force-with-lease" for autorebases
Michał Kępień [Thu, 30 Apr 2026 20:38:25 +0000 (22:38 +0200)] 
[9.20] fix: ci: Use "git push --force-with-lease" for autorebases

If a merge request is merged to an autorebased branch while it is
getting rebased, the "git push -f" command at the end of the autorebase
job will cause the contents of that merge request to be silently deleted
from Git history even though the merge request will still be (correctly)
shown as "merged" by GitLab.

Use "git push --force-with-lease" instead to prevent force-pushing the
rebased version of the branch if it is pushed to after its pre-rebase
version is fetched by the autorebase job.  Report such an event
accordingly.  For simplicity, no retries are attempted as the problem is
expected to be resolved by the next autorebase and the chances of this
scenario happening in practice are already low to begin with.

Backport of MR !11939

Merge branch 'backport-michal/use-git-push-force-with-lease-for-autorebases-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11940

4 weeks agoUse "git push --force-with-lease" for autorebases
Michał Kępień [Thu, 30 Apr 2026 20:19:59 +0000 (22:19 +0200)] 
Use "git push --force-with-lease" for autorebases

If a merge request is merged to an autorebased branch while it is
getting rebased, the "git push -f" command at the end of the autorebase
job will cause the contents of that merge request to be silently deleted
from Git history even though the merge request will still be (correctly)
shown as "merged" by GitLab.

Use "git push --force-with-lease" instead to prevent force-pushing the
rebased version of the branch if it is pushed to after its pre-rebase
version is fetched by the autorebase job.  Report such an event
accordingly.  For simplicity, no retries are attempted as the problem is
expected to be resolved by the next autorebase and the chances of this
scenario happening in practice are already low to begin with.

(cherry picked from commit f5a7671107e0c51f2a30b0d15aa24298694cb77a)

4 weeks ago[9.20] new: ci: Set up automatic rebasing for security-* branches
Michał Kępień [Thu, 30 Apr 2026 11:27:56 +0000 (13:27 +0200)] 
[9.20] new: ci: Set up automatic rebasing for security-* branches

Introduce a set of private branches containing only security fixes that
are automatically rebased onto the corresponding open source branches
whenever new changes are merged.  Each rebase triggers a basic build,
failing the CI job if the build breaks.

When a security-* branch is rebased, create a CI pipeline for its new
revision and rebase its corresponding bind-9.x-sub branch (if it exists)
on top of it, creating a rebase chain.

Report any failures in the process via Mattermost.

These changes enable treating security fixes similarly to other code
changes, without deferring merges all the way until release prep.

Backport of MR !11930

Merge branch 'backport-michal/autorebase-chain-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11931

4 weeks agoSet up automatic rebasing for security-* branches
Michał Kępień [Thu, 30 Apr 2026 09:58:55 +0000 (11:58 +0200)] 
Set up automatic rebasing for security-* branches

Introduce a set of private branches containing only security fixes that
are automatically rebased onto the corresponding open source branches
whenever new changes are merged.  Each rebase triggers a basic build,
failing the CI job if the build breaks.

When a security-* branch is rebased, create a CI pipeline for its new
revision and rebase its corresponding bind-9.x-sub branch (if it exists)
on top of it, creating a rebase chain.

Report any failures in the process via Mattermost.

These changes enable treating security fixes similarly to other code
changes, without deferring merges all the way until release prep.

(cherry picked from commit af7d5e566ee0bf1d6c761a4301f7b3072d5080bd)

4 weeks ago[9.20] fix: usr: prevent malicious DNSSEC zones from exhausting validator CPU
Ondřej Surý [Thu, 30 Apr 2026 11:24:00 +0000 (13:24 +0200)] 
[9.20] fix: usr: prevent malicious DNSSEC zones from exhausting validator CPU

A DNSSEC-signed zone could publish a DNSKEY with an unusually large
RSA public exponent and force any validator resolving names in that
zone to spend disproportionate CPU verifying signatures.  The
validator now rejects such DNSKEYs, matching the limit already
applied to keys read from files or HSMs.

Closes #5881

Backport of MR !11917

Merge branch 'backport-5881-rsa-exponent-keytrap-cpu-amplification-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11923

4 weeks agoReject RSA DNSKEYs with oversize public exponents at parse time
Ondřej Surý [Thu, 30 Apr 2026 05:01:53 +0000 (07:01 +0200)] 
Reject RSA DNSKEYs with oversize public exponents at parse time

The wire-format RSA DNSKEY parser was the only key path with no upper
bound on the public exponent — opensslrsa_parse and opensslrsa_fromlabel
already cap at RSA_MAX_PUBEXP_BITS.  An attacker-controlled DNSKEY could
therefore force a validator to compute s^e mod n with e up to ~|n| bits,
amplifying every verify by ~120x for typical 2048-bit moduli (OpenSSL
itself only caps the exponent for moduli above 3072 bits).  Apply the
same bit-count cap to wire-format keys.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit ab8c1a77e06bf7fc969ad1fac20c3ae5a96257e5)

4 weeks ago[9.20] fix: usr: Stop delv from aborting on a malformed query name
Ondřej Surý [Thu, 30 Apr 2026 10:08:04 +0000 (12:08 +0200)] 
[9.20] fix: usr: Stop delv from aborting on a malformed query name

delv aborts with SIGABRT instead of exiting cleanly when given a query
name that fails wire-format conversion (e.g. a label longer than 63
octets). After this change delv prints the parse error and exits with
a normal failure code.

Closes #5916

Backport of MR !11921

Merge branch 'backport-5916-delv-run-resolve-null-detach-abort-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11927

4 weeks agoSkip detach when delv's client never created
Ondřej Surý [Thu, 30 Apr 2026 07:38:40 +0000 (09:38 +0200)] 
Skip detach when delv's client never created

run_resolve allocates dns_client_t late, but the cleanup epilogue
called dns_client_detach() unconditionally. When convert_name() or
dns_client_create() failed first, the detach hit a NULL client and
the REQUIRE(DNS_CLIENT_VALID) inside it aborted the process with
SIGABRT instead of a clean error exit.

Guard the detach with a NULL check. Add a digdelv test that runs
delv on a query name whose first label exceeds 63 octets and
asserts the process does not exit 134.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit dba102ef16821f91f0494f9db5c9a646dcab913f)

4 weeks ago[9.20] fix: usr: prevent rare named crash when notifies are cancelled
Ondřej Surý [Thu, 30 Apr 2026 10:04:06 +0000 (12:04 +0200)] 
[9.20] fix: usr: prevent rare named crash when notifies are cancelled

Under heavy load, named could occasionally crash when a queued
outbound notify or zone refresh was cancelled at the moment it
was being sent — for example, while a zone was being reloaded or
removed.  The race that caused the crash is now prevented.

Closes #5915

Backport of MR !11918

Merge branch 'backport-5915-ratelimiter-dequeue-tick-uaf-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11922

4 weeks agoDispatch ratelimiter events under the lock
Ondřej Surý [Thu, 30 Apr 2026 05:39:23 +0000 (07:39 +0200)] 
Dispatch ratelimiter events under the lock

isc__ratelimiter_tick() and isc_ratelimiter_shutdown() each pulled
events out of rl->pending into a function-local list, dropped the
mutex, and then iterated.  ISC_LIST_APPEND leaves the link in the
LINKED state, so a concurrent isc_ratelimiter_dequeue() saw an
event as still queued, called ISC_LIST_UNLINK against rl->pending —
which patched the prev/next of the local list — and freed the
event before dispatch finished, producing either an INSIST in the
unlink macro or a use-after-free in the dispatch loop.

isc_async_run() is a non-blocking wfcq enqueue, so there is no
benefit to dropping the mutex around it.  Unlink each event and
hand it to isc_async_run() while still holding rl->lock; the
existing ISC_LINK_LINKED check in dequeue then correctly
distinguishes "still queued and cancellable" from "already taken".

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 4d465f4fa58abb79b90d9019900e7d543fb511ea)

4 weeks ago[9.20] fix: dev: free per-command rndc state when response serialisation fails
Ondřej Surý [Thu, 30 Apr 2026 08:31:47 +0000 (10:31 +0200)] 
[9.20] fix: dev: free per-command rndc state when response serialisation fails

When isccc_cc_towire failed while building an rndc reply,
control_respond returned without releasing the per-command request,
response, HMAC secret copy, and text buffer.  They were eventually
freed when the connection closed, but until then the HMAC key copy
stayed in named's memory.  The failure path now goes through the
same cleanup label as every other error.

Closes #5913

Backport of MR !11915

Merge branch 'backport-5913-controlconf-control-respond-cleanup-leak-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11919

4 weeks agoRun conn_cleanup on isccc_cc_towire failure in control_respond
Ondřej Surý [Thu, 30 Apr 2026 04:29:21 +0000 (06:29 +0200)] 
Run conn_cleanup on isccc_cc_towire failure in control_respond

The bare return left conn->secret, conn->response, conn->request, and
conn->text pinned until the connection itself was torn down — every
other error in the function reaches conn_cleanup via goto, and the
success path falls into the same label, so the towire-failure return
was the lone outlier.  Send it through the existing cleanup path.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 1b681dfa2ff408f40ca5e3453e336ff8864af27c)

4 weeks ago[9.20] fix: dev: Fix swapped arguments in redirect2() single-label branch
Ondřej Surý [Thu, 30 Apr 2026 05:39:10 +0000 (07:39 +0200)] 
[9.20] fix: dev: Fix swapped arguments in redirect2() single-label branch

On a recursive resolver with nxdomain-redirect configured, an
NXDOMAIN result for a query whose qname is the root could corrupt
the view's nxdomain-redirect target, after which the redirect
feature stopped working for every subsequent query in that view
until named was restarted.

Closes #5908

Backport of MR !11908

Merge branch 'backport-5908-query-redirect2-name-copy-arg-swap-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11913

4 weeks agoFix swapped arguments in redirect2() single-label branch
Ondřej Surý [Wed, 29 Apr 2026 17:23:19 +0000 (19:23 +0200)] 
Fix swapped arguments in redirect2() single-label branch

For a query whose qname is the root, the labels==1 branch in
redirect2() called dns_name_copy(redirectname, view->redirectzone)
with arguments reversed, overwriting the view-global
nxdomain-redirect target with the empty redirectname rather than
copying the configured target into the per-query lookup name.  After
the corruption, view->redirectzone names the root, so
dns_name_issubdomain() makes redirect2() short-circuit for every
subsequent query and the nxdomain-redirect feature stops working
until named is restarted.

Triggering this needs the resolver to receive an NXDOMAIN for the
root from upstream, which does not happen in normal DNS operation.

Swap the arguments to match the dns_name_copy(source, dest)
signature.  Add a system test that issues a root query through the
nxdomain-redirect resolver and verifies the redirect feature still
works for a normal NXDOMAIN-producing query afterwards.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit c62f24f7eea4447609e4e3f14773ae7a1beb6709)

4 weeks ago[9.20] fix: usr: Fix rndc-confgen aborting on HMAC-SHA-384/512 keys above 512 bits
Ondřej Surý [Thu, 30 Apr 2026 05:06:31 +0000 (07:06 +0200)] 
[9.20] fix: usr: Fix rndc-confgen aborting on HMAC-SHA-384/512 keys above 512 bits

`rndc-confgen -A hmac-sha384` and `-A hmac-sha512` documented a `-b`
range of 1..1024, but any value above 512 aborted on hardened builds
instead of producing a key. The full advertised range now works.

Closes #5903

Backport of MR !11903

Merge branch 'backport-5903-hmac-generate-stack-overflow-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11910

4 weeks agoSize HMAC key generation buffers to the maximum block size
Ondřej Surý [Wed, 29 Apr 2026 14:23:10 +0000 (16:23 +0200)] 
Size HMAC key generation buffers to the maximum block size

hmac_generate() declared its on-stack nonce buffer as
unsigned char data[ISC_MAX_MD_SIZE], i.e. 64 bytes. That is the maximum
digest size, but the buffer is filled up to the algorithm's HMAC block
size, which is 128 bytes for SHA-384 and SHA-512. Asking rndc-confgen
for an HMAC-SHA-384 or HMAC-SHA-512 key with -b > 512 (the documented
range allows up to 1024) wrote past the end of the stack buffer; on
hardened builds this aborted with a stack-smash detector firing
instead of producing a key.

Use the existing ISC_MAX_BLOCK_SIZE (128) for the buffer so the full
1..1024 range advertised by -A hmac-sha{384,512} works as documented.
The matching key_rawsecret[64] in confgen's generate_key() is enlarged
the same way so the generated key fits when dumped to the buffer.

Add a system test that exercises rndc-confgen across the previously
overflowing keysizes; with -Db_sanitize=address it caught the abort
before the fix.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 46f6bb6364db1dcbbfb2a2add72cff45fd1bda22)

4 weeks ago[9.20] fix: usr: Fix suppressed missing-glue check in named-checkzone
Ondřej Surý [Wed, 29 Apr 2026 16:13:23 +0000 (18:13 +0200)] 
[9.20] fix: usr: Fix suppressed missing-glue check in named-checkzone

named-checkzone and named-checkconf -z silently skipped the
missing-glue check for any NS name that had already triggered an
extra-AAAA-glue warning, so zones missing required A glue could pass
validation and be deployed with broken delegations.

Backport of MR !11899

Merge branch 'backport-ondrej/check-tool-err-glue-code-collision-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11905

4 weeks agoResolve ERR_MISSING_GLUE / ERR_EXTRA_AAAA value collision
Ondřej Surý [Wed, 29 Apr 2026 12:03:38 +0000 (14:03 +0200)] 
Resolve ERR_MISSING_GLUE / ERR_EXTRA_AAAA value collision

Both constants were defined as 5. The symbol table used by checkns() to
deduplicate log messages keys on (name, error_code), so logging an
extra-AAAA error caused logged() to also return true for the
missing-glue check, silently skipping the entire missing-glue block for
the same name in named-checkzone and named-checkconf -z.

Convert the ERR_* defines to an auto-numbered enum so the compiler
guarantees the values stay pairwise distinct.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 72d21a08063400d9a3e9c3d13ccc5ac28bf457c1)

5 weeks ago[9.20] chg: nil: Disable licensing check for root.hints
Colin Vidal [Tue, 28 Apr 2026 14:51:41 +0000 (16:51 +0200)] 
[9.20] chg: nil: Disable licensing check for root.hints

Removing REUSE licensing header check for `root.hints` files.

Backport of MR !11893

Merge branch 'backport-colin/disable-licensing-check-roothints-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11894

5 weeks agoRemove licensing header check for `root.hint[s]`
Colin Vidal [Tue, 28 Apr 2026 13:46:57 +0000 (14:46 +0100)] 
Remove licensing header check for `root.hint[s]`

Removing REUSE licensing header check for `root.hint` and `root.hints`
files.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit 19a446f00e572e13597b080934e52e034f2a4cc3)

5 weeks ago[9.20] new: doc: Add AI coding assistants guidance to CONTRIBUTING.md
Ondřej Surý [Mon, 27 Apr 2026 08:58:12 +0000 (10:58 +0200)] 
[9.20] new: doc: Add AI coding assistants guidance to CONTRIBUTING.md

Adapted from the Linux kernel's Documentation/process/coding-assistants.rst
to the BIND 9 context. Adds three subsections under the existing
"Guidelines for Tool-Generated Content" section:

- Licensing and legal requirements (MPL-2.0, SPDX identifiers).
- Signed-off-by and Developer Certificate of Origin: AI agents must
  not add Signed-off-by trailers; only the human submitter may
  certify the DCO.
- Attribution: the Assisted-by: AGENT_NAME:MODEL_VERSION trailer
  for recording AI involvement, with an explicit prohibition on
  AI-added Co-Authored-By trailers (Co-Authored-By designates a
  human co-author who shares responsibility).

Backport of MR !11888

Merge branch 'backport-ondrej/coding-assistants-doc-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11891

5 weeks agoAdd AI coding assistants guidance to CONTRIBUTING.md
Ondřej Surý [Wed, 22 Apr 2026 13:01:34 +0000 (15:01 +0200)] 
Add AI coding assistants guidance to CONTRIBUTING.md

Adapted from the Linux kernel's Documentation/process/coding-assistants.rst
to the BIND 9 context. Adds three subsections under the existing
"Guidelines for Tool-Generated Content" section:

- Licensing and legal requirements (MPL-2.0, SPDX identifiers).
- Signed-off-by and Developer Certificate of Origin: AI agents must
  not add Signed-off-by trailers; only the human submitter may
  certify the DCO.
- Attribution: the Assisted-by: AGENT_NAME:MODEL_VERSION trailer
  for recording AI involvement, with an explicit prohibition on
  AI-added Co-Authored-By trailers (Co-Authored-By designates a
  human co-author who shares responsibility).

(cherry picked from commit 2339bcd49381f4ab58c3f7cc9f43e4edc57bbf67)

6 weeks ago[9.20] fix: usr: Fix named crash when processing SIG records in dynamic updates
Ondřej Surý [Fri, 17 Apr 2026 17:24:17 +0000 (19:24 +0200)] 
[9.20] fix: usr: Fix named crash when processing SIG records in dynamic updates

Previously, :iscman:`named` could abort if a client sent a dynamic update containing a SIG record (the legacy signature type) to a zone configured with an update-policy. The function `dns_db_findrdataset` had an incorrect requirements prerequisite that prevented SIG records being looked up, which was triggered as part of processing an UPDATE request and could be triggered remotely by any client permitted to send updates. This has been fixed by ensuring that SIG records are handled consistently with RRSIG records during update processing.

Closes #5818

Backport of MR !11864

Merge branch 'backport-5818-fix-update-of-sig-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11876

6 weeks agoAdd test for SIG in prequisites of dynamic update
Matthijs Mekking [Thu, 16 Apr 2026 14:17:34 +0000 (16:17 +0200)] 
Add test for SIG in prequisites of dynamic update

Make sure the nameserver correctly handles SIG records in the
prerequisites of the dynamic update. The first check is to ensure that
the prerequisites are not examined prior to checking the credentials.

The second test case checks that the SIG present prerequisite is
examined and therefore refuses the update. Also this should not trigger
an assertion failure in dns__db_findrdataset() (due to the REQUIRE()
only accepted dns_rdatatype_rrsig when the covers parameter was set).

(cherry picked from commit 51f27fda46870acea69835f82835ca857c000bd0)

6 weeks agoAdd AXFR regression test for SIG covers preservation
Ondřej Surý [Thu, 16 Apr 2026 11:25:03 +0000 (13:25 +0200)] 
Add AXFR regression test for SIG covers preservation

diff.c rdata_covers() runs on both dns_diff_apply (IXFR, ns/update.c
dynamic updates) and dns_diff_load (AXFR).  After the previous commit
refused SIG and NXT in dynamic updates, the AXFR path remains the
most natural way to drive legacy SIG records into a secondary's zone
DB and regression-gate the rdata_covers() fix.

The test adds ans11 as an AsyncDnsServer primary for a small zone
whose AXFR carries two SIG rdatas at the same owner with different
covered types (A, MX) and different TTLs (600, 1200), and declares
ns6 a secondary of that zone.  With the bug present, dns_diff_load
groups both tuples at typepair (SIG, 0) and the MX-covering record
inherits the first-seen TTL (600); the fix keeps them at (SIG, A)
and (SIG, MX) with their original TTLs.

rndc dumpdb -zones on the secondary is used to inspect stored state
directly, because the wire-level SIG query response merges
same-(owner,type,class) RRs and masks the per-rdataset TTLs.

(cherry picked from commit e9f880c78ff3c2f799763628060eca0f0d64e70f)

6 weeks agoRefuse SIG and NXT records in dynamic updates
Ondřej Surý [Thu, 16 Apr 2026 10:23:34 +0000 (12:23 +0200)] 
Refuse SIG and NXT records in dynamic updates

SIG (24) and NXT (30) are obsolete DNSSEC record types, superseded by
RRSIG and NSEC in RFC 3755.  Allowing them through dynamic update
exposes two distinct bugs that the surrounding GL#5818 work already
fixes as defense-in-depth:

  - dns__db_findrdataset() used to REQUIRE that (covers == 0 ||
    type == RRSIG), which aborts named when a SIG update reaches the
    prescan foreach_rr() call.  Fixed to accept dns_rdatatype_issig().
  - diff.c rdata_covers() used to test only RRSIG, dropping the
    covered-type field for SIG rdatas; the zone DB then filed every
    SIG rdataset under typepair (SIG, 0) instead of
    (SIG, covered_type) and follow-up adds collided at that bucket.
    Fixed to use dns_rdatatype_issig().

Both underlying bugs are still reachable via inbound zone transfer
(diff.c rdata_covers() runs from both dns_diff_apply on the IXFR path
and dns_diff_load on the AXFR path), so the type-helper fixes above
remain necessary.  For the dynamic-update path, the simplest and
safest posture is to refuse SIG and NXT outright at the front door in
ns/update.c, alongside the existing NSEC/NSEC3/non-apex-RRSIG
refusals.  KEY remains permitted because it is still used to carry
public keys for SIG(0) transaction authentication.

The existing tcp-self SIG regression test is repointed to assert
REFUSED on the SIG add, a symmetric NXT test is added, and the
SIG-via-dyn-update covers-bucket test is removed because it is no
longer reachable through this entry point; AXFR-based coverage of
diff.c rdata_covers() follows in a separate commit.

(cherry picked from commit 3a44a13232991ba054aa157a1c3ffb8376359b42)

6 weeks agoAdd regression test for SIG covers being dropped in dns_diff_apply
Ondřej Surý [Thu, 16 Apr 2026 09:16:40 +0000 (11:16 +0200)] 
Add regression test for SIG covers being dropped in dns_diff_apply

rdata_covers() in lib/dns/diff.c tests `type == dns_rdatatype_rrsig`
instead of dns_rdatatype_issig(), so for a legacy SIG (24) rdata it
returns 0 and the covered type is discarded on the dynamic-update /
IXFR path.  The zone DB then files every SIG rdataset under typepair
(SIG, 0) instead of (SIG, covered_type), and a follow-up add with a
different covers field but a different TTL collides at that bucket,
trips DNS_DBADD_EXACTTTL in qpzone, returns DNS_R_NOTEXACT, and comes
back to the client as SERVFAIL.

The new test adds a PTR to establish the node (tcp-self requires the
client IP's reverse form to equal the owner), then two SIG updates
with different covers and different TTLs; on a buggy build the second
update is SERVFAIL and named logs `dns_diff_apply: .../SIG/IN: add
not exact`.  The test is expected to pass once rdata_covers() is
switched to dns_rdatatype_issig(), matching the fix already adopted
for dns__db_findrdataset() on this branch and the helper pattern used
in master.c, xfrout.c, and qpcache.c.

(cherry picked from commit b9fc0e595b5f907654bc241efee5f942d57b7903)

6 weeks agoFix dropped covers field for SIG records in dns_diff_apply
Ondřej Surý [Thu, 16 Apr 2026 09:21:48 +0000 (11:21 +0200)] 
Fix dropped covers field for SIG records in dns_diff_apply

rdata_covers() in lib/dns/diff.c discriminated only on
dns_rdatatype_rrsig (46) and returned 0 for the legacy SIG (24), so
the covered-type field was silently discarded on the dynamic-update
and IXFR paths.  Every SIG rdataset was then filed in the zone DB
under typepair (SIG, 0) instead of (SIG, covered_type); a second SIG
add with a different covers but a different TTL collided at that
bucket, tripped DNS_DBADD_EXACTTTL in qpzone, returned
DNS_R_NOTEXACT, and came back to the client as SERVFAIL.

Use dns_rdatatype_issig() here so both SIG and RRSIG carry their
covers through the diff, matching the helper pattern already used in
lib/dns/master.c, lib/ns/xfrout.c, lib/dns/qpcache.c, and the
dns__db_findrdataset() REQUIRE that the surrounding merge request
just relaxed.

(cherry picked from commit 0a5ba57116857779680d76fe4b20e125f3bc3b71)

6 weeks agoAdd system test for SIG record handling in update-policy tcp-self
Ondřej Surý [Tue, 7 Apr 2026 14:40:36 +0000 (16:40 +0200)] 
Add system test for SIG record handling in update-policy tcp-self

Verify that a SIG record sent via TCP dynamic update is accepted
by the tcp-self update-policy and correctly stored in the zone.

(cherry picked from commit ecddeab6962fe7aab70ccaff56fab8f496316a9b)

6 weeks agoFix assertion failure in dns_db_findrdataset() for SIG records
Mark Andrews [Tue, 7 Apr 2026 14:39:57 +0000 (16:39 +0200)] 
Fix assertion failure in dns_db_findrdataset() for SIG records

dns__db_findrdataset() had a REQUIRE() that only accepted
dns_rdatatype_rrsig when the covers parameter was set.  A dynamic
update containing a SIG record (type 24) would trigger this
assertion, crashing named.  Use dns_rdatatype_issig() to accept
both SIG and RRSIG.

(cherry picked from commit 03edeccaa16991e05c101ae82a03568ae1b2dbd0)

6 weeks ago[9.20] fix: dev: Fix inverted gethostname() check in rndc status
Ondřej Surý [Fri, 17 Apr 2026 16:46:53 +0000 (18:46 +0200)] 
[9.20] fix: dev: Fix inverted gethostname() check in rndc status

The replacement of named_os_gethostname() with raw gethostname()
inverted the success check: the "localhost" fallback runs on success,
and on failure the uninitialized hostname buffer is read by snprintf(),
leaking stack memory via the rndc status reply.

Closes #5889

Backport of MR !11879

Merge branch 'backport-5889-fix-gethostname-inverted-check-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11881

6 weeks agoFix inverted gethostname() check in rndc status
Ondřej Surý [Fri, 17 Apr 2026 14:28:50 +0000 (16:28 +0200)] 
Fix inverted gethostname() check in rndc status

When named_os_gethostname() was replaced with raw gethostname(), the
success/failure polarity was flipped: the fallback to "localhost" now
runs on success and the hostname buffer is left uninitialized on
failure.  In the failure path, snprintf() then reads the uninitialized
stack buffer, disclosing stack contents via the rndc status reply.

(cherry picked from commit f7859247df222fa17a0ad52f8ce87816e06984ec)

6 weeks ago[9.20] chg: test: Reimplement xfer/ans5 using ControllableAsyncServer
Štěpán Balážik [Fri, 17 Apr 2026 15:16:41 +0000 (15:16 +0000)] 
[9.20] chg: test: Reimplement xfer/ans5 using ControllableAsyncServer

Backport of MR !11626

Merge branch 'backport-stepan/xfer-asyncserver-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11878