Skip to content

mod_dav: Fix NULL pointer dereference in ms_wdv.c check_locked_by_other() - #883

Closed
arturobernalg wants to merge 2 commits into
apache:trunkfrom
arturobernalg:fix/httpd-70051-dav-mswdv-null-deref
Closed

arturobernalg wants to merge 2 commits into
apache:trunkfrom
arturobernalg:fix/httpd-70051-dav-mswdv-null-deref

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Both goto out paths in check_locked_by_other() (modules/dav/main/ms_wdv.c) that fire before open_lockdb() runs leave lockdb at its NULL initializer, and the out label dereferenced it unconditionally:

out:
    (*lockdb->hooks->close_lockdb)(lockdb);

A DAV request whose dav_get_resource() or open_lockdb() call fails crashes the worker with a NULL pointer dereference. The most reliable trigger is a request to a URL whose last filesystem-resolvable component is a file plus extra path components, under DAVMSext WDV.

The sister function mswdv_combined_lock() a few hundred lines below already guards the same call (if (lockdb) (*lockdb->hooks->close_lockdb)(lockdb);), so this fix mirrors that existing pattern.

Also adds a regression test (test_dav_mswdv_null_deref in test/pytest_suite/tests/t/modules/test_dav.py, plus DAVMSext All on the test directory): PUT a resource, then PUT past it with an extra path component, and confirm the server returns a clean DAV error and is still alive afterwards. Verified it fails with a connection reset against the pre-fix code and passes against this fix.

PR: https://bz.apache.org/bugzilla/show_bug.cgi?id=70051

  • 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).
    (N/A, no log messages added.)
  • If the change is user-visible, a changes-entries/*.txt file is included,
    following the template in README.CHANGES (not needed otherwise).
    (Not needed - one-line NULL-guard fix, no behavior change on the success path.)
  • Test cases based on pyhttpd are included where appropriate.
    (Added: test_dav_mswdv_null_deref in test/pytest_suite/tests/t/modules/test_dav.py.)

…er().

Both goto out paths before open_lockdb() runs leave lockdb at its NULL
initializer, and the out label dereferenced it unconditionally. A DAV
request whose dav_get_resource() or open_lockdb() call fails (e.g. a
PUT/DELETE/MOVE/LOCK to a URL with extraneous path components under
DAVMSext WDV) crashes the worker. Guard the call like the existing
pattern in mswdv_combined_lock() a few hundred lines below.

PR: 70051
Enables DAVMSext on the pytest_suite mod_dav test directory and adds
test_dav_mswdv_null_deref: PUT a resource, then PUT past it with an
extra path component so dav_get_resource() fails before any lockdb is
opened, and confirm the server returns a clean DAV error instead of
crashing, and is still alive afterwards.

Verified this reproduces the bug: against the pre-fix check_locked_by_other()
the test fails with a connection reset (the worker segfaults); against
28c8dbd it passes.

PR: 70051
@arturobernalg
arturobernalg force-pushed the fix/httpd-70051-dav-mswdv-null-deref branch from 791d449 to b3b929a Compare October 25, 2026 04:53
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.

1 participant