Summary
Geany can pass filenames containing shell metacharacters into build or execution commands in a way that allows those characters to be interpreted by the shell. If a user runs Compile, Build, or Execute on a crafted filename, commands may run with that user's privileges.
Affected context
The vulnerability occurs when Geany substitutes a filename into a build or execution command that is interpreted by /bin/sh. It becomes risky when a crafted filename is available to the user and the user triggers Compile, Build, or Execute for that file.
Exploit preconditions
- Attack surface: Geany's Compile, Build, and Execute command handling
- Required access: The attacker must make a crafted filename available to a Geany user; the user must be able to open or access it
- Trigger point: The user runs a build or execution action that uses the filename
- Why exploitation is possible: Shell metacharacters in the substituted filename may be interpreted as command syntax
Why this happens
The underlying issue is OS command injection, mapped to CWE-78. The insecure pattern is incorporating a filename into a shell command without reliably preventing shell interpretation. As a result, data intended to identify a file may be treated as part of the command.
Potential impact
- An attacker may execute commands with the affected user's privileges
- The user's files and data could be accessed or modified, subject to their permissions
- Malware or other unwanted software could be run in the user's session
General mitigation guidance
Mitigation generally focuses on avoiding shell interpretation of externally influenced values.
- Prefer APIs that pass executable arguments directly rather than constructing shell command strings
- Treat filenames and other externally influenced values as untrusted, and use robust argument handling where shell invocation cannot be avoided
- Use fixed, allowlisted command structures and avoid unnecessary dynamic command construction
- Apply least privilege to user accounts and development environments
How teams detect issues like this
- Use static analysis to identify shell command construction that incorporates filenames or other externally influenced values
- Review build and execution command templates for unsafe interpolation and missing argument handling
- Apply code-review policies that require safer process invocation patterns
- Consider automated security review tools that flag command-injection risks

