Commit graph

16395 commits

Author SHA1 Message Date
Aydın Mercan
a531f00a75
wipe hmac keys correctly pre-3.0 libcrypto
A lingering `sizeof` from the prototype era of !11094 caused the
key-wipe in `isc_hmac_key_destroy` to use `sizeof(key->len)` instead of
`key->len` for the length argument of `isc_safe_memwipe`.

This results in a buffer overflow of zero bytes in HMAC keys that are
less than 4 bytes. As such, the overflow can only be visibile in keys
that are less than 32-bits, which is beyond broken and creating such
keys are only possible in testing.

Therefore, this change is *not* a security fix since the conditions are
never reachable in any imaginable deployment scenario.

Builds that use OpenSSL >=3.0 are unaffected as the `sizeof` was only
remaining in pre-3.0 builds.
2026-02-06 14:14:43 +03:00
Aydın Mercan
ecb677658f
don't transform errors in hmac_sign
The change from DST_R_OPENSSLFAILURE to ISC_R_CRYPTOFAILURE seems to be
benign. Furthermore it should a bug to rely on the exacts crypto failure
code.
2026-02-02 11:50:14 +03:00
Aydın Mercan
19c9053a6b
use isc_ossl_wrap to generate epheremal tls keys 2026-02-02 11:50:14 +03:00
Aydın Mercan
b748651bb0
explicitly set ec points properties in pre-3.0 openssl
Generating a P-256 key in pre-3.0 wasn't explicitly using uncompressed
named curves in DNSSEC but was when generating an epheremal TLS key.
2026-02-02 11:50:14 +03:00
Aydın Mercan
251af02fe7
make generate_pkcs11_ec_key consistent with others 2026-02-02 11:50:14 +03:00
Aydın Mercan
c2f3a23a3e
expose isc__crypto_md in isc/ossl_wrap.h
This is a bit of a namespace convention violation but it fits the spirit of
this header since it is exposing OpenSSL-isms to others.

Further work is needed to make sure the exposed EVP_MD isn't needed
anymore.
2026-02-02 11:50:14 +03:00
Aydın Mercan
21f80a2bd7
make isc_ossl_wrap_ecdsa_set_deterministic consistent with style 2026-02-02 11:50:14 +03:00
Aydın Mercan
8c69fedc7c
switch away from ossl_param builders from ecdsa functions 2026-02-02 11:50:14 +03:00
Aydın Mercan
fe617aa830
set parameters in batch for rsa keygen
On top on improving readability, doing so allows us to use a uint32_t
for setting the e value, getting rid of allocating an unneccessary
BIGNUM.
2026-02-02 11:50:14 +03:00
Aydın Mercan
3bd3754994
remove libcrypto version specific code in opensslecdsa_link
Using `EVP_SIGNATURE` explicit algoritms for signatures have been added
in OpenSSL 3.4 and so is skipped for the initial OpenSSL version
specific code splitting.
2026-02-02 11:50:14 +03:00
Aydın Mercan
f4d88404e2
remove libcrypto version specific code in opensslrsa_link
Using `EVP_SIGNATURE` explicit algoritms for signatures have been added
in OpenSSL 3.4 and so is skipped for the initial OpenSSL version
specific code splitting.
2026-02-02 11:50:14 +03:00
Aydın Mercan
f21d237374
move openssl error reporting to isc/ossl_wrap
While being the best place at the time, the tlserr2result doesn't belong
inside TLS code since it is generic to OpenSSL and mostly used in the
dst interface. The newly created ossl_wrap interface is the idea place
for flushing the OpenSSL thread error queue.
2026-02-02 11:50:14 +03:00
Aydın Mercan
c4a25e633c
add openssl_wrap
The isc_ossl_wrap API is intended to separate OpenSSL version specific
code that needs to expose the libcrypto internals and keep isc_crypto
clean.
2026-02-02 11:50:14 +03:00
Aydın Mercan
5ae9b4d14c
cleanup unused header in isc/md.h
Use `isc/crypto.h` whenever needed instead.
2026-02-02 11:50:14 +03:00
Aydın Mercan
8f106f2b66
Separate isc_hmac between pre and post OpenSSL 3.0
Instead of the `EVP_MD_CTX` based functions, use either the new
`EVP_MAC` or the old `HMAC_CTX` based functions.

`EVP_MAC` is the recommended way using using MAC functions in post-3.0
while `HMAC_CTX` is used internally by `EVP_MD_CTX`, making the latter
redundant.
2026-02-02 11:50:14 +03:00
Aydın Mercan
f9ec4a1cdf
switch isc_md_type_t to a proper enum
Get rid of the OpenSSL-isms that plague the codebase where the hash type
is `EVP_MD *`

