fix: harden hooks, MCP server, and config (security audit) - #893
fix: harden hooks, MCP server, and config (security audit)#893brodsky754 wants to merge 1 commit into
Conversation
|
hey @brodsky754 — this conflicts with develop. also pls rebase onto #863 (precompact fix) first since both touch hooks_cli.py — merging in the wrong order would regress the compaction fix. thanks! |
|
Hi, thanks for the contribution. This PR has merge conflicts with Could you rebase onto If this change is no longer relevant, feel free to close the PR. (This message is part of a periodic backlog pass, sent to all open PRs that match this state.) |
config.py: write config.json and people_map.json via os.open(..., 0o600) — O_EXCL on first create, O_TRUNC on overwrite — so the files are owner-only from creation, closing the brief world-readable window between open() and chmod(). Covers all five config / people-map write paths. mcp_server.py: stop returning raw exception text (str(e)) to clients from the internal-error (`except Exception`) handlers, which leaked backend / path / stack details; return a generic "Internal error" and log the real exception server-side via logger.exception(). Deliberate ValueError validation messages and tool_add_drawer's actionable readback-failure RuntimeError are still surfaced — callers rely on them and they expose nothing internal. Rebased onto develop. The original hooks_cli.py changes are dropped: develop already validates transcript paths (_validate_transcript_path) and resolves MEMPAL_DIR before mining, making them redundant. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
01b0198 to
56768a9
Compare
|
Rebased onto current @bensig — #863 landed in What's left:
|
|
Thanks for this contribution, and apologies for the slow turnaround.
If you'd rather not pick it back up, no problem at all — just say so and I'll close it out, and thanks either way for taking the time to send it. |
Summary
_is_safe_transcript_path()to reject..traversal in transcript reads; add_is_valid_mempal_dir()to validate MEMPAL_DIR contains project markers before subprocess spawn; canonicalize all paths viaos.path.realpath()str(e)with"Internal error"in 12except Exceptionhandlers to prevent leaking file paths/internal state to MCP clients (keepsstr(e)inValueErrorhandlers for user-facing validation)config.jsonatomically withos.open(O_CREAT|O_EXCL, 0o600)to eliminate TOCTOU permission window; writepeople_map.jsonwith0o600permissions (contains PII)Context
Full security audit of the codebase found 0 Critical, 3 High, 6 Medium, 6 Low findings. This PR addresses all 3 High and 3 trivial Medium fixes. Remaining Medium/Low findings are documented in the audit report (informational only).
Test plan
.gitmarker dirs for new_is_valid_mempal_dir()validation🤖 Generated with Claude Code