mod_dav_fs: bound lock record fields to the fetched datum length - #776
Closed
arshsmith1 wants to merge 1 commit into
Closed
arshsmith1 wants to merge 1 commit into
arshsmith1 wants to merge 1 commit into
Conversation
Collaborator
|
Thanks for the PR, but we should be able to treat these DBM files as trusted input, trying to validate them will bring a lot of complexity and not a lot of value. The nspace handling fix is a special case to cope with with the specifics of the |
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_fs_load_lock_record() in modules/dav/fs/lock.c only checks offset < val.dsize once per top-level record, then reads each field of a fetched lock-database datum without confirming it fits; in the indirect-lock branch it reads ip->key.dsize out of the record and passes it straight to apr_pmemdup(p, val.dptr + offset, ip->key.dsize), so a truncated or corrupt record drives a read of attacker-influenced length past the end of the datum (the owner/auth_user apr_pstrdup() calls can walk past it too). The function already returns DAV_ERR_LOCK_CORRUPT_DB for an unknown type byte, but only after these reads happen. This adds a per-field size check (and a memchr NUL-termination check for the owner/auth_user strings) that routes short records to that same corrupt-DB error before any read, keeping offset <= val.dsize throughout and leaving well-formed records untouched. This mirrors the recent namespace-table hardening in the propdb reader.