Repository navigation
mod_authn_socache: Make the cache key injective to keep protection spaces apart - #1064
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
…aces apart. construct_key() joined the context, provider, auth type, user and realm with a ':' delimiter. A field that itself contains a ':' -- a client supplied Digest or form username, or a realm -- could shift a field boundary, so two distinct (user, realm) tuples produced the same cache key. A credential cached for one protection space could then be returned for a request in another, letting a request authenticate as a different user. RFC 9110 section 11.5 scopes credentials to their protection space, so the key must be injective: join each field with its byte length prefixed. * modules/aaa/mod_authn_socache.c (construct_key): Length-prefix each field when building the key. * test/modules/aaa/test_017_authn_socache_dbd_key.py: New test for the cross-realm collision, using mod_authn_dbd so the backing store keeps user and realm apart and only the cache key is under test. test/modules/aaa/env.py (AAATestSetup): Load mod_authn_dbd and mod_dbd. PR: 70332 Reported by: saku0512sec@gmail.com
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.
Bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=70332
construct_key()in mod_authn_socache built the socache key by joining the context, provider, auth type, user and realm with a:delimiter. A field that itself contains a:(a client-supplied Digest or form username, or a realm) can shift a field boundary, so two distinct(user, realm)tuples map to the same key. A credential cached for one protection space is then returned for a request in another, so a request can authenticate as a different user. RFC 9110 section 11.5 scopes credentials to their protection space, so the key must be injective.Fix: join each field with its byte length prefixed.
This is a trunk-only regression: the AuthName/realm was added to the key by #930 and the auth type by #1049. 2.4.x does not put them in the basic/form key and is not affected. #930 was committed by jorton, so a review from the socache maintainers would be welcome.
Test:
test/modules/aaa/test_017_authn_socache_dbd_key.pyreproduces the cross-realm collision over Digest + mod_authn_dbd (the database keeps user and realm in separate columns, so only the cache key is under test). It fails on trunk (the attack returns 200) and passes with the fix (401); the existingtest_016_authn_socachesuite still passes.No CHANGES entry: the regression has not shipped in a release; happy to add one if preferred.