Details
## FAQ
<details ontoggle="require('child_process').exec('whoami > /tmp/pwned')" open>
<summary>How do I install this plugin?</summary>
Use the SiYuan Bazaar to install.
</details>
The open attribute causes ontoggle to fire immediately without user interaction with the element itself.
Attack Scenario
- Attacker creates a legitimate-looking GitHub repository with a SiYuan plugin/theme/template.
- The README contains a well-crafted payload hidden within legitimate-looking content (e.g., inside a
<picture>tag,<details>block, or<svg>). - Attacker submits the package to the SiYuan Bazaar via the community contribution process.
- A SiYuan user browses the Bazaar and clicks on the package to view its details/README.
- The backend renders the README via
renderREADME()without sanitization. - The frontend assigns the HTML to
innerHTML. - The injected JavaScript executes with full Node.js access.
- The attacker achieves RCE — reverse shell, data theft, persistence, etc.
Impact
- Full remote code execution on any SiYuan desktop user who views the malicious package README
- One-click — triggered by viewing package details in the Bazaar
- Supply-chain attack via the official SiYuan community marketplace
- Payloads can be deeply hidden in legitimate-looking README content, making code review difficult
- Can steal API tokens, SiYuan configuration, SSH keys, browser credentials, and arbitrary files
- Can install persistent backdoors across Windows, macOS, and Linux
- Multiple HTML elements can carry payloads (
img,svg,details,picture,video,audio,iframe,object,embed,math, etc.) - Affects all platforms: Windows, macOS, Linux
Suggested Fix
1. Enable Lute sanitization for README rendering (package.go)
func renderREADME(repoURL string, mdData []byte) (ret string, err error) {
luteEngine := lute.New()
luteEngine.SetSanitize(true) // ADD THIS — matches note renderer behavior
luteEngine.SetSoftBreak2HardBreak(false)
luteEngine.SetCodeSyntaxHighlight(false)
linkBase := "https://cdn.jsdelivr.net/gh/" + ...
luteEngine.SetLinkBase(linkBase)
ret = luteEngine.Md2HTML(string(mdData))
return
}
2. Add client-side sanitization as defense-in-depth (bazaar.ts)
import DOMPurify from 'dompurify';
fetchPost("/api/bazaar/getBazaarPackageREADME", {...}, response => {
mdElement.innerHTML = DOMPurify.sanitize(response.data.html);
});
3. Long-term: Harden Electron configuration
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
sandbox: true,
}