Skip to content

mod_dav: Fix dav_get_timeout() overflowing an attacker-controlled Tim… - #960

Merged
arturobernalg merged 1 commit into
apache:2.4.xfrom
arturobernalg:backport/httpd-65788-dav-timeout-overflow
Nov 7, 2026
Merged

arturobernalg merged 1 commit into
apache:2.4.xfrom
arturobernalg:backport/httpd-65788-dav-timeout-overflow

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

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


  • This PR does not report or address a security vulnerability
    (see SECURITY.md and
    https://www.apache.org/security/#reporting-a-vulnerability).
  • Code follows the httpd style guide.
  • New log messages (level debug or higher) use an empty APLOGNO() tag;
    numbers are assigned by a committer at merge time (see docs/log-message-tags/README).
  • If the change is user-visible, a changes-entries/*.txt file is included,
    following the template in README.CHANGES (not needed otherwise).
  • Test cases based on pyhttpd are included where appropriate, in the
    test/modules/xxx directory matching the modules/xxx module source,
    or test/modules/core for core server changes. On Unix, verify these
    pass locally with e.g. make check-pytest PYTEST_DIRS=test/modules/xxx.

…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
@arturobernalg
arturobernalg merged commit 03679d7 into apache:2.4.x Nov 7, 2026
34 checks passed
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.

2 participants