Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
permissions:
contents: read

# Actions are pinned by commit, not by tag: a tag can be moved to other code,
# and these steps run with the repository checked out. The comment on each
# line names the release the commit belongs to.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -23,12 +27,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -52,12 +56,12 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
# The whole history, so the base commit of the PR is present.
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v5
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.13"
- name: Check commit authorship
Expand All @@ -71,10 +75,10 @@ jobs:
# Live DNS: without a bound, a hang runs to the 6-hour default.
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
- run: uv python install 3.13
- run: uv sync --all-extras --python 3.13
- name: Full suite (live DNS + DNSSEC), 100% statement and branch coverage enforced
Expand All @@ -84,10 +88,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
- run: uv python install 3.13
- name: Build sdist and wheel
run: uv build
Expand All @@ -107,7 +111,7 @@ jobs:
uv run --no-project python -m zipfile -l "${wheels[0]}" \
| grep -q 'recursive_resolver/py.typed' \
|| { echo "py.typed missing from the wheel"; exit 1; }
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: dist
path: dist/
160 changes: 160 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,166 @@ All notable changes to this project are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2026-11-16

A security release, with breaking API changes. Three defects in DNSSEC
validation let an attacker able to answer for a signed zone, on-path or by
spoofing, have forged data accepted: twice as authenticated, once by
downgrading the zone to unsigned. None needs a key of the zone; each reuses a
genuine, public record or field out of place. Upgrade before relying on a
`SECURE` verdict, or on a signed zone being treated as signed, from 0.2.0.

### Security

- An unsigned CNAME beside a genuine signed DNAME decided where the
redirection went, and the answer came back `SECURE` whatever its target.
The CNAME is now always synthesised from the DNAME (RFC 6672 §3.4) and the
server's is ignored.
- A wildcard's NSEC record, replayed under another owner name, proved NODATA
(`_dmarc.example.` has no TXT) or NXDOMAIN as authenticated: its signature
verifies under any name below the wildcard's parent. A denial record now
counts only with a signature made for its own owner name.
- An RRSIG signer field naming any unsigned delegation in a signed zone sent
the chain-of-trust walk there, and that zone's genuine "no DS" proof was
applied to the name being judged: forged referrals, NXDOMAIN and NODATA
came back `INSECURE` instead of `BOGUS`, and the forged delegation was
cached. The signer must now contain the name being judged.
- A DS set listing a supported and an unsupported algorithm could be
downgraded to unsigned by a forged DNSKEY answer keeping only the
unsupported key. Whether a zone is verifiable is now read off the signed DS
RRset (RFC 4035 §5.2), and a SHA-1 DS is ignored beside a stronger one
(RFC 4509 §3).
- Only the first eight DS records of a zone were considered, and the order of
an RRset is not signed: with eight that this build cannot check sent first,
the zone read as unsigned whatever followed. Records that cannot be checked
are now set aside before the cap applies.
- An unsigned delegation could stay cached past the proof that it is
unsigned, and every delegation below it was cached for its own NS TTL.
`min_ttl` no longer lifts one past that proof, and the proof now counts
when it arrived in a DS response of its own, for the delegations below the
cut, and across lookups resumed from the cache, as do the TTLs of its NSEC
or NSEC3 records and the time spent resolving glueless nameservers before
the delegation is cached.
- A signature that verified earlier in a resolution is checked for expiry
again before that verdict is reused.
- Validated DNSKEY and DS records were cached for their wire TTL, up to a day,
with a 60 second floor, past the expiry of their signatures. They are now
capped like any authenticated data (RFC 4035 §5.3.3), so a rollover or an
emergency revocation takes effect.
- An unauthenticated NXDOMAIN hid every name below it (RFC 8020) for up to an
hour: one broken server or spoofed packet for `_domainkey.example.` hid
every DKIM selector. Only an authenticated NXDOMAIN covers its subtree now,
as in Unbound.
- A packet from any address reaching the resolver's ephemeral port aborted
the query in flight. It is now ignored, as wrong-ID packets already were.
- CNAME and DNAME redirections were accepted without the AA bit.
- A TCP response with TC set was used as complete.
- The child apex's own NSEC3 could prove its parent publishes no DS; the NSEC
path already refused this.
- A lame zone, whose servers all refuse or fail, drew 44 to 64 queries per
lookup to its own servers: its in-zone NS names were re-resolved through
the same servers, recursively, and SERVFAIL sweeps were quadratic in the
number of servers. It now costs about one query per server, and reports
`ServfailError` instead of a budget error.
- dnspython 2.9.2 or later is required. Earlier releases are affected by
CVE-2026-114605 (CPU exhaustion on crafted name compression, reachable from
any nameserver a lookup reaches) and CVE-2026-128089. See SECURITY.md.

