- Status Closed
-
Assigned To
cbay - Private
Opened by waloodi_109 - 25.08.2025
Last edited by cbay - 25.08.2025
FS#205 - csrftoken not unique to session or specific user and csrfmiddlewaretoken can be altered
Hello Team
I hope you are doing well. While Researching in your domain, I found csrftoken not unique to session or specific user and csrfmiddlewaretoken can be altered issue in https://admin.alwaysdata.com
Steps to Reproduce:
1: A post request will be sent /api/tokens/delete/302 or /api/tokens/delete/some_number and i see in burp that in the cookie's header csrftoken = vhHMjvtks3jwGkHikbY48d5gQR76yvPA and i see in the params sent that csrfmiddlewaretoken= 8b9QkWMZgnqohp9R77Tu4m46PQW0YZRwtiGsth59ygzKNzGZh8Ho2pZcvxTWmkwW
what i noticed is that changing csrfmiddlewaretoken's value to csrftoken 's value will still make the request work..
ie setting csrfmiddlewaretoken = vhHMjvtks3jwGkHikbY48d5gQR76yvPA will still let the request work.
2: I noticed that the csrftoken sent in requests is not unique to the session id or user logged , meaning if im logged in as user1 and have csrftoken=x then i can login as user2 and send the request with csrftoken=x and csrfmiddlewaretoken=x and it will work!
what does this mean?
3.this means csrfmiddlewaretoken does not really add another layer of protection, i can easily change it the csrftoken stored in the cookie and it will still work
4. given a valid csrftoken from any user (for example csrftoken=c7wq7XJaQq71Eump3tVwNJpOSHLbiqSC), its possible to create a csrf request that sends the POST /api/tokens/delete/index request (where index can be enumerated ) with this valid csrftoken being sent as the csrfmiddlewaretoken value and with
X-CSRF-Token set also as the valid csrf token as well and it will work and we can manage to delete user api tokens through csrf exploit( for example clicking on a website that sends such request).
Note:
First account user csrftoken can be used to remove second account api token.
Thank You,
Waleed Anwar
Loading...
Available keyboard shortcuts
- Alt + ⇧ Shift + l Login Dialog / Logout
- Alt + ⇧ Shift + a Add new task
- Alt + ⇧ Shift + m My searches
- Alt + ⇧ Shift + t focus taskid search
Tasklist
- o open selected task
- j move cursor down
- k move cursor up
Task Details
- n Next task
- p Previous task
- Alt + ⇧ Shift + e ↵ Enter Edit this task
- Alt + ⇧ Shift + w watch task
- Alt + ⇧ Shift + y Close Task
Task Editing
- Alt + ⇧ Shift + s save task
Hello,
This is perfectly normal, you can read how CSRF protection is done with Django, the framework we use.
Kind regards,
Cyril
you mean that, first user crsftoken should be used to remove api token of second user?
first account user csrf token should be used as a csrfmiddlewaretoken for a second user and csrfroken also
The CSRF token is only used to prevent CSRF attacks. It is not unique per user or session.
but, its making a sense user one can use their csrf token to remove second user api
Reference: https://hackerone.com/reports/2513333
Any Update??
csrftoken and csrfmiddlewaretoken are different as you can see, but I can use csrftoken and csrfmiddlewaretoken as same as you can watch in the video.