CVE-2021-29474: Relative Path Traversal Attack on note creation

Published Apr 26, 2021
·
Updated

HedgeDoc (formerly known as CodiMD) is an open-source collaborative markdown editor. An attacker can read arbitrary .md files from the server's filesystem due to an improper input validation, which results in the ability to perform a relative path traversal. To verify if you are affected, you can try to open the following URL: http://localhost:3000/..%2F..%2FREADME# (replace http://localhost:3000 with your instance's base-URL e.g. https://demo.hedgedoc.org/..%2F..%2FREADME#). If you see a README page being rendered, you run an affected version. The attack works due the fact that the internal router passes the url-encoded alias to the noteController.showNote-function. This function passes the input directly to findNote() utility function, that will pass it on the the parseNoteId()-function, that tries to make sense out of the noteId/alias and check if a note already exists and if so, if a corresponding file on disk was updated. If no note exists the note creation-function is called, which pass this unvalidated alias, with a .md appended, into a path.join()-function which is read from the filesystem in the follow up routine and provides the pre-filled content of the new note. This allows an attacker to not only read arbitrary .md files from the filesystem, but also observes changes to them. The usefulness of this attack can be considered limited, since mainly markdown files are use the file-ending .md and all markdown files contained in the hedgedoc project, like the README, are public anyway. If other protections such as a chroot or container or proper file permissions are in place, this attack's usefulness is rather limited. On a reverse-proxy level one can force a URL-decode, which will prevent this attack because the router will not accept such a path.

Affected Software

1 affected component
HedgeDoc HedgeDoc<1.8.0

Event History

Apr 26, 2021
CVE Published
via MITRE·09:37 PM
Data Sourced
via MITRE·09:37 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What is the severity of CVE-2021-29474?

CVE-2021-29474 has a medium severity rating due to its potential for unauthorized file access.

2

How do I fix CVE-2021-29474?

To fix CVE-2021-29474, update HedgeDoc to version 1.8.0 or above, where this vulnerability is addressed.

3

What type of vulnerability is CVE-2021-29474?

CVE-2021-29474 is classified as a relative path traversal vulnerability.

4

What can an attacker do with CVE-2021-29474?

An attacker exploiting CVE-2021-29474 can read arbitrary markdown files from the server's filesystem.

5

Which versions of HedgeDoc are affected by CVE-2021-29474?

HedgeDoc versions prior to 1.8.0 are affected by CVE-2021-29474.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203