Run proper Security Audit #380
Replies: 3 comments 1 reply
-
|
Migrated this to discussion since it's really not a collection of issues. Concerning shell tool: yes, we warn users about it, they can turn it off and in ide-assistant context it is turned off automatically Serena doesn't send data anywhere, all data interaction is handled by the MCP client (the one exception is the token counting by anthropic API, if explicitly configured). And Serena's bash tool is as good/bad as any other bash tool from a security perspective. Some assertions in this analysis are wrong, some stuff is hallucinated. The server runs on the user's host, GDPR stuff is irrelevant. I will not go into detail here since the report is just not a good foundation for further discussion, but we can leave it in case others want to contribute or you want to continue the conversation in a more focused matter :) |
Beta Was this translation helpful? Give feedback.
-
|
Btw, it's a good standard procedure to do this kind of audit @BorisAnthony ! I recently raised security concerns for MCP servers myself on reddit |
Beta Was this translation helpful? Give feedback.
-
|
Yeah I felt unsure about posting it, sorry if it was a nuisance! 😅 Anyways, thank you for the response! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
This looks awesome!
As part of my standard procedure these days, I downloaded the codebase, opened it with Claude Code and asked it to run a thorough security analysis. The following is what it returned.
I'm not a pro at this, but it sounds serious enough that someone who knows this stuff should probably take a look.
It says "The audit found no evidence of deliberate malicious code, but identified significant security vulnerabilities that could be exploited for data exfiltration and system compromise if the tool falls into the wrong hands or is deployed inappropriately."
The recommendations at the end seem sensible too.
Apologies if this is unhelpful or annoying. I'm in no position to actually evaluate if it is "slop" or not…
Comprehensive Security Assessment Report: Serena MCP Server
Assessment Date: July 31, 2025
Assessed Version: Current main branch
Assessment Type: Static Code Analysis & Architecture Review
Risk Classification: HIGH
Executive Summary
This security audit of the Serena MCP Server codebase has identified several critical security vulnerabilities that pose significant risks for data exfiltration, unauthorized system access, and potential compromise of systems running this software. The primary concerns center around unrestricted shell command execution, network exposure, and insufficient access controls.
🔴 HIGH RISK FINDINGS
1. Arbitrary Shell Command Execution
src/serena/tools/cmd_tools.py:14-43,src/serena/util/shell.py:15-42ExecuteShellCommandToolallows execution of arbitrary shell commands with full system privilegessubprocess.Popen(command, shell=True)which enables command injection2. Network Server Binding to All Interfaces
src/serena/dashboard.py:146,src/serena/mcp.py:123,compose.yaml:140.0.0.0by default, exposing services to network"0.0.0.0"in multiple server configurations3. Unrestricted File System Access
src/serena/tools/file_tools.py, project validation functions🟠 MEDIUM RISK FINDINGS
4. External API Communication Without User Consent
src/serena/analytics.py:54-70AnthropicTokenCountclass makes API calls to Anthropic for token countinganthropic.Anthropic(api_key=api_key)client sends user content externally5. Language Server Process Spawning
src/solidlsp/ls_handler.py:184-193shell=Truesubprocess.Popen(cmd, shell=True)with potentially user-controllable commands6. Insecure Web Dashboard
src/serena/dashboard.py:59-104/get_log_messages/shutdown🟡 LOW RISK FINDINGS
7. Environment Variable Exposure
src/serena/util/shell.py:50, various configuration filesos.environ.copy()which includes all environment variables8. Persistent Data Storage
src/serena/tools/memory_tools.py, logging infrastructure.serena/memories/🔒 POSITIVE SECURITY FINDINGS
uvfor deterministic dependency resolution📋 SECURITY TEST RECOMMENDATIONS
1. Command Injection Testing
2. Network Exposure Testing
3. Path Traversal Testing
4. API Exfiltration Testing
5. Memory/Log Analysis Testing
🛡️ SECURITY RECOMMENDATIONS
Immediate Actions (Critical - Implement Within 7 Days)
Disable Shell Command Execution by Default
Bind Services to Localhost Only
Add Authentication to Web Dashboard
Medium-term Improvements (1-4 Weeks)
Implement Command Whitelisting
Add Comprehensive Input Validation
Implement Sandboxing
Add Security Configuration Options
Long-term Enhancements (1-3 Months)
Containerization and Isolation
Role-based Access Controls
Security Monitoring
Regular Security Maintenance
🚨 IMMEDIATE DEPLOYMENT RECOMMENDATIONS
For Production Environments
Network Security
System Security
SECURITY RISK LEVEL: HIGH
This codebase presents significant security risks that could lead to complete system compromise. The combination of arbitrary shell command execution, network exposure, and insufficient access controls creates a dangerous attack surface.
Risk Matrix
Recommended Usage Contexts
Compliance Considerations
This tool should only be deployed in highly controlled environments with comprehensive security controls and continuous monitoring.
Beta Was this translation helpful? Give feedback.
All reactions