### Fixed

- Every name in `root-servers.net` failed with
`DNSSECMaterialUnavailableError`. The root servers serve that zone but not
`net`, and the chain of trust was only ever asked of them. A referral they
send to the zone whose keys or DS proof is needed is now followed.
- Glueless NS names are resolved two at a time, as far as needed, rather than
all thirteen in both address families before the first query, and an
address family the host cannot reach is given up for the rest of the
resolution without being charged. With `ipv4_only=False` on a host without
IPv6, `www.gov.uk`, `login.microsoftonline.com` and `aws.amazon.com` ran out
of query budget; in the default mode `www.gov.uk` cost 44 queries and now
costs 24.
- With validation on, servers that cannot do EDNS were unreachable even for
unsigned zones. Plain DNS is now the last rung of the downgrade ladder
wherever the chain of trust is not secure.
- An NXDOMAIN is confirmed by one sibling server, not two, and a response
with no signature in a signed zone is retried on one sibling, not on all of
them. Sibling retries no longer count against `max_depth`.
- `Answer.cname_chain` repeated names and differed between a cold and a warm
lookup. It now lists each redirected name once, in order.
- Cached CNAMEs are followed for any record type, so a warm lookup of a name
behind a CNAME costs no upstream query.
- A server failure or DNSSEC failure is remembered for 5 seconds (RFC 9520).
- DS answers sent in referral form, with the DS and its RRSIG in AUTHORITY,
validate instead of reading as unsigned.
- Algorithms dnspython refuses to validate (RSAMD5, DSA) are unverifiable, so
such zones are `INSECURE` per RFC 8624 rather than `BOGUS`. Hosts whose
crypto policy refuses SHA-1 signatures (the RHEL 9 family) treat
algorithms 5 and 7 the same way.
- `dnssec=True` with a `cryptography` too old for dnspython's DNSSEC support
failed every lookup as an attack. It is now refused at construction with
`DNSSECUnavailableError`.
- The whole-call deadline is a hard cap: a TCP retry gets what is left of it,
and a caller that waited out its time on an identical concurrent lookup no
longer starts a full resolution of its own.
- A negative answer with no SOA is not cached (RFC 2308 §5).
- No reachable nameserver is a `ServfailError`, not a timeout, and
`ServfailError` says what failed rather than always "SERVFAIL".
- `--trace` reports the exception a failed resolution ended with, and marks
the step whose response failed validation `bogus`; `-v` logs every query.
- `--text` escapes control characters and bytes that are not UTF-8 instead of
writing them to the terminal, where they could crash a strict encoding.
- Rejected glue is logged at DEBUG: the zone chooses it, so at WARNING a
hostile zone could write a log line per referral.
- Exceptions survive pickling, so they cross process pools and task queues.
- `"example.com "` is stripped rather than resolved with a trailing `\032`,
and `"@"` is refused rather than resolved as the root. A relative
`dns.name.Name` with no room for the root label raises `InvalidNameError`
rather than dnspython's `NameTooLong`.
- `Answer.ttl` behind a CNAME counts the time spent resolving its target.
- "Network unreachable" for one server no longer rules out its whole address
family for the rest of the lookup once a server of that family has
answered.
- `scripts/mutation_check.py` reported every mutant as caught by the unit
suite, in 0.2.0 too: one test module could not be imported from the copy it
runs in, and under `-x` pytest exits 1 for that as it does for a failed
test. It now leaves that module and the live-DNS tests out, and requires
both suites to pass on an unmutated copy first. Run for real, four entries
survived, and two more gaps showed in the EDNS fallback; all six have tests.
- `scripts/verdict_harness.py` counted a reference's SERVFAIL as a bogus
verdict even when it persisted with checking disabled, so one public
resolver failing to reach a flaky zone read as "they say bogus".

