Commit graph

14563 commits

Author SHA1 Message Date
Ondřej Surý
8330b49fb9
Use cryptographically-secure pseudo-random generator everywhere
It was discovered in an upcoming academic paper that a xoshiro128**
internal state can be recovered by an external 3rd party allowing to
predict UDP ports and DNS IDs in the outgoing queries.  This could lead
to an attacker spoofing the DNS answers with great efficiency and
poisoning the DNS cache.

Change the internal random generator to system CSPRNG with buffering to
avoid excessive syscalls.

Thanks Omer Ben Simhon and Amit Klein of Hebrew University of Jerusalem
for responsibly reporting this to us.  Very cool research!

(cherry picked from commit cffcab9d5f)
2025-10-02 13:53:14 +02:00
Mark Andrews
4c6d03b0bb
Retry lookups with unsigned DNAME over TCP
To prevent spoofed unsigned DNAME responses being accepted retry
response with unsigned DNAMEs over TCP if the response is not TSIG
signed or there isn't a good DNS CLIENT COOKIE.

To prevent test failures, this required adding TCP support to the
ans3 and ans4 servers in the chain system test.

(cherry picked from commit 2e40705c06)
2025-10-02 13:07:06 +02:00
Mark Andrews
cd17dfe696
Further restrict addresses that are cached when processing referrals
Use the owner name of the NS record as the bailwick apex name
when determining which additional records to cache, rather than
the name of the delegating zone (or a parent thereof).

(cherry picked from commit a41054e9e6)
2025-10-02 13:07:06 +02:00
Mark Andrews
025d61bacd
Tighten restrictions on caching NS RRsets in authority section
To prevent certain spoofing attacks, a new check has been added
to the existing rules for whether NS data can be cached: the owner
name of the NS RRset must be an ancestor of the name being queried.

(cherry picked from commit fa153f791f)
2025-10-02 13:07:06 +02:00
Ondřej Surý
7c5b8ef055
Fail the DNSSEC validation if matching but invalid DNSKEY is found
If a matching but cryptographically invalid key was encountered during
the DNSSEC validation, the key would be just skipped and not counted
towards validation failures.  Treat such DNSSEC keys as hard failures
and fail the DNSSEC validation immediatelly instead of continuing the
DNSSEC validation with the next DNSKEYs in the RRset.

Co-authored-by: Matthijs Mekking <matthijs@isc.org>

(cherry picked from commit f00117a422)
2025-10-02 12:32:45 +02:00
Mark Andrews
955874f0bc
re-split STATIC_ASSERT message
(cherry picked from commit ccc41c7044)
2025-09-29 13:08:24 +02:00
Mark Andrews
7b4315b7a6
re-split log message text
(cherry picked from commit a64c350523)
2025-09-29 13:08:24 +02:00
Mark Andrews
f866f7a1e8 Remove dns_rdataset_equals as unneeded
(cherry picked from commit 7d765a3514)
2025-09-11 08:27:50 +10:00
Mark Andrews
018ecbb0c8 Fix missing RRSIGs for "glue" lookups with CD=1
The code to test whether to store the RRSIGs on DNS_R_UNCHANGED
with CD=1 was failing because the comparison methods of the two
rdatatset instances were not compatible.  Move the testing into
dns_db_addrdataset(), and request it by setting the DNS_ADD_EQUALOK
option.  If the option is set and the old and new rrsets compare
as equal, dns_db_addrdataset() returns ISC_R_SUCCESS instead of
DNS_R_UNCHANGED.

(cherry picked from commit b954a1df43)
2025-09-11 08:27:50 +10:00
Mark Andrews
4a076fd0c0 Add support for parsing and displaying BRID rdata type
(cherry picked from commit 6b29da55fc)
2025-09-03 11:10:52 +10:00
Mark Andrews
3df5d60de8 Add support for parsing and displaying HHIT rdata type
(cherry picked from commit 37041c3ec3)
2025-09-03 11:10:51 +10:00
Mark Andrews
823e39a932 RPZ canonical warning displays zone entry incorrectly
Do not insert a NUL into ip_str too early as the full value
is needed later.  Only insert the NUL immediately before
displaying just the prefix string.

(cherry picked from commit 283da99f02)
2025-09-02 23:43:45 +00:00
Michał Kępień
6e3203a5b5
Deprecate the "tkey-domain" statement
Mark the "tkey-domain" statement as deprecated since it is only used by
code implementing TKEY Mode 2 (Diffie-Hellman), which was removed from
newer BIND 9 branches.
2025-09-01 22:04:28 +02:00
Michał Kępień
57271272d1 Deprecate the "tkey-gssapi-credential" statement
The "tkey-gssapi-keytab" statement enables GSS-TSIG to be set up in a
simpler and more reliable way than using the "tkey-gssapi-credential"
statement and setting environment variables (e.g. KRB5_KTNAME).

