-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[BUG] Path Traversal in API Server #1588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Review SummarySkipped posting 1 drafted comments based on your review threshold. Feel free to update them here. Draft Commentspython/composio/server/api.py:219-237
Scores:
Reason for filtering: The bug description claims there's a redundant check for missing API key, but the code snippet doesn't show this issue. The first check is for missing/empty API key, while the second check validates the key value against access_token. These are different logical checks serving different purposes. Analysis: The review comment incorrectly identifies a logical issue that doesn't exist. The first check verifies the API key exists and isn't empty, while the second check validates the key value. These are distinct validations with different error messages. The total score is well below the threshold of 13, and the comment would introduce confusion rather than fix an actual issue. |
for dep in dependencies: | ||
if not re.match(r'^[a-zA-Z0-9_\-\.]+[a-zA-Z0-9_\-\.=<>]*$', dep): | ||
return False, f"Invalid dependency format: {dep}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security: The validate_dependencies
function uses a regex that may allow some potentially dangerous characters in dependency names, which could lead to command injection.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
for dep in dependencies: | |
if not re.match(r'^[a-zA-Z0-9_\-\.]+[a-zA-Z0-9_\-\.=<>]*$', dep): | |
return False, f"Invalid dependency format: {dep}" | |
for dep in dependencies: | |
if not re.match(r'^[a-zA-Z0-9_\-\.]+[a-zA-Z0-9_\-\.=<>~!]*$', dep): | |
return False, f"Invalid dependency format: {dep}" |
if tempfile.exists(): | ||
raise ValueError("Tools from this module already exits!") | ||
raise ValueError("Tools from this module already exist!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness: The _upload_workspace_tools
function doesn't properly handle the case where the tool file already exists, raising a ValueError
instead of returning a proper HTTP response.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if tempfile.exists(): | |
raise ValueError("Tools from this module already exits!") | |
raise ValueError("Tools from this module already exist!") | |
if tempfile.exists(): | |
raise HTTPException( | |
status_code=409, | |
detail="Tools from this module already exist!" | |
) |
Hi @angrybayblade, @kaavee315 just following up to see if there’s anything we should update or clarify in the fix. Happy to make any changes if needed. Appreciate your time! |
Version: 0.7.16-rc1
Path Traversal in API Server
Description
A critical path traversal vulnerability has been identified in Composio's FastAPI server, specifically in the
/api/download
endpoint. This vulnerability allows attackers to read arbitrary files from the server's filesystem by manipulating thefile
parameter. Due to a lack of proper path validation and sanitization, an attacker can access sensitive files both within and outside the intended directory structure.The vulnerability exists because the endpoint takes a user-supplied path, converts it directly to a
Path
object, and serves the file without any path validation or directory restrictions. This allows for path traversal attacks that can access sensitive system files, configuration files containing credentials, or any other files readable by the server process.This vulnerability can be exploited without authentication if the server is run without setting the
ACCESS_TOKEN
environment variable. Even when authentication is enabled, any authenticated user (regardless of privilege level) can exploit this vulnerability to read arbitrary files.Source-Sink Analysis
Source: User-controlled input via the
file
query parameter in the/api/download
endpoint.Sink: The
FileResponse
function that serves the file content directly to the client.Vulnerable Code Path:
python/composio/server/api.py
:Authentication Mechanism:
The authentication middleware completely bypasses authentication checks if the
ACCESS_TOKEN
environment variable is not set:Proof of Concept
Impact
This vulnerability has severe security implications. Attackers can access sensitive files such as:
Contact
If you have any queries regarding this bug report, send an email to gecko@gecko.security.