Commit graph

6922 commits

Author SHA1 Message Date
Matthijs Mekking
eed010c3a5 Also fix off by one error in system test
The system test was also subject to the same off by one bug that also
existed in the code. That is: if the inception time of the signature
is exactly equal to the inactive time of the key, we still have to
expect the signature.

(cherry picked from commit d9b6036e0f)
2026-04-07 08:32:58 +00:00
Matthijs Mekking
14be941e78 Add fast test case
This specific test case triggered a bug where the SKR included bundles
with unsigned DNSKEY RRsets (signatures where omitted because the
inception time was equal to the inactive time of the key).

(cherry picked from commit 784a441e2d)
2026-04-07 08:32:58 +00:00
Nicki Křížek
dcc78517be Rewrite xfer/ans11/ans.py to use AsyncDnsServer
Replace the hand-rolled threaded socket server with the standard
AsyncDnsServer framework used by other ans.py servers in the test suite.

The DNS wire-format message builders (IXFR diff, AXFR, SOA, SERVFAIL)
are retained unchanged since they produce carefully crafted messages
needed to trigger the IXFR->AXFR race condition. The server
infrastructure is replaced:

- Manual TCP/UDP socket management and threading replaced by
  AsyncDnsServer, which handles both protocols, pidfile lifecycle,
  and signal handling.
- Query parsing replaced by the framework's dns.message-based parser;
  query dispatch moved into IxfrRaceHandler.get_responses().
- The axfr_done_event threading.Event replaced by a boolean instance
  variable on IxfrRaceHandler, safe within the single asyncio event
  loop.
- For IXFR over TCP, the handler yields two BytesResponseSend actions
  (msg1 then msg2) so the framework sends both with TCP length prefixes,
  preserving the race-triggering sequence.
- For IXFR over UDP, the TC flag is set on the response to force TCP
  retry.
- Unused encode_name_compressed() and parse_dns_query() removed.

Also fix a timing issue that might result in the initial transfer not
being done by the time the test is executed -- since ns11 is started
after ns6. Ensure the initial transfer has happened before running the
ixfr_race test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 187e571f4d)
2026-04-03 12:05:44 +00:00
Aram Sargsyan
d1537583a7 Add a test to check for IXFR->AXFR race-condition
The test initiates a zone transfer with IXFR, which produces
a big amount of differences and then generates an error. The
secondary should be able to gracefully shutdown the ongoing
IXFR transfer and retry with AXFR without race conditions
between them.

