Repository navigation
fix(gentime): reject out-of-range dates and zone offsets - #600
Merged
Merged
Conversation
parse_gentime() did not range-check the fields of a Generalized Time
string, so timegm()/mktime() silently normalized them and visudo
reported "parsed OK". A typo in a NOTAFTER (or sudoNotAfter) value
could extend a time-limited rule, e.g.
NOTAFTER=20260230235959Z -> expires March 2 (no February 30)
NOTAFTER=20269999999999Z -> expires in 2034
Reject month, day (including days that do not exist in the month),
hour, minute, second and time zone offset values outside the ranges
allowed by RFC 4517. Leap days and leap seconds are still accepted,
and so is 24:00:00 as the end of the day (ISO 8601), which already
meant 00:00:00 of the next day; any other hour 24 is rejected. Add
the corresponding check_gentime cases.
A sudoers rule with such a date is now a syntax error: with the
default error_recovery that rule is skipped, with error_recovery=false
the file is rejected. An LDAP entry with such a date is treated as
expired, as for any other invalid sudoNotBefore/sudoNotAfter value.
millert
approved these changes
Nov 20, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, producing an error is probably better than normalizing the values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parse_gentime()does not range-check the fields of a Generalized Time string;timegm()/mktime()silently normalize them, so a typo inNOTBEFORE/NOTAFTER(orsudoNotBefore/sudoNotAfter) moves the time window andvisudodoes not complain.Reproduction (there is no February 30):
NOTAFTER=20269999999999Zis accepted too and expires in 2034.With this change:
Month, day (including days that do not exist in the month), hour, minute, second and zone offset values outside the RFC 4517 ranges are rejected. Leap days, leap seconds and
24:00:00as the end of the day (ISO 8601, which already meant 00:00:00 of the next day) are still accepted; any other hour 24 is rejected.Compatibility: a sudoers rule with such a date becomes a syntax error, so with the default
error_recoverythat rule is skipped, and witherror_recovery=falsethe file is rejected. An LDAP entry with such a date is treated as expired, as for any other invalidsudoNotBefore/sudoNotAftervalue.Testing: 21 new
check_gentimecases;make checkpasses (47 suites, built with-fsanitize=address,undefined).Found by comparing
parse_gentime()against an RFC 4517 specification over an exhaustive set of boundary values.