Post-Trust: From XSS to RCE in Syncthing
Syncthing fixed a filename XSS in 2023 that let a paired device run JavaScript through a tooltip in the web UI. That made me want to see if I could find another filename XSS, and I found one in Restore Versions.
With file versioning enabled, Restore Versions displays archived filenames using Fancytree, a third-party JavaScript library for displaying file trees. Fancytree treats titles as HTML by default, and Syncthing hadn't enabled its escapeTitles option there, so opening the dialog could run JavaScript from a filename supplied by an accepted peer.
The original Restore Versions PR, merged in 2018, introduced the tree without escapeTitles. One of Syncthing's maintainers, calmh, said in review that he wasn't reviewing the JavaScript or vendored dependencies in the large change, which may explain how the default slipped through.
Because the injected JavaScript ran in Syncthing's own GUI origin, it could read the GUI's CSRF token and call the local REST API just as the GUI does. In my PoC, it switched the folder to an external versioner, which runs a configured command when Syncthing archives an old file version, and restarted Syncthing. The next file change archived the old copy and ran that command, opening Calculator on the receiving Mac.
The 2023 tooltip report didn't attempt RCE. I suspect that separate bug could have been taken further too.
The attack needed an accepted peer with access to the shared folder, versioning turned on, and someone to open Restore Versions. I reported it privately on June 2, 2026; Syncthing changed Fancytree to escape filenames, and the fix shipped in 2.1.2 on July 8. With those conditions and the fix out for several months now, I doubt this has much practical use today.
I wasn't credited for reporting the bug. That's unfortunate, but it's more common than not in OSS projects like this.
The PoC code is on GitHub.
