.maestro/playbooks/2026-03-12-CM-Issues-PRs/2026-03-12-Issues-PRs-Triage/TRIAGE-05-Security-Fixes.md
Security issues require careful, targeted fixes. Code analysis confirms one real vulnerability (arbitrary file write via watch.context.path), one design-level concern (multi-user port sharing), and two items that need audit review rather than code changes. GitHub Actions workflows were analyzed and found to be safe — no injection vectors.
Issues addressed: #1285, #1255, #1204, #1251 Prerequisite: Phases 01-04 should be complete.
Fix arbitrary file write via watch.context.path (#1204). ✅ Added isPathWithinHomeDirectory() validation to agents-md-utils.ts, applied in writeAgentsMd() and loadTranscriptWatchConfig(). 11 new tests pass. CONFIRMED VULNERABILITY: src/services/transcripts/processor.ts line ~362 writes to a user-configured path from ~/.claude-mem/transcript-watch.json without boundary validation. The expandHomePath() in src/services/transcripts/config.ts only handles ~ expansion:
src/utils/agents-md-utils.ts, in the writeAgentsMd() function (which already blocks .git/ paths), add path boundary validation BEFORE the write:
const resolvedPath = path.resolve(agentsPath)const homeDir = os.homedir()homeDir — log warning and return early.. segments after resolution (defense in depth)src/services/transcripts/config.ts loadTranscriptWatchConfig() — reject any context.path that resolves outside the user's home directory~/.codex/AGENTS.md and ~/project/AGENTS.md must remain valid Fix cross-account data leakage on multi-user macOS (#1255). ✅ Added computePerUserPort() and getEffectiveUid() to worker-utils.ts. getWorkerPort() now derives a per-user port via basePort + (uid % 1000) when no explicit port override is set. 9 new tests pass. The worker binds to 127.0.0.1:37777 which is accessible to ALL local users on the same machine. Two users running claude-mem share the same port, causing data cross-contamination:
src/services/worker-service.ts and src/shared/SettingsDefaultsManager.ts to understand port bindingsrc/shared/paths.ts or a new utility:
process.getuid() (Unix) or os.userInfo().uid (cross-platform)37777 + (uid % 1000) — this gives each user a unique port within a 1000-port rangeCLAUDE_MEM_WORKER_PORT is NOT explicitly set by the usergetWorkerPort() to use this derived port by default'37777' as the base)~/.claude-mem/worker.sock instead of TCP. Check if Express supports UDS. This is more secure but may break Windows compatibility — document the tradeoff and implement the per-user port approach Audit and close GitHub Actions injection concern (#1285). Code analysis of all 6 workflow files in .github/workflows/ confirms NO exploitable injection vectors:
convert-feature-requests.yml uses actions/github-script@v8 with proper API calls, not shell interpolationclaude-code-review.yml and claude.yml use Anthropic's official claude-code-actionnpm-publish.yml uses standard npm workflow with no untrusted inputdeploy-install-scripts.yml uses hardcoded paths onlysummary.yml uses github.event.issue.number which is a trusted numeric value from GitHub APIAudited all 6 GitHub Actions workflows. No ${{ github.event.* }} values are interpolated into shell run: commands. convert-feature-requests.yml uses actions/github-script with API calls. All workflows follow secure patterns. Closing as not-a-vulnerability.Create security audit response document for #1251. This is a comprehensive audit request that requires documenting current security posture:
/Users/alexnewman/Scripts/claude-mem/Auto Run Docs/2026-03-12-CM-Issues-PRs/2026-03-12-Issues-PRs-Triage/Working/security-audit-response.md with YAML front matter: type: report, title: Security Audit Response, created: 2026-03-12, tags: [security, audit]127.0.0.1) with requireLocalhost middleware on admin endpointsstartsWith check)~/.claude-mem/settings.json) should be user-only (0600)~/.claude-mem/claude-mem.db) should be user-onlyRun tests and build:
npm test — all tests must passnpm run build-and-sync