Mark the "tkey-gssapi-credential" statement as deprecated to eventually
only have one method for setting up GSS-TSIG in named.  Do not mention
"tkey-gssapi-credential" in the section of the ARM on dynamic updates.

(cherry picked from commit 6de435c528)
2025-09-01 19:34:19 +00:00
Ondřej Surý
8c97b56b2c
Add and use __attribute__((nonnull)) in dnssec-signzone.c
Clang 20 is complaining about passing NULL to an argument with 'nonnull'
attribute.  Mark these two functions with the same attribute to assure
that these two function also don't accept NULL as an argument.

(cherry picked from commit 9e350c1774)
2025-08-28 16:27:00 +02:00
Ondřej Surý
0cd65c605c
Don't preserve cache entries if new TTL is smaller than existing
Under certain circumstances, cache entries with equivalent rdataset
might not get replaced.  Previously such entry would get preserved
regardless of the new TTL and expire time on the existing header would
get updated when the expire time was less than the expire time on the
existing header.  Change the logic to preserve the existing header only
if the new expire time is larger than the existing one and replace the
existing cache entry when the new expire time is less than the existing
one.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
(cherry picked from commit 9f7ba584cf)
2025-08-26 21:34:08 +02:00
Ondřej Surý
d4c4edff1f
Preserve ZEROTTL attribute when replacing NS RRset
Previously, BIND 9 would drop the ZEROTTL attribute when updating
previously cached NS entry with ZEROTTL attribute set.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
(cherry picked from commit 982ca161c2)
2025-08-26 21:32:35 +02:00
Ondřej Surý
8339615235
Use ControlStatementsExceptControlMacros for SpaceBeforeParens
> Put a space before opening parentheses only after control statement
> keywords (for/if/while...) except this option doesn’t apply to ForEach
> and If macros. This is useful in projects where ForEach/If macros are
> treated as function calls instead of control statements.

(cherry picked from commit 42496f3f4a)
2025-08-19 08:10:58 +02:00
Ondřej Surý
a464171243
Add and apply InsertBraces statement
> Insert braces after control statements (if, else, for, do, and while)
> in C++ unless the control statements are inside macro definitions or
> the braces would enclose preprocessor directives.

(cherry picked from commit d051e1e8f8)
2025-08-19 08:09:59 +02:00
Mark Andrews
3ed407ac77 Use DNS_RDATACOMMON_INIT to hide branch differences
Initialization of the common members of rdata type structures varies
across branches. Standardize it by using the DNS_RDATACOMMON_INIT
macro for all types, so that new types are more likely to use it,
and hence backport more cleanly.
2025-08-14 22:42:01 +10:00
Mark Andrews
fbc8365395 Add support for parsing and displaying DSYNC rdata type
(cherry picked from commit c47615094e)
2025-08-06 13:51:43 +10:00
Mark Andrews
976b19e00c Add support for parsing DSYNC scheme mnemonics
Adds dns_dsyncscheme_fromtext, dns_dsyncscheme_totext and
dns_dsyncscheme_format.  Adds type dns_dsyncscheme_t.

(cherry picked from commit 6e1311c624)
2025-08-06 13:08:11 +10:00
Mark Andrews
74fab1887c validator.c:check_signer now clones val->event->sigrdataset
Spurious validation failures were traced back to check_signer looping
over val->event->sigrdataset directly.  Cloning val->event->sigrdataset
prevents check_signer from interacting with callers that are also
looping over val->event->sigrdataset.

(cherry picked from commit 8aa130f253)
2025-08-01 23:55:38 +10:00
Andoni Duarte Pintado
d9d8b64189 Merge tag 'v9.18.38' into bind-9.18 2025-07-16 17:20:53 +02:00
Mark Andrews
c0b1adb7e5 Digest type GOST is also deprecated
(cherry picked from commit 125a232bfb)
2025-07-16 10:42:35 +10:00
Mark Andrews
2db0806b6c Warn about deprecated DNSKEY and DS algorithms / digest types
DNSKEY algorithms RSASHA1 and RSASHA-NSEC3-SHA1 and DS digest type
SHA1 are deprecated.  Log when these are present in primary zone
files and when generating new DNSKEYs, DS and CDS records.

(cherry picked from commit cb6903c55e)
2025-07-16 09:14:22 +10:00
Ondřej Surý
1f73101cac
When overmem, clean enough memory when adding new ADB names/entries
The purge_stale_names()/purge_stale_entries() is opportunistic even when
we are under memory pressure (overmem).  Split the opportunistic LRU
cleaning and overmem cleaning.  This makes the stale purging much
simpler as we don't have to try that hard and makes the overmem cleaning
always cleanup double the amount of the newly allocated ADB name/entry.

