Summary
Greenshot versions 1.3.310 and below contain an OS command injection flaw in how user-controlled filenames are incorporated into shell commands.
By crafting a filename with shell metacharacters, an attacker can cause arbitrary commands to execute when Greenshot invokes external commands that use the vulnerable formatting logic.
Affected context
The vulnerability occurs in Greenshot's integration with external commands on Windows when filenames are passed to shell-invoked processes.
It is relevant in environments where:
- Users can influence or control screenshot filenames (directly or indirectly)
- External command destinations are configured and executed by Greenshot
- Filenames are propagated into command lines without robust validation or escaping
The risk is more pronounced when the process runs with elevated or sensitive privileges.
Exploit preconditions
- Attack surface: Local system where Greenshot is installed and configured to use external commands.
- Required access: Ability to cause Greenshot to process a screenshot whose filename is attacker-controlled or influenced.
- Trigger point: Execution of an external command destination that uses the vulnerable
FormatArgumentslogic inExternalCommandDestination.cs. - Why exploitation is possible: The application uses
string.Format()to interpolate filename values directly into shell command strings without quoting, escaping, or validation, allowing shell metacharacters in filenames to be interpreted as part of the command.
Why this happens
This issue stems from treating user-controlled data (filenames) as trusted input when composing OS-level command strings.
In the vulnerable code path, the FormatArguments method uses string.Format() to splice filename values into command templates that are ultimately executed by the shell or command interpreter.
Without strict quoting, escaping, or validation, special characters in filenames are interpreted by the shell, enabling CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Conceptually, the bug reflects a pattern where data and code are mixed in the same string, giving attacker-controlled input influence over the command structure rather than being treated purely as data.
Potential impact
- Execution of arbitrary commands under the privileges of the user (or process account) running Greenshot
- Reading, modifying, or deleting local files accessible to that account
- Installing additional malware or persistence mechanisms on the affected system
- Exfiltrating sensitive data, screenshots, or configuration information
- Pivoting to other internal resources reachable from the compromised host
General mitigation guidance
Effective mitigation focuses on separating data from commands and reducing trust in filename input:
- Prefer APIs that avoid shell invocation entirely and pass arguments as strongly typed parameters rather than concatenated strings.
- Apply strict quoting and escaping for all filename and path parameters when they must be included in a command-line string.
- Validate or constrain filenames to an expected character set and length, rejecting or normalizing unexpected metacharacters.
- Apply the principle of least privilege to Greenshot and any helper processes so that, if a command executes, its impact is minimized.
- Limit or harden configurable external command templates so that user-controlled data cannot alter command structure.
How teams detect issues like this
Organizations can identify and monitor for similar issues using:
- Static analysis rules that flag string concatenation or formatting used to build command lines with user-controlled variables.
- Code review checklists that require reviewers to verify that any command execution pathway uses parameterized or safely escaped arguments.
- Pattern searches in the codebase for use of
string.Format, concatenation, or interpolation feeding into process or shell execution calls. - Policy enforcement in CI/CD that blocks new uses of shell-based execution without approved safe wrappers.
- Runtime monitoring for unusual command invocations spawned by desktop applications like Greenshot, especially commands containing filename fragments.