By using a proper enum, alongside the cleanup, we also get the ability
to use constants for known hash sizes instead of having a function call
every time.

`EVP_MD_CTX_get0_md` has been removed instead of being adapted since it
wasn't used anymore.
2026-02-02 11:12:55 +03:00
Aydın Mercan
35eeefb437
initial openssl version splitting
Dealing with OpenSSL has been rapidly turning into an unwieldy situation
as post-3.0 changes turn the library into a different beast.

Start treating pre and post-3.0 versions differently for easier
maintenance.
2026-02-02 11:12:53 +03:00
Colin Vidal
d0d4b40b62 dns_rdataset_* const parameters
dns_rdataset_clone() now have a const source rdataset. Also,
dns_rdataset_isassociated() also takes a const rdataset.
2026-01-30 19:33:42 +01:00
Mark Andrews
5843289550 Use isc__zero_or_more when calling isc_base64_tobuffer 2026-01-28 00:25:04 +11:00
Mark Andrews
62fd89d4a1 Use isc_one_or_more when calling isc_base64_tobuffer 2026-01-28 00:25:04 +11:00
Mark Andrews
7feb0f5b53 Use isc_one_or_more when calling isc_hex_tobuffer 2026-01-27 23:57:34 +11:00
Mark Andrews
07610f8566 Add enum for use with isc_base64_tobuffer and isc_hex_tobuffer
This adds the following enum isc_one_or_more and isc_zero_or_more
which specify if one or more or zeror or more bytes are required
when reading the unbounded base64 / hex encoded data.
2026-01-27 23:57:34 +11:00
Aram Sargsyan
31290eccb1 Fix a bug in zone_loaddone()
The zone_loaddone() function disables database notifications for
a catalog zones and response policy zones (RPZ) when loading had
failed. Howerer, the 'result != ISC_R_SUCCESS' check is insufficient,
because the DNS_R_SEENINCLUDE result also indicates success.

Add a second condition for the "if" block.
2026-01-27 11:31:15 +00:00
Mark Andrews
10366e4f4e Remove extraneous space at start of brid and hhit records 2026-01-27 16:05:29 +11:00
Mark Andrews
bdb9c838a8 Fix isc_base64_tobuffer call for brid and hhit
Zero length records were not being rejected.
2026-01-27 16:05:24 +11:00
Mark Andrews
3180e50459 dsync_from struct produced an invalid record
uint16_tobuffer was used instead of uint8_tobuffer when adding the
scheme to the buffer.  This produced a record that was one octet
too long.  This has been fixed.
2026-01-24 00:38:51 +11:00
Matthijs Mekking
24aa490a9b Lower case the NSEC next owner name when signing
When building the NSEC rdata, lower case the next owner name before
storing it in the Next Domain Name Field.

Note that this is not required according to RFC 6840, Section 5.1:

  When canonicalizing DNS names (for both ordering and signing), DNS
  names in the RDATA section of NSEC resource records are not converted
  to lowercase.  DNS names in the RDATA section of RRSIG resource
  records are converted to lowercase.

  The guidance in the above paragraph differs from what has been
  published before but is consistent with current common practice.
  Item 3 of Section 6.2 of [RFC4034] says that names in both of these
  RR types should be converted to lowercase.  The earlier [RFC3755]
  says that they should not.

Since there is inconsistency in the documents over time, having
uppercase next owner names in the NSEC records may cause validation
failures if validators are not implementing RFC 6840.

Also, RFC 4034 section 6.2 is not about how NSEC record content is
created, but how RRset content is normalized in order to produce and
validate RRSIG records for a given RRset. Since the next owner name
of the NSEC record is about ordening, and the canonical DNS name order
requires that uppercase US-ASCII letters must be treated as if they
were lowercase US-ASCII letters, case is not meaningful for NSEC
next owner names, as it cannot be compressed on the wire, so we may
lowercase the next owner name in the NSEC rdata before signing, being
more kind to validators.
2026-01-23 11:52:59 +00:00
Matthijs Mekking
b68069f275 Refactor dns_kasp_attach/detach
Replace implementation with ISC_REFCOUNT_IMPL.
2026-01-23 09:59:52 +00:00
Colin Vidal
bc1a66a1d0 resolver: add comment when recursing
When a fetch result gets a delegation, `rctx_referral()` sets the
`rctx->get_nameserver = true`, which tells the resolver to retry another
server, not because of an error with the current server, but simply to
follow the delegation.

