Arbitrary File Deletion Vulnerability in Siyuan Note

Published Date: January 5, 2025

Package Affected Versions Patched Versions Severity
📦 github.com/siyuan-note/siyuan/kernel (Go) < 0.0.0-20250103014808-d9887aeec1b2 High

Description

Summary


Siyuan Note contains an arbitrary file deletion vulnerability in the /api/history/getDocHistoryContent endpoint. An attacker can exploit this flaw by crafting a malicious request, which could delete arbitrary files on the server.




Technical Details


The vulnerability lies in how the historyPath parameter is processed in the following function chain:

  1. api/history.go:133 – Processes historyPath from the request payload.

  2. model/history.go:150 – Passes historyPath to the GetDocHistoryContent function.


Here’s the critical section:

if historyPath exists and does not satisfy the filesys.ParseJSONWithoutFix, then it will be deleted by os.RemoveAll


If ParseJSONWithoutFix fails, the file at historyPath will be deleted via os.RemoveAll.

Proof of Concept (PoC)


An attacker can exploit this with the following curl command:

curl "http://127.0.0.1:6806/api/history/getDocHistoryContent" \
-X POST -H "Content-Type: application/json" \
-d '{"historyPath":"<abs_filepath_of_a_file>"}'


Replace <abs_filepath_of_a_file> with the absolute path of the target file.




Impact


Successful exploitation allows an attacker to delete any file on the server, potentially leading to service disruption or further exploitation depending on the deleted files.

Patches & Workarounds

Mitigation and Fix


Currently, no official patch is available. However, here are some immediate steps to reduce risk:

  1. Restrict Access: Limit access to the vulnerable API endpoint to trusted IP addresses.

  2. Validate Input: Ensure historyPath strictly validates file paths before processing.

  3. Temporary Disablement: If possible, disable the /api/history/getDocHistoryContent endpoint until a patch is released.






Recommended Code Fix Example:
Add strict validation to prevent arbitrary file paths:

if !isValidHistoryPath(historyPath) {
return errors.New("invalid history path")
}


Implement isValidHistoryPath to ensure historyPath adheres to safe patterns.

References

https://nvd.nist.gov/vuln/detail/CVE-2025-21609
Share this:
  • Crypto Regulation in 2025: What You Need to Know

    Cryptocurrency regulation in 2025 looks less like a wild west shootout and more like a paperwork-laden chess match. As the digital asset industry matures, governments around the world are trying to fit crypto into traditional legal frameworks. Some are doing this with a sledgehammer. Others, with a scalpel.

  • How to Secure Your Wi-Fi Network Against Cyber Threats

    Your Wi-Fi network is like the front door to your digital home. If you leave it open, strangers may wander in. This guide shows you how to lock that door and keep unwanted guests out. I promise this guide is clear. Even I had to reread it once or twice (and that was a slow…

  • Cybersecurity Risks of U.S. Trade Tariffs: Impact on Supply Chains in Canada, Mexico & the EU

    In early 2025, the U.S. government announced new tariffs aimed at Canada, Mexico, and potentially the European Union. While the tariffs on Canada and Mexico are temporarily on hold, businesses are already adjusting supply chains to prepare for the financial impact. Trade policies like these cause ripple effects across industries, and cybersecurity often takes a…

  • Dark Web & Small Businesses: How Hackers Sell Your Data

    Many small business owners assume that cyberattacks only target large corporations. They imagine hackers as shadowy figures breaching high-security networks of multinational companies. The reality is much bleaker: small businesses are prime targets because they often lack strong cybersecurity defenses. Worse, once stolen, their data often ends up for sale on the dark web.

  • Top 10 Viruses and Malware Wreaking Havoc in January 2025

    Learn how to identify and defend against the latest cybersecurity threats like Banshee, Clop Ransomware, and AI-powered attacks. Stay one step ahead of hackers with this detailed guide.

  • Should You Invest in DIY AI Assistants?

    With AI technologies advancing rapidly, there’s growing interest in building personal assistants at home. Today, big names like Alexa and Google Home dominate the market, but their capabilities remain limited by their current integrations. Meanwhile, ChatGPT and Google’s Gemini have revolutionized conversational AI, although they lack standalone devices or wake-word functionality. These limitations won’t last…