Skip to content

[2.4.x] mod_authn_socache: Make the cache key injective to keep protection spaces apart - #1142

Merged
arturobernalg merged 1 commit into
apache:2.4.xfrom
arturobernalg:backport/1064-24x
Dec 1, 2026
Merged

arturobernalg merged 1 commit into
apache:2.4.xfrom
arturobernalg:backport/1064-24x

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Backport of #1064 (trunk 753762d).

2.4.x does not have the provider and auth type fields that trunk added to the key (b3e1ac2, 9c70606), so only the context, user and realm are length-prefixed. The test is the same as on trunk; without the fix test_019_03 fails on 2.4.x.

BZ 70332

…aces apart.

construct_key() joined the context, 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_019_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.

Backport of trunk 753762d (apache#1064).  2.4.x does not have the provider
and auth type fields of the trunk key (b3e1ac2, 9c70606), so only
the context, user and realm are length-prefixed.

PR: 70332
Reported by: saku0512sec@gmail.com

(cherry picked from commit 753762d)
@arturobernalg
arturobernalg merged commit e13af7e into apache:2.4.x Dec 1, 2026
36 of 37 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