(cherry picked from commit eb0ffa0d5f)
2025-07-11 14:49:28 +02:00
Petr Menšík
4f972095fe Add few extra WANT_QUERYTRACE logs into resume_qmin
Print optionally a bit more details not passed to event in case
dns_view_findzonecut returns unexpected result. Result would be
visible later in foundevent, but found fname would be lost. Print it
into the log.

(cherry picked from commit d2c6966232)
2025-07-09 11:13:23 +10:00
Petr Mensik
eeda00329f Handle CNAME and DNAME in resume_min in a special way
When authoritative zone is loaded when query minimization query for the
same zone is already pending, it might receive unexpected result codes.

Normally DNS_R_CNAME would follow to query_cname after processing sent
events, but dns_view_findzonecut does not fill CNAME target into
event->foundevent. Usual lookup via query_lookup would always have that
filled.

Ideally we would restart the query with unmodified search name, if
unexpected change from recursing to local zone cut were detected. Until
dns_view_findzonecut is modified to export zone/cache source of the cut,
at least fail queries which went into unexpected state.

(cherry picked from commit 2fd3da54f9)
2025-07-09 00:56:09 +00:00
Aram Sargsyan
65ba05bb68
Reset DNS_{GETDB_STALEFIRST,DBFIND_STALETIMEOUT} in ns__query_start()
In case of chained queries (e.g. CNAME) a discrepancy could arise
if the original query had the DNS_GETDB_STALEFIRST bit set, but
the next query doesn't have it (e.g. because the CNAME target is
a authoritative zone for the server) and cause an unanswered query
because of a logic error.

Reset both DNS_GETDB_STALEFIRST and DNS_DBFIND_STALETIMEOUT bits in
the ns__query_start() function before reevaluating whether they are
needed for the current query, and reset them again after calling
the query_lookup() function.
2025-07-03 14:24:55 +02:00
Mark Andrews
a6dba44b65 Use clang-format-20 to update formatting
(cherry picked from commit 422b9118e8)
2025-06-25 13:59:44 +10:00
Mark Andrews
523940c48e Preserve brackets in DNS_SLABHEADER_GETATTR macro
We need to turn off clang-format to preserve the brackets as
'attribute' can be an expression and we need it to be evaluated
first.

Similarly we need the entire result to be evaluated independent of
the adjoining code.

(cherry picked from commit 3620db5ea6)
2025-06-25 13:59:44 +10:00
Matthijs Mekking
5f589541bc Fix spurious missing key files log messages
This happens because old key is purged by one zone view, then the other
is freaking out about it.

Keys that are unused or being purged should not be taken into account
when verifying key files are available.

The keyring is maintained per zone. So in one zone, a key in the
keyring is being purged. The corresponding key file is removed.

The key maintenance is done for the other zone view. The key in that
keyring is not yet set to purge, but its corresponding key file is
removed. This leads to "some keys are missing" log errors.

We should not check the purge variable at this point, but the
current time and purge-keys duration.

This commit fixes this erroneous logic.

(cherry picked from commit d494698852)
2025-06-19 11:35:01 +02:00
Mark Andrews
4ff67b1889 Add CO support to dig
Dig now support setting the EDNS CO as flag using "+coflag" /
"+nocoflag" rather than as part of +ednsflags.

(cherry picked from commit 6c28411c55)
2025-06-13 20:39:17 +10:00
Mark Andrews
274077aeb9 Silence tainted scalar in client.c
Coverity detected that 'optlen' was not being checked in 'process_opt'.
This is actually already done when the OPT record was initially
parsed.  Add an INSIST to silence Coverity as is done in message.c.

(cherry picked from commit 72cd6e8591)
2025-05-29 23:10:13 +00:00
Nicki Křížek
1e5ae39430 Merge tag 'v9.18.36' into bind-9.18 2025-04-16 15:30:16 +02:00
Ondřej Surý
86673ee67a
Unify the int32_t vs int_fast32_t when working with atomic types
There's a mismatch between the atomic and non-atomic types that could
potentialy lead to a rwlock deadlock (after two billion 2^32) writes.
Use int_fast32_t when loading the atomic_int_fast32_t types in the
isc_rwlock unit.
2025-04-14 18:56:54 +02:00
Mark Andrews
2ee41c81fd Don't cache lack of EDNS based on received responses
Caching prevents server upgrades being detected in a timely manner
and it can also prevent DNSSEC responses being requested.

(cherry picked from commit 90b2f94d9b)
2025-04-03 12:44:21 +02:00
Aram Sargsyan
df0fe93fa5 Fix the resolvers RTT-ranged responses statistics counters
When a response times out the fctx_cancelquery() function
incorrectly calculates it in the 'dns_resstatscounter_queryrtt5'
counter (i.e. >=1600 ms). To avoid this, the rctx_timedout()
function should make sure that 'rctx->finish' is NULL. And in order
to adjust the RTT values for the timed out server, 'rctx->no_response'
should be true. Update the rctx_timedout() function to make those
changes.

