Skip to content

Use serial number arithmetic for RRSIG validity times - #1413

Merged
rthalley merged 3 commits into
rthalley:mainfrom
TochusC:fix/rrsig-time-rollover
Nov 6, 2026
Merged

rthalley merged 3 commits into
rthalley:mainfrom
TochusC:fix/rrsig-time-rollover

Conversation

@TochusC

@TochusC TochusC commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

RFC 4034 §3.1.5 requires RFC 1982 serial number arithmetic for comparisons involving the 32-bit RRSIG inception and expiration fields. The current validator compares these fields directly with Unix time, so it rejects an otherwise valid signature whose validity interval crosses the rollover.

For example, a signature with inception 0xfffffff0 and expiration 0x00000020 is valid at Unix times 0xffffffff and 0x100000001. Both calls to validate_rrsig() currently raise ValidationFailure("expired").

This change uses dns.serial.Serial for both comparisons. It accepts the exact inception and expiration instants and preserves the fractional-second expiration check. Comparisons at the undefined half-range boundary fail the time check. Non-finite validation times raise ValidationFailure.

The regression test signs an RRset and exercises both sides of the rollover, both inclusive endpoints, fractional times just outside the interval, and the undefined half-range comparison. The test reproduced the false rejection before the change. The local offline suite passed with 1,645 tests passing and 131 skipped. Black, Ruff, Pyright, and ty also passed.

RFC 4034 §3.1.5 · RFC 4035 §5.3.1 · RFC 1982 §3.2

@jschlyter

Copy link
Copy Markdown
Contributor

Good catch!

Do we need to add special test cases given that RFC 4034 §3.1.5 states "As a direct consequence, the values contained in these fields cannot refer to dates more than 68 years in either the past or the future." ?

@TochusC

TochusC commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the comment. I added tests for both inception and expiration at the 68-year boundary and one second inside it.

@rthalley
rthalley merged commit 3cdceba into rthalley:main Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants