Security hole found in Rails 2.3's http_authentication.rb
The digest authentication helper in Rails 2.3 treated a nil password from the user lookup as a valid match when the request also carried a nil password, so a protected action returned 200 instead of 401. An attacker could reach pages meant to be protected by simply sending empty credentials.
n8.tumblr.com
Published on n8.tumblr.com
A hole that I believe could be a MAJOR deal for anyone using digest authentication in Rails 2.3 with the new httpauthentication.rb code and who followed the simple Digest example from the rdoc, or the blog entry introducing it.
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 password lookup returned nil for an unknown user, and the validation compared that nil with the nil password supplied in the request, treating the two as a match instead of failing.
Impact
Anyone could bypass digest authentication and view content that was supposed to be protected, as demonstrated on a live example site.
What the attacker needed
Rails 2.3 app using digest auth example; No valid credentials needed
The fix
The validation should return false when the password procedure returns nil, as the documentation already promised; the author supplied a patch but the text does not say it was merged.
How it was found
- Set up a Rails 2.3 controller using the documented digest authentication example.
- Send a request to the protected action with a nil username and nil password.
- Observe that the response is 200 and the protected content is returned instead of a 401.
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.
Digest authentication is a way for a web server to ask for a username and password without sending the password in clear text. The code that checked the password had a mistake: when it could not find the user, it got an empty value back and compared that empty value with the empty password in the request, so they matched. That let anyone open a protected page without real credentials.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.