Skip to content
CSRF Disclosed report Beginner

don't store CSRF tokens in cookies

The web application stored the CSRF token in a cookie as well as in a request header. If an attacker could intercept or compromise the cookie, they would also obtain the CSRF token, potentially allowing them to forge requests.

0x0ameer Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 25 days

Your web application generates CSRF token values inside cookies which is not a best practice for web applications as revelation of cookies can reveal CSRF Tokens as well. Authenticity tokens should be kept separate from cookies and should be isolated to change operations in the account only.

More description: This report tells that the CSRF tokens are present inside of the cookies value which is not a best practice and if the cookie is intercepted and compromised than the CSRF token will also be vulnerable.

This is the Captured request of edit Statement HTTP ,In this request you can see CSRF token is generating in cookies named as csrf_token

POST /~[MY USER ID]/statement.json HTTP/1.1 Host: gratipay.com User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:46.0) Gecko/20100101 Firefox/46.0 Accept: application/json, text/javascript, /; q=0.01 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-CSRF-Token: y44PyqG67bRQljEA5mLK1bez4hgZ8XSD X-Requested-With: XMLHttpRequest Referer: https://gratipay.com/~ameerassadi4/ Content-Length: 24 Cookie: csrf_token=y44PyqG67bRQljEA5mLK1bez4hgZ8XSD; suppress-welcome=; session=aa5c93be733b4aae8370af6a3fae2be3 Connection: close

lang=en&content=sssssssd

i have also added a PoC picture in attachments,

Cheers, Ameer Assadi www.Ameeras.me / www.Geekurity.com

Attachments

notsafe.png
notsafe.png From the original on HackerOne

The original report as published on HackerOne, by 0x0ameer. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

Likely the application reused the same value for the CSRF token and a cookie, so the token was not kept separate from automatically sent cookie data.

Impact

If an attacker can intercept or otherwise compromise the cookie, they could obtain the CSRF token and potentially forge state-changing requests, though the report does not demonstrate a full attack.

What the attacker needed

Attacker can intercept or compromise the cookie

The fix

The CSRF token should be kept separate from cookies and isolated to change operations in the account only.

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 report has not been written yet. The Original tab links to the source.

A CSRF token is a secret code a website puts in forms to make sure a request really came from its own pages, not from an attacker's site. Here the same secret was also stored in a cookie, which is a small piece of data the browser sends automatically. If someone steals that cookie, they also get the secret, so the protection is weakened.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More by 0x0ameer

View all

1 more disclosed report, best first.

More from Gratipay

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.