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

            Bug ID: 70332
           Summary: trunk: mod_authn_socache delimiter collision can
                    authenticate a request as another user
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: mod_authn_socache
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 40277
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=40277&action=edit
Reproduce a mod_authn_socache delimiter-collision authentication bypass.

Trust-boundary impact:

Credentials presented by clients are untrusted. On current trunk,
credentials valid for one user in one Form authentication area can be
accepted as a different user in another protection space.
mod_authn_socache constructs cache keys by concatenating variable-length
fields with raw colon delimiters, so distinct username/realm tuples can
produce the same key.

Affected component and revision:

Apache/2.5.1-dev at current upstream trunk commit
3de5bf5db32b656f0db2875be275c540f057b703. The server and all loaded
modules came from the same unmodified standard build.

The ambiguous key format was introduced by
b3e1ac2edad3d6aa58e73a2a1068e11e494a8649 and extended by
9c70606411d1ff9cc1976edfc51ffe0e98da600d. These changes correspond to
GitHub PR #1049, based on PR #930.

Collision:

context=shared, provider=dbd, type=form,
user=victim:admin, AuthName=zone

context=shared, provider=dbd, type=form,
user=victim, AuthName=admin:zone

Both serialize as:

shared:dbd:form:victim:admin:zone

Configuration and preconditions:

Both protection spaces use AuthFormProvider socache dbd, one shared
AuthnCacheContext, and the same database table and query. Sharing a named
context across a directory tree backed by one credential source is a
documented use of AuthnCacheContext. The attacker controls the
colon-containing lower-privilege username victim:admin and its password.
The target protection space uses AuthName "admin:zone".

Reproduction:

Run authn_socache_form_key_collision_poc.py against a complete current
trunk installation, passing the server binary, module directory, and
mod_authn_socache DSO from that same build.

Observed on current trunk:

baseline victim/lowpass:             401 Unauthorized
baseline victim/highpass:            200 OK
prime victim:admin/lowpass:          200 OK
target victim/lowpass after priming: 200 OK

The final response contains the protected target resource. Debug logging
shows the cache entry stored for victim:admin, retrieved for victim, and
Require user victim granted.

Stable-release negative control:

The exact PoC was also run against an unmodified build of Apache HTTP
Server 2.4.71 from the official source archive, after verifying its
published SHA-256 checksum:

baseline victim/lowpass:             401 Unauthorized
baseline victim/highpass:            200 OK
prime victim:admin/lowpass:          200 OK
target victim/lowpass after priming: 401 Unauthorized

The 2.4.71 log shows a cache miss for victim followed by DBD rejecting
lowpass. The exact issue is therefore a trunk-only regression.

Expected behavior:

The two identities must occupy different cache entries. victim/lowpass
must remain unauthorized in the target protection space, and DBD must
validate it against victim's real password hash.

Actual behavior:

After the attacker primes the colliding entry, socache validates
lowpass against victim:admin's cached hash while the request identity
remains victim. Authorization then grants Require user victim.

Root cause:

construct_key() in modules/aaa/mod_authn_socache.c concatenates context,
provider, normalized AuthType, username, and realm with ":" without
escaping or length-prefixing. The serialization does not preserve field
boundaries.

Security impact:

A remote attacker with a suitably named lower-privilege account can
authenticate as a different target user and satisfy target-user
authorization rules. This can disclose protected resources and permit
actions available to the target account. Exploitation requires the
stated username, AuthName, shared-context, and live-cache preconditions.

Suggested fix:

Use an injective cache-key representation, such as explicit byte lengths
for every field, and add this collision as a regression test.

Proof of concept:

authn_socache_form_key_collision_poc.py

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to