Update the comment of `rctx_nextserver()` which is quite confusing here
(as it's not immediately obvious from the code how we recurse when
getting a delegation back from a query).

Also add a log line, which helps figuring out this is happening.
2026-01-22 07:31:00 +01:00
Colin Vidal
6e63d5d02a fix resolver query response doc
In case on positive response, the `rctx_authority_positive()` function
is called to scan the AUTHORITY section to find NS servers and related
RR (glues) to be cached.

The doc says the function was called `rctx_authority_scan()`, but it is
called `rctx_authority_positive()`.
2026-01-22 07:31:00 +01:00
Nicki Křížek
3d91b5c451 Merge tag 'v9.21.17' 2026-01-21 14:35:17 +00:00
Aram Sargsyan
d48df6b084 Remove qpzone.c:first_existing_header_indirect() which had bugs
The first_existing_header_indirect() static function is used only
in one place and it has bugs:

1. It doesn't advance the pointer and can cause an infinite loop
   if it doesn't break out from the loop on the first iteration.
2. It doesn't check if the header EXISTS, though its name indicates
   that it should.
3. Even if the infinite loop bug is fixed, it would eventually
   return the last checked header's pointer even if all the
   candidates do not match the criteria of the selection.

Instead of fixing it, remove the function and use simpler code in
the place where it was being called.
2026-01-21 10:47:17 +00:00
Mark Andrews
af379e10cc Use const pointer with strchr of const pointer
C23 now has qualifier preserving standard functions for strchr,
bsearch, strpbrk, strrchr, strstr, memchr.  There where a few places
where the return value was not assigned to a const qualified pointer.
These have been fixed.
2026-01-20 16:23:58 +11:00
Colin Vidal
e8b0d4749c rename dns_view_findzonecut() into dns_view_bestzonecut()
`dns_view_findzonecut()` is used only in the context where the closest
name servers for a name need to be queried.  In the future, this API
will also return the glues (if known) for those name servers, as well
as (exclusively, if both NS and DELEG exist) the DELEG record.

To avoid ambiguities with other code flows using `dns_db_findzonecut()`,
`dns_view_findzonecut()` has been renamed into `dns_view_bestzonecut()`.
2026-01-16 07:52:56 +01:00
Colin Vidal
18d6b94c1f remove sigrdataset from dns_view_findzonecut()
Since the `sigrdataset` "output" parameter of `dns_view_findzonecut()`
is never used (always called with NULL), it is now removed.

Also, since the resolver is moving towards a parent-centric direction,
there is no point having a signature for the NS record (which is not
authoritative in the parent, so never signed) in the contextes where
`dns_view_findzonecut()` is called.
2026-01-15 19:48:30 -08:00
Aram Sargsyan
6f4b5d6958 Make catalog zones' entry names case-insensitive
Previously, the isc_ht hash table module was case-sensitive, but now
it supports case-insensitive mode. Use the case-insensitive mode
for the catalog zones' entry names.
2026-01-12 12:58:57 +00:00
Aram Sargsyan
0e0ba06dbf Make catalog zone names case-insensitive
Previously, the isc_ht hash table module was case-sensitive, but now
it supports case-insensitive mode. Use the case-insensitive mode
for catalog zone names.
2026-01-12 12:58:57 +00:00
Colin Vidal
e0d7bddc6c simplify usage of dns_view_findzonecut()
As `dns_view_findzonecut()` only returns either ISC_R_SUCCESS or
DNS_R_NXDOMAIN, and since it automatically disassociates the rdatasets
in case of failure, some call sites are simplified.
2026-01-08 20:26:32 +01:00
Colin Vidal
0f121224ec findzonecut: helper function to choose zone or cache
When a delegation is found at a zone level, the cache is also looked up,
in case a more specific delegation is found. If it is, then the records
from the zone are disassociated and then associated with those from the
cache.

There is no return value, because even if the cache lookup fails, there
is a valid delegation from the zone, so this is a success either way.

The main function `dns_view_findzonecut()` is also strongly refactored,
as `findzonecut_zoneorcache()` allows a sequential flow between the
various DB lookup attempts, instead of jumping back to the begining of
the lookup code using `goto`.

From the caller's point of view, the API is slightly simplified: the
return value can only be ISC_R_SUCCESS (a delegation is found) or
DNS_R_NXDOMAIN (no delegation is found). Also, if no delegation is
found, this guarantees that the rdatasets passed as parameter are
disassociated.
2026-01-08 20:26:32 +01:00
Colin Vidal
e71b9e03a8 findzonecut: helper function for zone lookup
Move the zone lookup code into a separate helper function.

