6.0medium
NukeViet CMS: Authenticated path traversal to arbitrary file write via S/MIME certificate CN in SMTP settings
- Severity
- 6.0medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.43% (higher than 29% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-j79f-jrwm-2f2h
Description
NukeViet CMS is a multi Content Management System. From 4.5.00 until 4.6.01, an authenticated settings-module administrator can upload a PKCS#12 S/MIME certificate whose X.509 Subject CN contains path separators and traversal components. The smimeadd handler in admin/settings/smtp.php applies only an at-sign replacement before using the CN in .key, .crt, and .pem paths beneath data/certs. Traversal can select attacker-chosen paths outside data/certs, but writes remain constrained to already-existing writable directories and the permitted extensions. Within that constraint, attacker-controlled PEM data can overwrite certificate assets, including a DKIM private key; when the curl.cainfo PHP directive is empty, the attacker can also replace cacert.pem and undermine outbound TLS verification. This issue is fixed in version 4.6.01.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| nukeviet nukeviet | >= 4.5.00, < 4.6.01 | CVE List |
| nukeviet/nukeviet (Packagist) | from 4.5.00 before 4.6.01 | GitHub Advisory Database |
All scores
| GitHub_M | 6.0medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:H/A:L |
| GitHub | 5.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:L |
Classification
What each source says
CVE List
NukeViet CMS is a multi Content Management System. From 4.5.00 until 4.6.01, an authenticated settings-module administrator can upload a PKCS#12 S/MIME certificate whose X.509 Subject CN contains path separators and traversal components. The smimeadd handler in admin/settings/smtp.php applies only an at-sign replacement before using the CN in .key, .crt, and .pem paths beneath data/certs. Traversal can select attacker-chosen paths outside data/certs, but writes remain constrained to already-existing writable directories and the permitted extensions. Within that constraint, attacker-controlled PEM data can overwrite certificate assets, including a DKIM private key; when the curl.cainfo PHP directive is empty, the attacker can also replace cacert.pem and undermine outbound TLS verification. This issue is fixed in version 4.6.01.
GitHub Advisory Database
Summary
When an authenticated non-super administrator (settings-module admin) adds an S/MIME signing certificate via the smimeadd handler (admin/settings/smtp.php:220-296), the on-disk output filename is derived entirely from the certificate's X.509 Subject CN with only str_replace('@','__') applied. Because an X.509 CN may legally contain / and .., an attacker who crafts a self-signed cert with a traversal CN writes attacker-controlled PEM data to an attacker-chosen path (constrained to .key/.crt/.pem extensions, within already-existing writable directories).
This is a distinct, unpatched sink — the write-side analogue of a previously fixed delete-side path-traversal class — in a file the prior fix never touched.
Root Cause
admin/settings/smtp.php smimeadd handler:
openssl_pkcs12_read+openssl_x509_parseextract the Subject CN (:268).- The ONLY transform is
$email_name = str_replace('@','__', trim(CN))(:269). Nobasename,realpath,nv_is_file,dirname,strpos, or allowlist regex between the CN and the sinks (grep of :244-296 confirms). file_put_contents(NV_ROOTDIR.'/data/certs/'.$email_name.'.{key,crt,pem}', <attacker PEM>)at :283/:284/:287./and..in the CN surviveopenssl_x509_parseverbatim (empirically verified with OpenSSL 3 + PHP):CN=../../config/config→ resolved write path/data/certs/../../config/config.crt, escapingdata/certs.- Reachability:
smtp.php:12gate isNV_IS_MODADMIN;op=smtpis unconditional in$allow_func(admin/settings/functions.php:16). Thesettingsmodule is seeded (install/data.php:18) withact_1=1, act_2=1, act_3=0, so it is reachable by default to a level-2 SPADMIN (non-GODADMIN). - The
smimesignpurpose guard (:256) is satisfied byextendedKeyUsage=emailProtection;checkssis a per-user CSRF token — neither constrains the CN.
Impact
Arbitrary-directory file write (existing writable dirs, .key/.crt/.pem extension, attacker-controlled PEM content) by a non-super administrator.
- Unconditional (always-on): overwrite the DKIM signing key
data/certs/nv_dkim.<domain>.private.pem(setCN=nv_dkim.<domain>.private+ anextracertschain; the.crtoverwrite pre-check does not gate the.pemsink) → mail-signing key compromise/forgery (integrity + availability of mail signing). - Conditional ceiling (
curl.cainfophp.ini directive empty — the common default):data/certs/cacert.pem(the shipped 203 KB Mozilla CA bundle) is used asCURLOPT_CAINFO/cafilefor outbound HTTPS (includes/functions.php:2200-2202). SetCN=cacertwith a rogue chain → overwrite the CA bundle → outbound-TLS verification bypass / MITM.
Privileged-precondition test cleared: a level-2 SPADMIN does NOT already possess a designed arbitrary-file-write/RCE primitive — every designed executable-write surface is either in an act_2=0 module or behind an additional NV_IS_GODADMIN op-gate (PHP extensions are hard-force-forbidden even for GODADMIN). This handler therefore grants a NEW capability → a genuine security boundary is crossed.
Proof of Concept
# 1. Craft cert with traversal CN + S/MIME EKU, export legacy-compatible PKCS#12
openssl req -x509 -newkey rsa:2048 -keyout k.pem -out c.pem -days 1 -nodes \
-config cnf # cnf: CN=../../config/config, extendedKeyUsage=emailProtection
openssl pkcs12 -export -in c.pem -inkey k.pem -passout pass:x -out p.p12 \
-certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES -macalg sha1
# 2. POST p.p12 to admin/index.php?nv=settings&op=smtp with smimeadd=1, passphrase, valid checkss
# Observed: CN=cacert -> data/certs/cacert.crt; CN=../../config/config -> config/config.crt;
# CN=../../install/pwn -> install/pwn.crt (all SUCCESS; escaped data/certs)
Attack Chain
- Entry: authenticated non-GODADMIN admin with the
settingsmodule POSTs a crafted.p12toadmin/index.php?nv=settings&op=smtpwithsmimeadd=1, passphrase, validcheckss. Guard:NV_IS_MODADMIN(smtp.php:12) +op=smtpin$allow_func+checkssCSRF token + upload ext in{pfx,p12}. Bypass proof: all are auth/CSRF/wrapper guards; none constrain the CN; actor legitimately holds the settings module. - Process:
openssl_pkcs12_read→openssl_x509_parse→ CN read at :268; purpose guard$purpose[0]=='1' and $purpose[2]=='smimesign'at :256. Bypass proof:extendedKeyUsage=emailProtection→purposesreportssmimesignenabled (verified empirically). - Sink:
$email_name = str_replace('@','__', trim(CN));file_put_contents(NV_ROOTDIR.'/data/certs/'.$email_name.'.{key,crt,pem}', <attacker PEM>)(:269-287). Guard: none between CN and sink (only@→__). Bypass proof: grep showsstr_replaceis the sole transform;..,/,.pass through (empiricallyCN=../../config/config→/data/certs/../../config/config.crt). - Impact: arbitrary-directory file write (existing dirs,
.crt/.key/.pem, attacker PEM content). Unconditional: corrupt DKIM signing key / cert assets (I:H, A:L). Conditional (curl.cainfoempty): overwritecacert.pem→ outbound-TLS MITM (adds C:L).
Bypass Evidence
- grep of smtp.php :244-296 for
basename|realpath|preg_match|nv_is_file|nv_check|in_array|dirname|strpos|escape→ only match isstr_replace('@','__')at :269. - Empirically verified (OpenSSL 3 + PHP):
CN=../../config/configsurvivesopenssl_x509_parseverbatim; resolved write lands atconfig/config.crt(outsidedata/certs);purposes_enabledincludessmimesign. - Version:
git log 4.6.00..HEAD -- admin/settings/smtp.phpempty (identical on latest tag and HEAD); pattern present since 4.5.00. The prior path-traversal fix (commit27ba63c32) touches onlymodules/comment/admin/edit.php+install/tpl/step1.tpl— NOT smtp.php.
Affected Versions
>= 4.5.00, <= 4.6.00 (S/MIME cert feature introduced in commit d1f74a5be, first shipped in 4.5.00; code byte-identical through latest tag 4.6.00 and HEAD).
Suggested Fix
Apply basename() to the CN-derived name, or validate it with nv_is_file / a strict ^[A-Za-z0-9._@-]+$ allowlist before building the .key/.crt/.pem paths — the same nv_is_file containment the prior fix added to the comment module.
Reported by zx (Jace) — GitHub: @manus-use
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-94563 changed 2026-11-24 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-j79f-jrwm-2f2h changed 2026-11-30 | CC-BY-4.0 |
| NVD | CVE-2026-94563 changed 2026-11-24 | Public domain |