(cherry picked from commit 830e548111)
2025-03-31 18:35:45 +00:00
Aram Sargsyan
9a3ba4856a Fix resolver responses statistics counter
The resquery_response() function increases the response counter without
checking if the response was successful. Increase the counter only when
the result indicates success.

(cherry picked from commit 12e7dfa397)
2025-03-31 18:35:45 +00:00
Evan Hunt
04d18f31ce
fix the fetchresponse result for CNAME/DNAME
the fix in commit 1edbbc32b4 was incomplete; the wrong
event result could also be set in cache_name() and validated().

(cherry picked from commit 9ebeb60174)
2025-03-26 12:04:07 +01:00
Evan Hunt
46e793a3b4
set eresult based on the type in ncache_adderesult()
when the caching of a negative record failed because of the
presence of a positive one, ncache_adderesult() could override
this to ISC_R_SUCCESS. this could cause CNAME and DNAME responses
to be handled incorrectly.  ncache_adderesult() now sets the result
code correctly in such cases.

(cherry picked from commit 1edbbc32b4)
2025-03-26 12:01:59 +01:00
Evan Hunt
4b81333567 Don't check DNS_KEYFLAG_NOAUTH
All DNSKEY keys are able to authenticate. The DNS_KEYTYPE_NOAUTH
(and DNS_KEYTYPE_NOCONF) flags were defined for the KEY rdata type,
and are not applicable to DNSKEY.

Previously, because the DNSKEY implementation was built on top of
KEY, the NOAUTH flag prevented authentication in DNSKEYs as well.
This has been corrected.

(cherry picked from commit 5c21576f82)
2025-03-25 00:04:34 -07:00
Evan Hunt
07b599748f Tidy up keyvalue.h definitions
Use enums for DNS_KEYFLAG_, DNS_KEYTYPE_, DNS_KEYOWNER_, DNS_KEYALG_,
and DNS_KEYPROTO_ values.

Remove values that are never used.

Eliminate the obsolete DNS_KEYFLAG_SIGNATORYMASK. Instead, add three
more RESERVED bits for the key flag values that it covered but which
were never used.

(cherry picked from commit fee1ba40df)
2025-03-25 00:04:31 -07:00
Artem Boldariev
d0907a3a1f TLS DNS: Simplify tls_cycle_input()
This commit simplifies code flow in the tls_cycle_input() and makes
the incoming data processing similar to that in TCP DNS. In
particular, now we decipher all the the incoming data before making a
single isc__nm_process_sock_buffer() call. Previously we would try to
decipher data bit-by-bit before trying to process the deciphered bit
via isc__nm_process_sock_buffer(). Doing like before made the code
much less predictable, in particular in the areas like when reading is
paused or resumed.

The newer approach also allowed us to get rid of some old kludges.
2025-03-24 09:49:38 +02:00
Aram Sargsyan
ac15d3dede Implement -T cookiealwaysvalid
When -T cookiealwaysvalid is passed to named, DNS cookie checks for
the incoming queries always pass, given they are structurally correct.

(cherry picked from commit 807ef8545d)
2025-03-17 12:01:42 +00:00
Mark Andrews
89e76eec70 Add missing locks when returning addresses
Add missing locks in dns_zone_getxfrsource4 et al. Addresses CID
468706, 468708, 468741, 468742, 468785 and 468778.

Cleanup dns_zone_setxfrsource4 et al to now return void.

Remove double copies with dns_zone_getprimaryaddr and dns_zone_getsourceaddr.

(cherry picked from commit d0a59277fb)
2025-03-16 15:26:12 +11:00
Mark Andrews
54c89f75f3 Implement digest_sig and digest_rrsig for ZONEMD
ZONEMD needs to be able to digest SIG and RRSIG records.  The signer
field can be compressed in SIG so we need to call dns_name_digest().
While for RRSIG the records the signer field is not compressed the
canonical form has the signer field downcased (RFC 4034, 6.2).  This
also implies that compare_rrsig needs to downcase the signer field
during comparison.

(cherry picked from commit 006c5990ce)
2025-03-05 10:34:52 +00:00
Aram Sargsyan
df373d7d99 Fix memory ordering for operations with quota->used and quota->waiting
Change all the non-locked operations on 'quota->used' and
'quota->waiting' to "acq/rel" for inter-thread synchronization. Some
loads are left as "relaxed", because they are under a locked mutex
which also provides protection.
2025-03-04 09:57:34 +00:00
Aram Sargsyan
80d7d11f37 Use relaxed memory ordering for quota->max and quota->soft
These variables are not critical for memory ordering issues
and we can use the relaxed memory ordering, as done in the
main branch.
2025-03-04 09:57:34 +00:00