/

CVE-2026-22035

Severity:

HIGH RISK

(7.7)

OS Command Injection in Greenshot External Command

CVE-2026-22035

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution on the Host System

Severity:

HIGH RISK

(7.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 FormatArguments logic in ExternalCommandDestination.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.

Sources

SourceLink
github.comgithub.com/greenshot/greenshot/commit/5dedd5c9f0a9896fa0af1d4980d875a48bf432cb
github.comgithub.com/greenshot/greenshot/releases/tag/v1.3.311
github.comgithub.com/greenshot/greenshot/security/advisories/GHSA-7hvw-q8q5-gpmj

Frequently asked

questions

Exploitation is typically local: an attacker needs a way to influence or control a screenshot filename that Greenshot processes through its external command feature. In shared workstations or environments where filenames can be manipulated indirectly, this can still be a meaningful risk.

The attacker must be able to cause Greenshot to handle a screenshot with a crafted filename and trigger the external command path. This usually means local user access, or a scenario where another application or workflow generates filenames consumed by Greenshot.

The most robust fix is to stop building shell command strings with raw string formatting and instead use APIs that pass arguments as structured parameters. If the shell must be used, consistently quote and escape all user-influenced values and validate them against a strict allowed pattern.

Establish a standard pattern for command execution that never interpolates untrusted data directly into command strings, enforce secure wrappers around process invocation, and use automated checks to detect any new instances where user input might influence command construction.

Find out what's already
exploitable in your codebase.