Summary
A command injection vulnerability in Podman's HyperV machine backend allows attacker-controlled VM image paths to be embedded in a PowerShell double-quoted string without proper sanitization.
Because PowerShell evaluates $() subexpressions before running the outer command, a crafted machine name or image directory can trigger arbitrary PowerShell execution with the privileges of the Podman process on Windows systems.
Affected context
This vulnerability occurs in Podman deployments on Windows that use the HyperV machine backend implemented in pkg/machine/hyperv/stubber.go.
The issue is relevant when:
- Podman constructs PowerShell commands to manage HyperV-based virtual machines
- The VM image path is derived from user-controlled or partially user-controlled input such as machine names or image directories
- The resulting path is interpolated directly into a PowerShell double-quoted string
Only Windows environments using the HyperV backend are affected; other Podman platforms and backends are not impacted by this specific bug.
Exploit preconditions
- Attack surface: Podman's machine management functionality on Windows, specifically the HyperV backend.
- Required access: Ability to influence the VM image path, for example via crafted machine names, image directory paths, or other inputs that propagate into the image path.
- Trigger point: Execution of a PowerShell command that includes the unsanitized VM image path inside a double-quoted string, typically when creating or managing a HyperV VM through Podman.
- Why exploitation is possible: The VM image path is interpolated directly into a PowerShell double-quoted string without escaping or validation, enabling $() subexpression injection. PowerShell evaluates these subexpressions before running the main command, so injected content runs as part of the Podman process context.
Why this happens
The core issue is unsafe construction of shell commands with untrusted input, aligning with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
In the HyperV backend, the VM image path is concatenated into a PowerShell command as a double-quoted string without neutralizing or escaping characters meaningful to PowerShell, such as $( and ).
This pattern treats user-influenced data as if it were safe code, allowing attackers to embed PowerShell subexpressions that are evaluated at runtime.
The bug is not specific to one particular string but to the general practice of directly interpolating file system paths or names into shell commands without robust encoding or parameterization.
Potential impact
- Arbitrary PowerShell command execution with the privileges of the Podman process.
- On typical Windows setups, potential SYSTEM-level code execution via the HyperV backend service context.
- Full compromise of the affected Windows host, including installation of malware or backdoors.
- Lateral movement within the network if the compromised host has access to other systems.
- Modification or destruction of VM images and associated data managed by Podman.
General mitigation guidance
Effective mitigation focuses on eliminating direct command-string construction with untrusted input and reducing the privilege and scope of any remaining command execution.
Recommended defensive patterns include:
- Parameterization and escaping: Use PowerShell APIs or command builders that pass user-controlled values as parameters rather than inline strings, or apply rigorous escaping/encoding of special characters in any interpolated paths.
- Canonicalization and validation: Normalize and validate VM image paths against strict, expected patterns (e.g., allowlisted directories, restricted character sets) before use in any command context.
- Least privilege: Run Podman-related Windows services and HyperV management components under accounts with minimal necessary privileges instead of SYSTEM where possible.
- Segregation of duties: Separate user input handling from command execution logic so that only vetted, normalized values reach shell-level operations.
- Defense-in-depth checks: Introduce guardrails that reject inputs containing shell metacharacters or PowerShell-specific constructs like
$(, backticks, or pipeline characters when they are not required.
How teams detect issues like this
Organizations can detect and prevent similar vulnerabilities by combining automated and manual review techniques:
- Static analysis: Configure SAST tools to flag string concatenation patterns used to build shell commands, especially where user input or file paths flow into PowerShell or other shell invocations.
- Code review checklists: During reviews, require scrutiny of any code that calls PowerShell, cmd.exe, or other interpreters, ensuring that all arguments are passed as parameters and not embedded in raw command strings.
- Policy enforcement: Establish coding standards banning unescaped interpolation of user-supplied data into OS commands, and enforce these standards via pre-commit hooks or CI pipelines.
- Runtime monitoring: Use endpoint detection and response (EDR) tools on Windows hosts to monitor for unusual PowerShell invocations originating from Podman-related processes, including unexpected parameters or execution contexts.

