From “Add User” to Root: A 4-Digit Bug Bounty Command Injection
The SSH user creation feature in a web control panel passed the username to system commands run as root without sanitising it, so injected shell commands executed with root privileges. An attacker with a low-privileged SSH account could therefore run arbitrary commands as root and take full control of the server.
Published on yaseenzubair.medium.com
This article documents a real-world security issue identified while performing a bug bounty assessment. The purpose of this write-up is educational: to explain how a small design flaw in user management can lead to full system compromise when privilege boundaries are not enforced correctly.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the backend built shell commands by concatenating the raw username into them and ran them as root, without escaping or validating the input.
Impact
An attacker with a low-privileged SSH account could execute arbitrary commands as root and gain complete administrative control over the server.
What the attacker needed
A low-privileged SSH account; access to the user creation panel
The fix
The username should be validated against a strict allowlist and passed to system commands as separate arguments rather than concatenated into a shell string, and user creation should not run as root.
How it was found
- Install a process monitoring tool over the limited SSH access to watch background activity.
- Create a new SSH user through the control panel and observe that the backend commands run as root.
- Submit a username containing a command separator and a simple command to test for injection.
- Check over SSH whether the injected command ran, confirming root execution.
- Inject commands to add a root-level user entry and set its password.
- Switch to the new user over SSH to obtain a root shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you type a username into a web form, the server often builds a system command from it. If the server does not clean that input, extra commands can be slipped in and run by the server itself. Here the server ran those commands as the most powerful account on the machine, so the attacker could do anything.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.