Repository navigation
mod_dav: Fix dav_get_timeout() overflowing an attacker-controlled Tim… - #960
Merged
arturobernalg merged 1 commit intoNov 7, 2026
Conversation
…eout value. dav_get_timeout() parses a "Timeout: Second-<N>" header with atol(), which has no overflow detection. A long enough digit string overflows it, and the later "now + expires" addition overflows time_t too, so the lock ends up stored with a nonsensical (already-expired) timeout instead of the large-but-finite one the client asked for -- a LOCK request that looks successful (200, a valid Lock-Token) silently grants a lock that is already expired. Fix: parse with apr_strtoi64() (overflow-checked via errno), and clamp to 2^32 - 1 on overflow or on an in-range value above that maximum. A negative value clamps to 0, and a value with no digits at all clamps to 0 too, matching what atol() already silently did for that input. Also guard against the RFC 4918 maximum itself not fitting a 32-bit time_t, capping "now + sec" against DAV_TIME_T_MAX. This backports the trunk fix (f33eb04, PR apache#920) to 2.4.x. Trunk had already split this into dav_get_timeout()/dav_get_timeout_string(); 2.4.x has no such split, so the fix is applied directly in the single dav_get_timeout() function instead. PR 65788
notroj
approved these changes
Nov 7, 2026
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.
dav_get_timeout() parses a "Timeout: Second-" header with atol(), which has no overflow detection. A long enough digit string overflows it, and the later "now + expires" addition overflows time_t too, so the lock ends up stored with a nonsensical (already-expired) timeout instead of the large-but-finite one the client asked for -- a LOCK request that looks successful (200, a valid Lock-Token) silently grants a lock that is already expired.
Fix: parse with apr_strtoi64() (overflow-checked via errno), and clamp to 2^32 - 1 on overflow or on an in-range value above that maximum. A negative value clamps to 0, and a value with no digits at all clamps to 0 too, matching what atol() already silently did for that input. Also guard against the RFC 4918 maximum itself not fitting a 32-bit time_t, capping "now + sec" against DAV_TIME_T_MAX.
This backports the trunk fix (f33eb04, #920) to 2.4.x. Trunk had already split this into dav_get_timeout()/dav_get_timeout_string(); 2.4.x has no such split, so the fix is applied directly in the single dav_get_timeout() function instead.
BZ: https://bz.apache.org/bugzilla/show_bug.cgi?id=65788
(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.