Summary
Microsoft UFO's shell action replay logic allows OS command injection when action parameters are passed directly to PowerShell via subprocess with shell execution enabled.
If an attacker can create or modify UFO session/action JSON records, they can plant a malicious shell action that will run with the UFO process user's privileges when the session is resumed or replayed.
Affected context
This vulnerability affects Microsoft UFO deployments that:
- Use shell-based actions such as RunShellCommand or ExecuteCommand
- Persist planned and executed actions in per-session JSON records on disk or in shared storage
- Trust or expose session/action JSON files to external systems, automation, or users
- Replay or resume sessions that may contain shell actions without re-validating stored parameters
The issue is present where ShellReceiver.run_shell() or ShellReceiver.execute_command() are reachable and execute commands via PowerShell.
Exploit preconditions
- Attack surface: File or storage layer where UFO session and action JSON records are stored.
- Required access: Ability to create, write, or modify a UFO session/action JSON file that will later be processed by the framework.
- Trigger point: Session replay or resume logic that deserializes stored actions and invokes:
- ShellReceiver.run_shell()
- ShellReceiver.execute_command()
- RunShellCommand.execute()
- ExecuteCommand.execute()
- Why exploitation is possible: ShellReceiver passes command strings from action parameters directly into
subprocess.Popen()withshell=Trueandexecutable=powershell.exe, allowing the attacker-controlled command to be executed by the OS shell without sanitization or strict argument handling.
Why this happens
The core issue is the direct interpolation of untrusted command strings into an operating system shell with command parsing enabled.
In the vulnerable code path, action parameters stored in JSON are treated as fully trusted and forwarded to subprocess.Popen() using shell=True, delegating parsing and execution to PowerShell.
This pattern aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command, where user-controlled input is used to construct shell commands without robust validation or constrained invocation interfaces.
Because stored session data can be influenced by an attacker with write access, the shell invocation becomes a powerful execution primitive when those sessions are later replayed.
Potential impact
- Execution of arbitrary PowerShell commands as the UFO process user
- Reading, modifying, or deleting files accessible to the UFO service account
- Installing backdoors or persistence mechanisms on the host where UFO runs
- Lateral movement within the environment using the UFO host as a pivot
- Tampering with automation workflows, device configurations, or orchestration logic managed by UFO
General mitigation guidance
Mitigation should focus on eliminating direct shell invocation with raw, untrusted command strings and reducing trust in stored session data.
Common defensive patterns include:
- Avoiding
shell=Truein subprocess calls and instead using argument lists that bypass shell parsing. - Designing shell execution helpers that only allow pre-defined, parameterized commands with strict whitelists and type-checked arguments.
- Treating session/action JSON as untrusted input on replay, applying validation and normalization before any action is executed.
- Implementing a clear separation between data (parameters) and control (command templates), ensuring parameters cannot alter the command structure.
- Running the UFO service under a least-privilege account with minimal filesystem and network permissions.
- Restricting access to session and action storage locations via OS-level permissions and, where applicable, storage ACLs.
How teams detect issues like this
Detection efforts can target both code-level patterns and runtime behavior:
- Static analysis: Rules that flag use of
subprocess.Popen()or related APIs withshell=True, especially when arguments originate from deserialized data structures (e.g., JSON, databases, message queues). - Code review signals: Paths where session or action metadata is read from disk or external sources and forwarded into shell execution helpers without validation or canonicalization.
- Configuration and policy checks: CI/CD policies that disallow new shell-based helpers unless they use safe argument lists and controlled templates.
- Runtime monitoring: Logging and alerting on unusual PowerShell invocations initiated by the UFO process, including commands that deviate from expected automation patterns.
- Automated security review tools can be integrated into the development workflow to flag risky subprocess usage and shell injection patterns early.

