Path traversal vulnerability in sync logic allows a malicious sync target to create and overwrite arbitrary files
Description
A path traversal vulnerability in the resource saving logic allows a malicious sync target to overwrite arbitrary files on the user's computer.
Details
A resource metadata file can specify an id property containing ../s and other invalid characters. This ID property is deserialized as a part of the sync process and stored in the downloaded item:
Joplin's resource fetcher later uses this ID to determine where the resource should be saved:
resourceUtils.ts then uses the id property verbatim, which is unsafe for untrusted ids:
PoC
- Set up file system sync from the desktop app.
- In the sync directory, update a resource metadata file with an
id:that starts with../(e.g.../path-traversal). - Create a file matching the ID.
- Set up a new desktop app profile to sync with the file system.
- Sync.
- Observe that a
../path-traversalfile (possibly with an extension) has been created outside the resource directory.
- In the screen recording, a
path-traversal.svgfile is created directly within the user's profile directory.
Screen recording:
github.com/
Impact
This is a path traversal vulnerability that allows an attacker to create or overwrite arbitrary files. This can be used to obtain remote code execution. This affects all users that sync with an untrusted sync target.