Skip to content

CRITICAL: Windows command injection vulnerability in secure_exec quote handling #593

@krystophny

Description

@krystophny

CRITICAL SECURITY DEFECT: Command Injection on Windows

The Windows implementation of secure_exec contains CRITICAL command injection vulnerability due to inadequate quote escaping.

Vulnerable Code (fortplot_secure_exec.c:77-82):

if (strchr(argv[i], ' ')) {
    offset += snprintf(cmdline + offset, sizeof(cmdline) - offset, 
                     "\"%s\"", argv[i]);  // INADEQUATE ESCAPING
}

Security Impact:

  • Arbitrary command execution on Windows systems
  • Shell metacharacter injection through quote breaking
  • Complete system compromise possible
  • Bypasses security fixes from previous PRs

Attack Vector:
Arguments containing both spaces AND quotes can break out of quote protection:

Example Exploit:

// Attacker controls argv input
argv[1] = "file\"; calc.exe; echo \"";
// Results in: ffmpeg "file"; calc.exe; echo ""
// Executes: calc.exe (Windows Calculator as proof of concept)

Root Cause:
Windows CreateProcess cmdline construction performs naive quoting without proper escaping of embedded quotes.

Fix Required:
Implement proper Windows command line escaping per Microsoft documentation, or use CreateProcess with separate argv array without cmdline construction.

Component: Security, Windows Platform, Command Injection
Severity: CRITICAL - Remote code execution on Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions