Описание
Signal K Server has Unauthenticated State Pollution leading to Remote Code Execution (RCE)
Summary
An unauthenticated attacker can pollute the internal state (restoreFilePath) of the server via the /skServer/validateBackup endpoint. This allows the attacker to hijack the administrator's "Restore" functionality to overwrite critical server configuration files (e.g., security.json, package.json), leading to account takeover and Remote Code Execution (RCE).
Details
The vulnerability is caused by the use of a module-level global variable restoreFilePath in src/serverroutes.ts, which is shared across all requests.
Vulnerable Code Analysis:
- Global State:
restoreFilePathis defined at the top level of the module.// src/serverroutes.ts let restoreFilePath: string - Unauthenticated State Pollution: The
/skServer/validateBackupendpoint updates this variable. Crucially, this endpoint lacks authentication middleware, allowing any user to access it.app.post(`${SERVERROUTESPREFIX}/validateBackup`, (req, res) => { // ... handles file upload ... restoreFilePath = fs.mkdtempSync(...) // Attacker controls this path }) - Restore Hijacking: The
/skServer/restoreendpoint uses the pollutedrestoreFilePathto perform the restoration.app.post(`${SERVERROUTESPREFIX}/restore`, (req, res) => { // ... const unzipStream = unzipper.Extract({ path: restoreFilePath }) // Uses polluted path // ... })
Exploit Chain:
- Pollution: Attacker uploads a malicious zip file to
/validateBackup. The server saves it and updatesrestoreFilePathto point to this malicious file. - Hijacking: When
/restoreis triggered (either by the attacker if they have access, or by a legitimate admin), the server restores the attacker's malicious files. - Backdoor: The attacker overwrites
security.jsonto add a new administrator account. - RCE: Using the new admin account, the attacker exploits a separate Command Injection vulnerability in the App Store (
/skServer/appstore/install/...) to execute arbitrary system commands (e.g.,npm installinjection).
PoC
Here is a complete Python script to reproduce the full exploit chain.
Impact
Remote Code Execution (RCE), Account Takeover, Denial of Service.
Verified: RCE is demonstrated by creating a file named rce_proof.txt containing the text "RCE_SUCCESS" on the server filesystem using the exploit chain.
Пакеты
signalk-server
< 2.19.0
2.19.0
Связанные уязвимости
Signal K Server is a server application that runs on a central hub in a boat. Prior to version 2.19.0, an unauthenticated attacker can pollute the internal state (`restoreFilePath`) of the server via the `/skServer/validateBackup` endpoint. This allows the attacker to hijack the administrator's "Restore" functionality to overwrite critical server configuration files (e.g., `security.json`, `package.json`), leading to account takeover and Remote Code Execution (RCE). Version 2.19.0 patches this vulnerability.