Python
CVE-2026-33718
HIGH
Severity by source
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L
Primary rating from GitHub Advisory · only source for this CVE.
CVSS VectorGitHub Advisory
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L
Lifecycle Timeline
3DescriptionGitHub Advisory
Summary
A Command Injection vulnerability exists in the get_git_diff() method at openhands/runtime/utils/git_handler.py:134. The path parameter from the /api/conversations/{conversation_id}/git/diff API endpoint is passed unsanitized to a shell command, allowing authenticated attackers to execute arbitrary commands in the agent sandbox. The user is already allowed to instruct the agent to execute commands, but this bypasses the normal channels.
---
Details
Vulnerable Code Path
The vulnerability flows through these files:
- API Endpoint (
openhands/server/routes/files.py:267-277)
@app.get('/git/diff')
async def git_diff(
path: str,
# <-- User input from HTTP request
...
):
...
diff = await call_sync_from_async(runtime.get_git_diff, path, cwd)
# No sanitization- Runtime (
openhands/runtime/base.py:1231-1233)
def get_git_diff(self, file_path: str, cwd: str) -> dict[str, str]:
self.git_handler.set_cwd(cwd)
return self.git_handler.get_git_diff(file_path)
# Passed directly- Vulnerable Method (
openhands/runtime/utils/git_handler.py:10-12, 134)
# Command template with placeholder
GIT_DIFF_CMD = 'python3 /openhands/code/openhands/runtime/utils/git_diff.py "{file_path}"'
# Line 134 - VULNERABLE: User input directly interpolated
result = self.execute(self.git_diff_cmd.format(file_path=file_path), self.cwd)- Shell Execution (
openhands/runtime/utils/git_diff.py:25-27)
def run(cmd: str, cwd: str) -> str:
result = subprocess.run(
args=cmd,
shell=True,
# <-- Enables shell metacharacter interpretation
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=cwd
)Root Cause
The file_path parameter is directly interpolated into a shell command string using Python's .format() method without any sanitization. When this command is executed with shell=True, shell metacharacters like ", ;, and # are interpreted, allowing command injection.
Example:
- Input:
test"; id # - Constructed command:
python3 /script.py "test"; id #" - Shell interprets as two commands:
python3 /script.py "test"ANDid
---
Impact
Who is Affected
- All OpenHands deployments exposing the
/api/conversations/{id}/git/diffendpoint - Any authenticated user can exploit this vulnerability,
Attack Capabilities
An attacker can:
- Execute arbitrary commands on the runtime container as root
- Read sensitive files including
.env, API keys, source code - Write arbitrary files to inject malicious code
- Establish reverse shells for persistent access
- Potentially escape the container if Docker is misconfigured
Mitigation
Users should update to the latest version of OpenHands that includes the changes from PR #13051. The fix replaces direct shell string formatting with proper argument array handling or rigorous path sanitization to prevent command chaining.
AnalysisAI
A Command Injection vulnerability in OpenHands allows authenticated users to execute arbitrary commands in the agent sandbox by injecting shell metacharacters into the path parameter of the /api/conversations/{conversation_id}/git/diff API endpoint. The vulnerability affects OpenHands installations exposing this endpoint, with a CVSS score of 7.6. A patch is available via PR #13051, and while no EPSS or KEV data indicates active exploitation, the vulnerability is easily exploitable by any authenticated user.
Technical ContextAI
This vulnerability affects the OpenHands Python package (pkg:pip/openhands), specifically in the git_handler.py module's get_git_diff() method. The root cause is CWE-78 (Improper Neutralization of Special Elements used in an OS Command), where user-controlled input from the file_path parameter is directly interpolated into a shell command string using Python's format() method. The constructed command is then executed via subprocess.run() with shell=True, enabling the shell to interpret metacharacters like semicolons, pipes, and backticks. The vulnerable code path spans multiple layers: the Flask API endpoint receives unsanitized input, passes it through the runtime layer, and ultimately constructs a command string python3 /openhands/code/openhands/runtime/utils/git_diff.py "{file_path}" where the file_path placeholder is replaced without validation. This violates Python subprocess security best practices documented in the official Python documentation, which recommends using argument arrays instead of shell=True with string formatting.
RemediationAI
Update OpenHands to the latest version incorporating the security fix from PR #13051 available at https://github.com/OpenHands/OpenHands/pull/13051. The patch replaces unsafe shell string formatting with proper argument array handling or implements rigorous path sanitization to prevent command injection. Until patching is possible, restrict access to the /api/conversations/{conversation_id}/git/diff endpoint to only highly trusted authenticated users through API gateway rules or reverse proxy ACLs. Organizations can also consider implementing additional input validation at the API gateway layer to reject requests containing shell metacharacters in the path parameter, though this is a defense-in-depth measure and not a complete substitute for the vendor patch. Review the Python subprocess security considerations at https://docs.python.org/3/library/subprocess.html#security-considerations and OWASP Command Injection guidance at https://owasp.org/www-community/attacks/Command_Injection for additional context on secure implementation patterns.
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
Cross-user flow execution in Langflow (< 1.9.1) lets any authenticated API-key holder run another user's flow by passing
Same weakness CWE-78 – OS Command Injection
View allSame technique Command Injection
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-7h8w-hj9j-8rjw