This test checks for an issue (GL#5767) but since a race
condition is usually time-sensitive it might require several
attempts before it reproduces the issue.

(cherry picked from commit 5c248e7d1a)
2026-04-03 12:05:44 +00:00
Ondřej Surý
1be03f3a10 Add regression test for NSEC proof after unsigned-to-signed IXFR
Test that a secondary receiving an IXFR transitioning a zone from
unsigned to NSEC-signed returns the correct covering NSEC record
for empty non-terminal names.

Add isctest.query.wait_for_serial() shared helper for waiting until
a server has a specific SOA serial.

(cherry picked from commit 8a4990d6ff)
2026-04-03 04:34:20 +00:00
Matthijs Mekking
52abfa3e07 Test dnssec tools using zone file basename as origin
Add test cases where dnssec-signzone and dnssec-verify use the
zone file's basename as the origin when '-o' is omitted.

(cherry picked from commit 1251ae896c)
2026-04-01 23:08:14 -07:00
Nicki Křížek
2616cf7759 Remove license header files from _common test files
These are either config file or zone file snippets. Their license is
declared in REUSE.toml.

(cherry picked from commit 2390bd3a8f)
2026-03-31 17:09:20 +02:00
Ondřej Surý
4c33f83a45
Fix update-policy per-type max quota bypass via counter desynchronization
The prescan and main update loops in DNS UPDATE processing both used the
same counter to index the maxbytype[] quota array.  The prescan loop
always incremented the counter, but the main loop had 14 continue paths
that skipped the increment.  This allowed an authenticated DDNS client to
craft an UPDATE message with padding records (e.g. CNAME+A pairs that
trigger CNAME-conflict skips) to shift the counter and read wrong quota
entries, bypassing per-type record limits entirely.

Fix by incrementing the counter unconditionally at the start of each
iteration in the main loop.

(cherry picked from commit bac40394d5)
2026-03-30 11:11:46 +02:00
Aram Sargsyan
e3aa88080e Test an empty APL record as catalog zone ACL
Test that named can process an empty APL record as a valid catalog
zone ACL.

(cherry picked from commit b82966000e)
2026-03-27 12:38:01 +00:00
Michał Kępień
b1b3958eff Rename "nsec3-delegation" to "nsec3_delegation"
The "nsec3-delegation" test was added in a release branch, before commit
e40db975d9 introduced the current system
test naming convention.  Rename the test to comply with that convention.

(cherry picked from commit 48bf3d3e65)
2026-03-25 17:07:00 +01:00
Ondřej Surý
feb5dc7f98 Add regression test for TOCTOU race in DNS UPDATE SSU handling
Race rndc reconfig (toggling between allow-update and update-policy)
against a stream of DNS UPDATEs for 5 seconds and verify that named
does not crash.

Before the fix, the race between send_update() and update_action()
reading the SSU table independently could trigger an assertion
failure (INSIST) when the zone's update policy changed between the
two reads.

(cherry picked from commit c503b6eee8)
2026-03-25 16:16:22 +01:00
Michał Kępień
b040b566fe Merge tag 'v9.20.21' into bind-9.20 2026-03-25 14:24:13 +00:00
JINMEI Tatuya
f2115e9d58 ensure rndc modzone succeeds twice for a zone in named.conf
If a zone is in named.conf, not originally added by rndc addzone,
rndc modzone for that zone succeeds once, but subsequent modzone
attempts fail. This is because do_modzone removes the zone config
from global or view options, but it would fail due to 'not found'
once the config is removed.

The fix is to ensure re-adding the updated zone config to the
global or view options. This also works as a more complete fix
for the issue 85453d3 atempted to solve, ensuring rndc showzone
shows the latest config: it now works for multple attemps of
modzone, and with named that is not built with LMDB.

The change in this commit relies on UNCONST in a few places.
That's not clean, but 'add/mod/delzone' generally seems to
need it (for example, delete_zoneconf uses it to modify the list
of zones). In that sense, this change follows the convention
(for a longer term, there may have to be a better API so that we
can modify config obtions that were once parsed).
2026-03-25 09:38:16 +01:00
JINMEI Tatuya
2ec6f856e3 prevent named crash on rndc modzone for a zone in named.conf
If named is built without LMDB and has a zone in named.conf,
then rndc modzone for that zone triggers an assertion failure
unless there's already an NZF file. This is because load_nzf
doesn't create 'nzf_config' when NZF is missing, while a valid
nzf_config is assumed in do_modzone when it tries to add the
modified zone config to add_parser.

The crash is fixed by skipping the call to cfg_parser_mapadd when
nzf_config is NULL. Skipping it should be okay since the config stored
in add_parser would be needed only for subsequently deleting a zone by
rndc delzone when the zone was originally added by rndc addzone, but
in this case the zone was not 'added'. Checking if nzf_config is NULL
before using it also seems to be consistent with other parts of the
implementation.
2026-03-24 16:39:28 +01:00
Ondřej Surý
33d219bfe1 SKIP cache flush ordering on NTA expiry
dns_view_flushnode() was called in the delete_expired() async
callback, which runs after the query that detected the NTA expiry.
This created a race: the query would proceed with stale cached data
from the NTA period before the flush had a chance to run, resulting
in transient SERVFAIL with EDE 22 (No Reachable Authority).

Skip dns_view_flushnode() in the older branches as the solutions for
older branches are too complicated and this was not a critical bug.

(cherry picked from commit da8e1c956a)
2026-03-23 08:31:32 +00:00
Aram Sargsyan
5cfeda5981 Check that cached data is flushed when NTA expires
(cherry picked from commit ce98b71eb4)
2026-03-20 03:24:56 +01:00
Aram Sargsyan
22c3861df4 Backport the whole NTA test suite
The 9.20 branch was missing the new NTA test suite.  Backport it.
2026-03-20 03:24:56 +01:00
Nicki Křížek
e40db975d9 Rename all system test to use underscore
All system tests previously using a hyphen have been renamed to use
underscore instead. A couple of symlinks were corrected and one path in
`nsec3-answer` adjusted accordingly.

(cherry picked from commit 67aca1f8c6)
2026-03-18 15:36:50 +01:00
Nicki Křížek
4ae74863d1 Use underscore for system test names
Change the convention for system test directory names to always use an
underscore rather than a hyphen. Names using underscore are valid python
package names and can be used with standard `import` facilities in
python, which allows easier code reuse.

The temporary directories for test execution and their convenience
symlinks have been switched to using hyphens rather than underscores to
keep the pytest collection, filtering and .gitignore working as
expected.

(cherry picked from commit 9f4c1d1993)
2026-03-18 15:36:50 +01:00
Matthijs Mekking
60f63ce097 Test showzone and modzone on configured zone
Add test cases for 'rndc showzone' and 'rndc modzone' on a zone
that was configured in named.conf. This should not crash.

(cherry picked from commit 900127c460)
2026-03-17 09:51:18 +00:00
Ondřej Surý
e85af603df
Add system test using SIG(0) and ACL matching
This adds a system test to verify that asynchronous SIG(0)
validation correctly retains the ACL environment and network
addresses of the caller, preventing unauthorized ACL bypass
when evaluating match-clients and match-destinations.

(cherry picked from commit 613a93478b)
2026-03-13 13:49:48 +01:00
Aram Sargsyan
527ec95456
Test sending a TKEY query with deletion and unrecognized modes
This new test sends two signed TKEY queries, one in delegation
mode and one in an unrecognized mode to check that named
correctly processes them.

Co-authored-by: Nicki Křížek <nicki@isc.org>

(cherry picked from commit ab77b3dffa)
2026-03-13 13:39:38 +01:00
Nicki Křížek
b858e25438
Test excessive RRSIG(NSEC) in signed zones
Trigger a memory leak by adding extra RRSIG(NSEC) to a signed zone which
exceeds the resolver's configured max-records-per-type limit.

(cherry picked from commit a338e254be)
2026-03-13 13:22:23 +01:00
Nicki Křížek
05c51d3a5a
Reproducer for CVE-2026-1519
When a validating resolver processes a delegation from a DNSSEC-signed
zone which uses too many NSEC3 iterations, it should cease the attempt
to validate due to an NSEC3 iteration limit being exceeded and fall back
to insecure.

(cherry picked from commit 9bc14a89f1)
2026-03-13 13:06:38 +01:00
Michal Nowak
005aa31fd8 Bump xfer timeout to 30 seconds
Enabling ans6 responses and xfr-and-reconfig zone reload sometimes takes
more time on FreeBSD than the default timeout allows; bump it to 30
seconds.

(cherry picked from commit 77a7430a5f)
2026-03-10 13:25:05 +00:00
Nicki Křížek
1f6b58fa60 Log dnspython queries after .to_wire() is called
Some dns message modifications like TSIG happen only after .to_wire() is
called on the message. To ensure there isn't a discrepancy between what
has been logged and what has been sent, log the query after
dns.query.udp() is executed (which calls .to_wire() on the message).

Co-Authored-By: Štěpán Balážik <stepan@isc.org>
(cherry picked from commit a22e03f71b)
2026-03-09 12:12:41 +00:00
Colin Vidal
6d75e03971 add checkconf test with key defined inside a view
A configuration where a key was defined inside a view, then used in a
`primary` statement wasn't covered. This is now fixed.

(cherry picked from commit d8f46b09a7)
2026-03-01 13:41:53 +01:00
Colin Vidal
d85889710b
Add test coverage for nameserver processing limits
Introduce a new system test (nsprocessinglimit) to verify that the
resolver strictly respects outgoing network fetch quotas when presented
with heavily delegated, unresponsive zones.

This test acts as a regression check for the recent Fisher-Yates nameserver
selection refactor.  It sets up an authoritative server delegating a zone
to 23 distinct nameservers (all pointing to unresponsive loopback IPs).

Using dnstap, the test forces a resolution failure and verifies that:
1. The resolver successfully traverses the zone delegation path.
2. The resolver caps the outgoing network queries to the delegated
   nameservers exactly at the processing limit (20 fetches), ensuring
   array boundaries and dynamic fetch quotas are strictly enforced without
   crashing or hanging.

(cherry picked from commit 5274e764c4)
2026-02-26 08:17:23 +01:00
Štěpán Balážik
6e91738efe Replace deprecated typing imports
More specific modules (like collections.abc) can now be used.

Generated with: ruff check --extend-select UP035 --fix

(cherry picked from commit ced002c4ab)
2026-02-25 13:33:46 +01:00
Štěpán Balážik
c04b9251aa Clean up imports of dnspython modules
Add a pylint plugin that enforces:
  - There is no bare `import dns` statement.
  - All `dns.<module>` used are explicitly imported.
  - There are no unused `dns.<module>` imports.

Fix all the imports to conform with this check.

(cherry picked from commit d3186c7038)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
963ef9cb8e Replace Optional["T"] with "T | None"
In Python 3.10 strings don't support the | operator, so ruff doesn't
attempt to fix these. Quote the entire type specification to avoid the
typing.Optional import.

Alternatives I considered:
- leaving it as is (only use of Optional in the code base)
- using `from future import __annotations__` (replacing one import with
  another one)

(cherry picked from commit 1d5924c82f)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
17cf986396 Replace Optional[T] with T | None
Generated with: ruff check --extend-select UP045 --fix && black .

(cherry picked from commit fe38515ad0)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
89ce3b5e74 Remove the rest of Union usages by hand
These require some manual changes.

(cherry picked from commit cdb7428431)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
95f49d58b9 Replace Union[S, T] with S | T
Generated with: ruff check --extend-select UP007 --fix && black .

(cherry picked from commit ce9c9a1a9c)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
a7ef013f6d Built-in types are now subscriptable
Generated with: ruff check --extend-select UP006 --fix

(cherry picked from commit 790745da18)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
5fc2b9b2f3 Remove superfluous 'pylint: disable' directives
Some of these have been fixed already, fix the rest.

(cherry picked from commit 08f5e5ebd1)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
e5d5a6433c Remove unused imports
Generated with: ruff check --extend-select F401 --fix

(cherry picked from commit b00f16f026)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
af85bc2592 Set pytestmark explicitly in rollover* and nsec3* tests
Importing pytestmark confuses static analysis tools as they flag it as
unused.

(cherry picked from commit 7178c97e5c)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
99658ad4a1 Make default_algorithm accessible through a fixture and method
Importing pytest fixture trips up static analysis tools, so move
default_algorithm to conftest.py and use it instead of os.environ
accesses in various system tests.

For use outside test function, use Algorithm.default().

(cherry picked from commit ef21b77912)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
6e9e3b7208 Define __all__ in __init__.py files
Fix ruff's F401 unused-import errors in these files.

Also sort them with: ruff check --extend-select RUF022 --fix.

(cherry picked from commit 2b9c5ccd77)
2026-02-25 13:33:25 +01:00
Štěpán Balážik
746ca1d481 Automatically sort imports in Python code
Generated with: ruff check --extend-select I --fix (with the changes to
pyproject.toml applied).

(cherry picked from commit ffd5b6ac26)
2026-02-25 13:33:20 +01:00
Štěpán Balážik
d079305ba3 Remove unneeded pylint: disable=import-error
Paths are now correctly set up for pylint.
2026-02-25 13:15:05 +01:00
Štěpán Balážik
68b9928f0f Fix vulture warnings and tweak ignore lists
Run vulture on the whole repository, fix most errors in previously
unchecked code, adjust ignore lists.

(cherry picked from commit 57ecaee95d)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
5e6399411a Fix 'Too many return statements' pylint error
Refactor `Key.match_properties` into multiple functions.

(cherry picked from commit 19076c0d4d)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
50f6dcdc75 Fix pylint's 'invalid-name' errors
Where possible comply with the naming rules. Add exceptions for the
function names used in KASP tests.

(cherry picked from commit 50ed74197c)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
4f8d253d7a Set dist=loadscope for pytest in pytest.ini
Previously there was some handling of old pytest-xdist versions which is
no longer needed.

(cherry picked from commit c47b076494)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
a8911683d7 Fix the rest of 'Formatting a regular string which could be an f-string'
Some fixes have to be done manually.

(cherry picked from commit a384283497)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
eb9a93ebd5 Fix some 'Formatting a regular string which could be an f-string' errors
Generated with:
ruff check --select UP031,UP032 --fix --unsafe-fixes && black .

(cherry picked from commit df0be6b4bd)
2026-02-25 13:15:05 +01:00
Štěpán Balážik
d6247cad75 Fix 'Using deprecated class FileType of module argparse'
In preparation for running pylint on more Python code.
2026-02-25 13:15:05 +01:00
Štěpán Balážik
7dd6b4dc5b Fix 'Import should be placed at the top of the module'
In preparation for running pylint on more Python code.

(cherry picked from commit 4253d7298c)
2026-02-25 13:15:05 +01:00