GHSL-2023-268_GHSL-2023-270: Arbitrary command execution and SQL injection in Nginx-UI
Nginx-UI allowed any authenticated user to modify system settings via the API, including a terminal start command and nginx test command, leading to arbitrary command execution. It also had a SQL injection in the order and sort_by parameters of a paginated endpoint, allowing information disclosure.
Nginx-UI is a web interface to manage Nginx configurations. It is vulnerable to arbitrary command execution by abusing the configuration settings, and is also vulnerable to SQL injection.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application lacked authorization checks on settings modification and failed to sanitise user-controlled input before using it in shell commands and SQL queries.
Impact
This could lead to authenticated remote code execution, privilege escalation, and information disclosure.
What the attacker needed
A valid user account; ability to send API requests
The fix
The issues were fixed in commits 827e76c and ec93ab0.
How it was found
- Login as a newly created user.
- Send a request to modify the settings with a malicious start_cmd value.
- Open a terminal from the web interface and execute arbitrary commands as root.
- Send a request to modify the settings with a malicious test_config_cmd value.
- Add a new site in Home > Manage Sites > Add Site with random data.
- Verify that the command was executed (e.g., a file was created).
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 report has not been written yet. The Original tab links to the source.
Nginx-UI is a web tool for managing Nginx. Any logged-in user could change hidden settings through the API, even though the web page didn't show those options. One setting controlled what command runs when you open a terminal, so a user could make it run any command as root. Another setting was used to test nginx configuration, and it was passed directly to a shell, allowing command injection. Separately, a database query used user input without cleaning it, letting an attacker extract data by sorting results in a special way.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.