The main extra change here is the return codes. This helper function can
return 3 (and only those 3) values:

- ISC_R_SUCCESS: a delegation is found
- DNS_R_NXDOMAIN: no zone matches the qname
- ISC_R_NOTFOUND: a zone is found, but no delegation in the zone (this
  can be either because there is simply no delegation, or for other
  reasons, like, the zone DB is not loaded yet).

This enables the caller to make decisions about whether to attempt a
cache and/or hints lookup or not.
2026-01-08 20:26:32 +01:00
Colin Vidal
1b54ff1efb findzonecut: helper function for cache lookup
Extract the cache lookup implementation from `dns_view_findzonecut()`
into a separate helper function.

Also, when the cache result is not ISC_R_SUCCESS (which is the only
"success" value from the existing code in this case), the return value
is overriden to DNS_R_NXDOMAIN. This enables the caller (in follow-up
commit) to differentiate the case where a zone is found, but for
whatever reason, no delegation is in there, from the case where no zone
is found. Separating those cases enables the caller to know whether it
needs to hit the cache/hints or not.
2026-01-08 20:26:32 +01:00
Colin Vidal
1b68638448 findzonecut: helper function for hints lookup
Extract `view_dns_findzonecut()` hints lookup parts in a separate
helper function.
2026-01-08 20:26:32 +01:00
Alessio Podda
78588981df Remove rrset-order cyclic from the default config, with shim
Currently we add an rrset-order cyclic statement to the default config.
Since the rrset-order allows matching a subset of all names, it must
be implemented with a string comparison against a wildcard, and since
the statement applies per rrset, this can result in millions of
comparisons per second on a busy authoritative server.

This commit removes rrset-order from the default config, but adds back
a code shim in query_setorder to preserve the previous behaviour.
2026-01-08 14:43:04 +01:00
Mark Andrews
14e299995f Fix incorrect length checks for BRID and HHIT records
Fix incorrect length checks in the towire_*() methods for BRID and HHIT
records to prevent assertion failures when trying to serve short
records.
2026-01-08 10:45:18 +01:00
Colin Vidal
4cf2efc97a small refactor for max-query-restart in check.c
Use the `check_range_uint32()` function in `check.c` to test the
boundaries of `max-query-restart` instead of custom code.
2026-01-07 07:01:59 +00:00
Colin Vidal
fe326a8c2f enforce bounds of multiple configuration options
The configuration options `edns-version`, `edns-udp-size`,
`max-udp-size`, `no-cookie-udp-size` and `padding` now enforce
boundaries. The configuration (including when using `named-checkconf`)
now fails if those options are out of range.
2026-01-07 07:01:59 +00:00
Giulio Benetti
0e43f62c12 Fix building on uclibc
While building on uclibc this error is thrown:
In file included from ./include/dns/log.h:20,
                 from callbacks.c:19:
../../lib/isc/include/isc/log.h:141:9: error: unknown type name ‘off_t’
  141 |         off_t maximum_size;
      |         ^~~~~

This is due to missing include unistd.h, so let's add it on top of
isc/log.h

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
2026-01-04 15:14:10 +01:00
Matthijs Mekking
52c940551d Change notify-cds option to notify-cfg CDS
Change the notify configuration to be more flexible for other types
of generalized DNS notifications.

Also allow for notify-cfg SOA.
2025-12-29 10:06:16 +01:00
Matthijs Mekking
7fd1eccb6e Change zone set/get options related to notify
Add a type to all dns_zone_(get|set) functions that apply to sending
notifies, so the options can be set and retrieved separately per type.

This affects dns_zone_setnotifydefer, dns_zone_getnotifydefer,
dns_zone_setnotifydelay, dns_zone_getnotifydelay,
dns_zone_setnotifysrc4, and dns_zone_setnotifysrc6.

The functions dns_zone_getnotifysrc4 and dns_zone_getnotifysrc6 are
unused and can be removed.
2025-12-29 09:43:04 +01:00
Mark Andrews
d1f3e92ffa Tidy up (fixed)names in dsyncfetch_start
Use a static dns_name_t for the "_dsync" label.  Remove some
unnecessary dns_fixedname_t variables.  Remove unnecessary dsyncname
dns_name_t from dns_dsyncfetch and rename dns_fixedname_t fname to
dsyncname.
2025-12-22 13:31:09 +11:00