Skip to main content
Menu
Advisories

Path traversal vulnerability in sync logic allows a malicious sync target to create and overwrite arbitrary files

GHSA-JCJ2-CQP2-7J53Published Updated GitHub

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:

github.com/laurent22/joplin/blob/a7c3cdad7450f4439a4601119a0b00c4e96e5acc/packages/lib/Synchronizer.ts#L973

Joplin's resource fetcher later uses this ID to determine where the resource should be saved:

github.com/laurent22/joplin/blob/a7c3cdad7450f4439a4601119a0b00c4e96e5acc/packages/lib/services/ResourceFetcher.ts#L181

resourceUtils.ts then uses the id property verbatim, which is unsafe for untrusted ids:

github.com/laurent22/joplin/blob/a7c3cdad7450f4439a4601119a0b00c4e96e5acc/packages/lib/models/utils/resourceUtils.ts#L12

PoC

  1. Set up file system sync from the desktop app.
  2. In the sync directory, update a resource metadata file with an id: that starts with ../ (e.g. ../path-traversal).
  3. Create a file matching the ID.
  4. Set up a new desktop app profile to sync with the file system.
  5. Sync.
  6. Observe that a ../path-traversal file (possibly with an extension) has been created outside the resource directory.
  • In the screen recording, a path-traversal.svg file is created directly within the user's profile directory.

Screen recording:

github.com/user-attachments/assets/02ff5730-a6bd-4c36-8ab9-a36865684367

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.

References

GitHub · laurent22/joplin