Skip to content

security: path traversal guard, MCP audit logging, chmod warning#709

Open
EstbanIsLife wants to merge 1 commit into
colbymchenry:mainfrom
EstbanIsLife:security/fixes
Open

security: path traversal guard, MCP audit logging, chmod warning#709
EstbanIsLife wants to merge 1 commit into
colbymchenry:mainfrom
EstbanIsLife:security/fixes

Conversation

@EstbanIsLife

Copy link
Copy Markdown

Summary

  • Path traversal protection (src/db/index.ts): DatabaseConnection.initialize() and .open() now reject paths containing .. and paths without a .db extension, preventing a caller from being tricked into opening an arbitrary file as a SQLite database.
  • MCP tool-call audit log (src/mcp/session.ts): Every tool invocation now writes a line to stderr with ISO timestamp, process PID, and tool name, making unexpected calls visible in daemon logs.
  • Socket chmod warning (src/mcp/daemon.ts): The fs.chmodSync(0o600) failure was swallowed silently. It now emits a stderr warning so permission issues on shared/network filesystems do not go unnoticed.

All three issues were identified during a static security review of the codebase.

Test plan

  • npm run build passes without errors
  • DatabaseConnection.initialize('../../../etc/passwd') throws Invalid database path: path traversal not allowed
  • DatabaseConnection.initialize('/tmp/test.txt') throws Invalid database path: must have .db extension
  • A valid path like .codegraph/codegraph.db still works normally
  • MCP tool calls appear in daemon stderr log

Generated with Claude Code

- Reject `..` in DatabaseConnection paths and enforce .db extension
  to prevent path traversal via initialize/open.
- Log every MCP tool call to stderr (timestamp, pid, tool name)
  so unexpected invocations are visible in daemon logs.
- Surface daemon socket chmod failure as a stderr warning instead
  of silently swallowing it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant