ciur / papermerge

Open Source Document Management System for Digital Archives (Scanned Documents)
https://papermerge.com
Apache License 2.0
2.55k stars 267 forks source link

Potential security issue #390

Closed oomb closed 9 months ago

oomb commented 3 years ago

Hello,

A potential security issue was found in this repository and was reported via huntr.

Kindly look into the issue here and validate it.

This link is private and will be only accessible to the project maintainers.

Thanks!

ciur commented 3 years ago

@oomb, thank you for opening this issue. I will have a look.

ciur commented 3 years ago

Here is how to reproduce the vulnerability issue:

  1. Login as as Papermerge administrative user (may work for other papermerge users as well)
  2. The naive Papermerge admin user receives a phishing email (see below for email example) from another source which asks to download THEIR document from THEIR webpage and upload to THEIR webpage as if that is the way of confirming THEIR service
  3. The naive Papermerge administrative user, clicks the link, but instead it download HIS (or one of HIS user's document, because of predictable URL and lack of CSRF token) and uploads HIS document to THEIR webpage.

Example of phishing email:

<html>
<body>
To verify that you are a human, upload the file that has been downloaded from our website now.
<a href="https://demo.papermerge.com/node/11/download/">Download Test File</a>
</body>
</html>

To mitigate the problem either use less predictable document ID's (e.g. UUID) or use csrf tokens.

l4rm4nd commented 3 years ago

@ciur: All requests within the Papermerge web application that trigger a sensitive action use a csrf token (either within POST data or as X-CSRFToken HTTP header), so I assume the CSRF middleware is correctly enabled and the application not susceptible to CSRF.

E.g. creating a new application user:

image

An attacker without knowledge about the csrfmiddlewaretoken is not able to conduct a CSRF attack.

So the outlined problem is not really Cross-Site Request Forgery (CSRF) nor Insecure Direct Object Reference (IDOR).

  1. Downloading attachements is only possible as authenticated user. You have to be logged into the web application.
  2. Downloading attachements is only possible as authorized user. You must have permissions to access the file.
  3. Downloading files do not trigger a state changing action on the application and is therefore done by the HTTP method GET. GET requests are usually not worth being protected by a csrf token. See OWASP
  4. Guessing the ID of an attachement does not really have an impact, since authorization and access controls are in place, which only allow the owner of a document to download it. So even if you have another valid user account within your papermerge application, this user won't be able to download the attachements without proper permissions, even if he can guess the correct ID of another user's document.

So what is the impact of this:

So imho this is not really an issue at all.

Recommendation

ciur commented 3 years ago

@l4rm4nd, thank you a lot for your detailed explanation. I will take care of the issue.