Ruby on Rails — ransack
The user search endpoint passed Ransack parameters straight through, validating only that the key ended in _cont and never checking which attribute was searched. An attacker could therefore query the admin's password_digest with substring matches and use the yes/no result count as a blind oracle to rebuild the hash character by character.
Published on medium.com
Target: http://challenge01.root-me.org:59097 Stack: Ruby on Rails, search powered by the Ransack gem.
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
Likely the search action allowed any attribute ending in _cont to reach Ransack, so a sensitive column such as password_digest could be used as a substring predicate.
Impact
An attacker could reconstruct the administrator's full password hash and then crack it offline to recover the plaintext password.
What the attacker needed
Reachable user search page; an admin account visible in results
The fix
The search action should whitelist the attributes that may be searched rather than only checking the predicate suffix, so sensitive columns such as password_digest can never be used as predicates.
How it was found
- Open the /users search page and note the admin account from the Roles column.
- Find the commented-out advanced_search link in the page source and request it, which returns a 500 error exposing controller code.
- Send invalid parameters to /users to trigger an exception that reveals the predicate-only validation.
- Search with first_name_cont set to the admin's first name plus password_digest_cont set to a guessed substring.
- Use the presence or absence of the admin in results to confirm or reject each candidate substring.
- Extend the known substring left and right, or automate it, until 32 hexadecimal characters are recovered.
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.
The site's search box is built by a library called Ransack, which lets you search on any database column by naming it in the request. The code only checked that the parameter name ended in a certain suffix, so a user could ask whether the admin's stored password hash contained a given piece of text. Each search returned either one result or none, which is enough to guess the hash one character at a time.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.