Skip to content
Info disclosure Write-up Intermediate

Ransacking your password reset tokens

The Ransack library in Ruby on Rails, when used with default configuration, allows attackers to brute-force sensitive attributes of associated database objects via search parameters. This can lead to extraction of password reset tokens and full account takeover, as demonstrated on fablabs.io.

Lukas Euler Follow

Published on positive.security

In its default configuration, Ransack will allow for query conditions based on properties of associated database objects. An application is potentially vulnerable if it exposes a search/filtering function which processes an unrestricted query object, usually represented by a Ruby hash constructed via the q GET…

Lukas Euler, on positive.security

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

Impact

An attacker could extract sensitive information such as password reset tokens and fully compromise the application, as demonstrated by gaining superadmin access on fablabs.io.

What the attacker needed

Rails app using Ransack with default config; Public search endpoint accepting q parameter; No allow list for searchable attributes

How it was found

  1. Find a search endpoint that passes user input directly to Ransack.
  2. Identify an association chain from the searchable model to a sensitive attribute (e.g., password reset token).
  3. Use the *_start matcher to guess the first character of the token by observing if results are returned.
  4. Extend the guessed prefix character by character until the full token is recovered.
  5. If the token is case-insensitive, brute-force the case distribution separately.
  6. Use the recovered token to reset the victim's password and log in.

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.

Ransack is a tool that helps Rails applications search their databases. If not configured securely, it lets attackers guess secret values (like password reset codes) one character at a time by asking the search 'does this start with X?' and seeing if any results come back. This can let them take over accounts.

What is Info disclosure?

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

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.