Skip to main content

Python CVE-2026-33718

HIGH
OS Command Injection (CWE-78)
2026-03-25 https://github.com/OpenHands/OpenHands GHSA-7h8w-hj9j-8rjw
7.6
CVSS 3.1 · GitHub Advisory
Share

Severity by source

GitHub Advisory PRIMARY
7.6 HIGH
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
Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low

Lifecycle Timeline

3
Analysis Generated
Mar 25, 2026 - 22:02 vuln.today
Patch released
Mar 25, 2026 - 22:02 nvd
Patch available
CVE Published
Mar 25, 2026 - 21:54 nvd
HIGH 7.6

DescriptionGitHub 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:

  1. API Endpoint (openhands/server/routes/files.py:267-277)
python
@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
  1. Runtime (openhands/runtime/base.py:1231-1233)
python
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
  1. Vulnerable Method (openhands/runtime/utils/git_handler.py:10-12, 134)
python
# 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)
  1. Shell Execution (openhands/runtime/utils/git_diff.py:25-27)
python
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" AND id

---

Impact

Who is Affected

  • All OpenHands deployments exposing the /api/conversations/{id}/git/diff endpoint
  • Any authenticated user can exploit this vulnerability,

Attack Capabilities

An attacker can:

  1. Execute arbitrary commands on the runtime container as root
  2. Read sensitive files including .env, API keys, source code
  3. Write arbitrary files to inject malicious code
  4. Establish reverse shells for persistent access
  5. 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.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

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

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2026-55255 HIGH POC
8.4 Jun 19

Cross-user flow execution in Langflow (< 1.9.1) lets any authenticated API-key holder run another user's flow by passing

Share

CVE-2026-33718 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy