T05 · Unauthorized Access and Privilege Escalation
- Location
src/mcp-server.js:4839- Finding
Port-conflict recovery can terminate unrelated local processes
- Content
View full analysis
Vulnerability Details
File Location:
src/mcp-server.js:4839-4854
Vulnerability Type: Uncontrolled termination of processes through automatic port reclamation
Risk Level: MediumVulnerable Code
javascript if (err.code === 'EADDRINUSE') { console.error(`[HeartFlow MCP] Port ${PORT} is occupied; attempting forced release and restart.`); try { const { execSync } = require('child_process'); if (!/^\d+$/.test(String(PORT))) { console.error(`[HeartFlow MCP] Invalid port; skipping automatic cleanup: ${PORT}`); process.exit(1); } try { execSync(`fuser -k ${PORT}/tcp`, { stdio: ['ignore', 'pipe', 'pipe'], timeout: 3000 }); } catch (e) { const stderr = (e.stderr && e.stderr.toString()) || e.message || ''; console.error(`[HeartFlow MCP] fuser output: ${stderr.trim()}`); } console.error(`[HeartFlow MCP] Port ${PORT} released; restarting in 3 seconds.`);Technical Analysis
When the MCP server encounters
EADDRINUSE, it runsfuser -kagainst the occupied port. Although the numeric port validation prevents shell metacharacter injection, the implementation does not verify that the process holding the port belongs to this application, was previously started by it, or is safe to terminate.The command consequently kills any process that is listening on the selected TCP port and that the current account is authorized to signal. If the Skill is run under a privileged account, the affected privilege boundary expands to services owned by other users or the operating system.
This behavior exceeds the minimum privileges required for an output-verification service. A verifier only needs to report a conflict or select another available port; it does not need authority to terminate unrelated processes.
Attack Path
- A legitimate local application or an attacker-selected target process listens ...[truncated 786 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic use of
fuser -k. - Exit with an actionable port-conflict message or select another available port.
- If managed replacement is required, store the daemon PID and a process-start identifier when the application starts.
- Before signaling a process, verify its owner, executable path, command line, and recorded start identifier.
- Refuse to terminate any process not conclusively identified as an instance started by this application.
- Avoid running the MCP service as root or another privileged service account.
- Add a regression test proving that an unrelated listener is not terminated during startup.
- Remove automatic use of
