Skip to content
Info disclosure Write-up Advanced

Disclosing information with a side-channel in Django

The dictsort filter in Django templates allowed sorting by arbitrary attributes, including password hashes, and by using a sorting oracle an attacker could extract sensitive information such as password hashes. An attacker could also invoke arbitrary methods without arguments, though with limitations.

Dennis Brinkrolf Follow

Published on sonarsource.com

Django is an open-source Python framework offering modular and reusable components to enable faster development cycles. These components also provide safe foundations for applications, with the core shipping mitigations against most web security mistakes with a strong default configuration.

Dennis Brinkrolf (@DBrinkrolf), on sonarsource.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The dictsort filter's _property_resolver allowed resolving arbitrary attributes and calling methods without arguments, including sensitive fields like password hashes, enabling a sorting oracle.

What the attacker needed

User-controlled sort parameter in template; Vulnerable Django version; At least 800 registered users for full extraction

The fix

The maintainers limited dictsort's _property_resolver to allow only dictionary and attribute lookups, preventing method calls and sorting by individual characters.

How it was found

  1. The attacker sends a request to sort users by the first character of their password hash, which is always 'p', so the order remains unsorted and serves as a baseline.
  2. The attacker sends a request to sort users by the second character of their password hash, observing the new order to group users by that character.
  3. The attacker repeats this for each subsequent character position, using the unsorted baseline to track users and assign them to groups.
  4. After n+1 requests, where n is the length of the hash, the attacker reconstructs the complete password hash for each user.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Django is a tool for building websites. A template filter called dictsort lets you sort lists by a chosen field. The bug was that it let you sort by any field, even secret ones like password hashes. By seeing how the sorted list changes, an attacker could figure out the secret values.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Dennis Brinkrolf

View all

1 more disclosed report, best first.

More from Django

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.