Summary
OpenProject's repository diff download endpoint allows attackers to inject additional git command-line options into the underlying git show invocation by supplying a crafted rev parameter.
Any user with :browse_repository permission can abuse this to direct git output to arbitrary filesystem locations writable by the OpenProject process, enabling arbitrary file creation or overwrite and leading to data loss and denial of service.
Affected context
The vulnerability occurs in OpenProject's SCM integration when generating diff downloads at:
/projects/:project_id/repository/diff.diff
It affects deployments where:
- Git is used as the backing repository for a project
- The application constructs and executes
git showcommands using user-controlledrevvalues - The
:browse_repositorypermission is granted to project members
In this context, unvalidated rev input is interpreted by Git as command-line options, allowing the output to be redirected to attacker-chosen paths that the OpenProject process user can write to.
Exploit preconditions
- Attack surface: HTTP(S) interface to the repository diff download endpoint (
/projects/:project_id/repository/diff.diff). - Required access: Authenticated user with
:browse_repositorypermission on the target project. - Trigger point: Providing a specially crafted
revparameter that starts with or contains Git command-line options (e.g., output redirection flags) when requesting a diff for a single revision. - Why exploitation is possible: The application incorporates the
revvalue directly into thegit showinvocation (or its argument list) without validating it as a safe revision identifier or separating positional arguments from options. Git interprets the user-controlledrevas options such as--output=<path>, enabling writes to arbitrary files accessible to the OpenProject process.
Why this happens
This issue stems from improper handling of user-controlled input when constructing system commands.
The rev parameter, which is intended to represent a revision identifier, is treated as part of the command argument list without robust validation, sanitization, or strict type checking.
As a result, the parameter can be interpreted as Git command-line options (for example, --output=/path/file), which alters the behavior of git show.
This maps to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where untrusted input influences the execution of a system-level command beyond its intended scope.
Potential impact
- Creation of arbitrary files containing
git showoutput at locations writable by the OpenProject process user - Overwriting of existing application, configuration, or data files, causing data loss
- Denial of service by corrupting configuration, cache, or runtime files required for normal operation
- Partial compromise of log or audit integrity if attacker-controlled diff data is written into sensitive log files
General mitigation guidance
Effective mitigation focuses on constraining how user input influences system command execution and file paths:
- Treat revision identifiers as data, not options: enforce strict whitelisting or schema validation ensuring
revmatches allowed Git ref formats (e.g., commit hashes, tags, branch names) and cannot begin with-or contain option-like sequences. - Use structured command execution APIs that separate arguments from options and do not permit user-controlled flags; avoid passing raw user input into command-line option positions.
- Introduce an internal mapping layer where user-facing revision tokens are resolved server-side to known-safe refs, rather than using arbitrary strings directly.
- Restrict the runtime's filesystem write permissions using least privilege (e.g., dedicated working directories, no write access to application binaries or critical configuration paths).
- Implement generic hardening for external tool invocations: centralized helpers for SCM commands that consistently validate and sanitize parameters.
How teams detect issues like this
Detection can combine code-level and operational techniques:
- Static analysis: Define rules to flag external command execution where user input (such as query parameters like
rev) is passed into argument lists, especially when it can influence options or file paths. - Code review: During manual reviews, pay attention to SCM integration layers and helper functions that wrap
gitcommands; verify that all user-supplied values are validated as safe refs and cannot become flags or redirection options. - Security testing: Incorporate fuzzing and negative tests around endpoints that translate user parameters into system commands, checking for unexpected file writes or abnormal command behavior.
- Runtime monitoring: Log and alert on unusual patterns such as
gitcommands executed with unexpected options, or sudden creation/overwrite of files outside designated repository working directories.

