Security Vulnerability Found in Heroku and Rails form_tag
Rails' form_tag helper automatically inserted the CSRF authenticity token into forms posting to external sites, so Heroku's single sign-on form sent the token to add-on providers. An attacker could collect the token and use it to perform actions on the victim's Heroku account, such as adding a collaborator.
benmanns.com
Published on benmanns.com
Update: Heroku's Official Response
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
Rails' form_tag helper inserted the CSRF authenticity token into all forms by default, including those posting to external domains.
Impact
An attacker could execute a CSRF attack on api.heroku.com on a targeted user's account and apps, but the attack requires the victim to add the malicious add-on or be added as a collaborator and then click a link.
What the attacker needed
Victim adds malicious add-on or is added as collaborator; victim clicks a link to the add-on SSO endpoint
How it was found
- Create a malicious add-on that collects the authenticity_token from incoming SSO requests.
- Add the malicious add-on to a victim's app (requires the victim to add it or be added as a collaborator).
- When the victim visits the add-on SSO endpoint, the authenticity_token is sent to the attacker.
- Use the stolen token to make authenticated requests to api.heroku.com, such as adding a collaborator.
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.
When you log into a website, it often gives your browser a secret token to prove who you are on each request. Rails, a web framework, automatically added this token to every form, even forms that send data to other websites. Heroku used such a form to log you into add-ons, so the token leaked to the add-on, and an attacker could use it to act as you.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.