hedgedoc/lib/web
Sheogorath dc29a286e6
Fix arbitary file upload for uploadimage API endpoint
This patch fixes a security issue with all existing CodiMD and HedgeDoc
installation which allows arbitary file uploads to instances that expose
the `/uploadimage` API endpoint. With the patch it implies the same
restrictions on the MIME-types as the frontend does. Means only images
are allowed unless configured differently.

This issue was reported by Thomas Lambertz.

To verify if you are vulnerable or not, create two files `test.html` and
`test.png` and try to upload them to your hedgedoc installation.

```
curl -X POST -F "image=@$(pwd)/test.html" http://localhost:3000/uploadimage
curl -X POST -F "image=@$(pwd)/test.png" http://localhost:3000/uploadimage
```

Note: Not all backends are affected. Imgur and lutim should prevent this
by their own upload API. But S3, minio, filesystem and azure, will be at
risk.

Addition Note: When using filesystem instead of an external uploads
providers, there is a higher risk of code injections as the default CSP
do not block JS from the main domain.

References:
https://github.com/hedgedoc/hedgedoc/security/advisories/GHSA-wcr3-xhv7-8gxc

Signed-off-by: Christoph Kern <sheogorath@shivering-isles.com>
2020-12-27 19:51:01 +01:00
..
auth Fix crash when OAuth2 config parameters are missing 2020-11-30 15:04:30 +01:00
imageRouter Fix arbitary file upload for uploadimage API endpoint 2020-12-27 19:51:01 +01:00
middleware Replace CodiMD with HedgeDoc 2020-11-14 21:18:36 +01:00
note Remove pdf export code 2020-11-26 21:09:23 +01:00
baseRouter.js Move note actions to their own file. 2019-10-27 13:51:53 +01:00
historyRouter.js Fix eslint warnings 2019-05-31 00:30:29 +02:00
statusRouter.js Add config option for cookie SameSite policy 2020-08-27 02:04:49 +02:00
userRouter.js Move note actions to their own file. 2019-10-27 13:51:53 +01:00
utils.js Allow posting new note with content 2018-01-18 10:41:58 +01:00