### Changed

- Python 3.10 is no longer supported: dnspython 2.9 requires 3.11. The
`dnssec` extra requires `cryptography>=50`, as dnspython 2.9 does.
- `RecursiveResolver`, `DNSCache` and `Limits` take keyword arguments only,
and out-of-range values (`timeout`, `max_depth`, `max_retries`, the limits)
raise `ValueError`.
- A resolver built with `dnssec=False` reports `ValidationState.DISABLED`
rather than `INSECURE`, which claimed a zone had been checked.
- `Answer.dnssec` has no default.
- `trace_answer()` returns a `Trace`, a list of `TraceStep` with an `error`
attribute; code that unpacks it as a list keeps working.
- `RRSIG` cannot be queried with validation on: it has no signature of its
own, so the answer was always `BOGUS`.
- `QueryBudgetExceededError` for the signature and NSEC3 limits has `qname`
`None` rather than the placeholder `"<dnssec>"`.
- GitHub Actions in CI are pinned by commit, and the release script pins
`build`, `twine` and Hatchling and refuses to run on a dirty tree. The sdist
now ships `TESTING.md` and the `Dockerfile`.

### Added

- `resolve()`, `resolve_answer()`, `resolve_rrset()` and `trace_answer()`
accept a `dns.name.Name` and a `dns.rdatatype.RdataType` as well as text.
- `ResolverError.query_name` and `query_type`: the query passed to
`resolve()`, where `qname` can be a CNAME target or a nameserver hostname.
- `Trace`, exported from the package.
- Python 3.15 in the CI matrix.
- Thirty-two entries in the mutation catalogue, covering the fixes above that
it can express, for 84 in all.

## [0.2.0] - 2026-09-03

A security release. Four defects in DNSSEC validation allowed forged data to be
Expand Down
18 changes: 12 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ the file header and add a row to `THIRD-PARTY.md`.
bailiwick, AA, class and address rules each exist because a specific attack or
real-world failure was observed. `CHANGELOG.md` records which.
- **Keep dnspython exceptions inside the resolver.** Everything raised out of
the public API must be a `ResolverError`. Bare `except Exception` is not
a resolution must be a `ResolverError`; only invalid constructor arguments
raise `ValueError`. Bare `except Exception` is not
acceptable in the query path: it is what previously turned malformed input
into phantom network timeouts.
- Unit tests must not touch the network. Use the builders in `tests/conftest.py`
Expand Down Expand Up @@ -149,14 +150,18 @@ because `dig +short` does not validate either.
The script is interactive and every step is a y/N gate, so you can read what it
found before continuing. It:

1. checks the tree is clean, the two version strings agree, the changelog has an
entry and the tag does not already exist;
1. checks the two version strings agree, the changelog has an entry and the tag
does not already exist, and refuses to go on with uncommitted changes: the
artifacts are built from the working tree, and the tag it prints names
`HEAD`;
2. runs `make check-all`;
3. builds the sdist and wheel **inside Docker**, so the host never needs `pip`,
`build` or `twine`, and runs `twine check`;
`build` or `twine`, and runs `twine check`. `build`, `twine` and the
Hatchling backend are pinned at the top of the script; bump them there
deliberately;
4. inspects the artifacts against what this package promises: `py.typed`
present, no tests or scripts in the wheel, LICENSE bundled, and the
`dnspython` floor at or above the 2.8.0 security floor with the `dnssec` and
`dnspython` floor at or above the 2.9.2 security floor with the `dnssec` and
`idna` extras. It reads these out of the built wheel's `METADATA`, not out
of `pyproject.toml`, so a build that lost them is caught;
5. uploads to TestPyPI, then installs from there in a throwaway container and
Expand Down Expand Up @@ -200,4 +205,5 @@ a release:
- Trust anchors: <https://data.iana.org/root-anchors/root-anchors.xml>

Only anchors that are currently valid belong in the file: retired ones (such as
KSK-2010, tag 19036) must be removed, not kept "just in case".
KSK-2010, tag 19036) must be removed, not kept "just in case". KSK-2017 (tag
20326) is scheduled for revocation on 2027-01-11 and is the next to go.
Loading
Loading