Skip to content

fix: security remediation — 17 findings fixed#1

Merged
cshumac merged 15 commits intomainfrom
fix/security-remediation
Mar 21, 2026
Merged

fix: security remediation — 17 findings fixed#1
cshumac merged 15 commits intomainfrom
fix/security-remediation

Conversation

@cshumac
Copy link
Owner

@cshumac cshumac commented Mar 21, 2026

Summary

Addresses all 20 security audit findings from the fork handoff document (docs/clsh-fork-handoff.md). Fixes 17, defers 3 with documented justification.

Critical/High (P0)

P1 — Pre-daily-use

P2 — Hardening

P3 — Nice to have

Deferred (acceptable for single-user tool)

Infrastructure

  • Set up Vitest for @clsh/agent (22 tests)
  • Ran Prettier on all agent source files

Test plan

  • npm run test --workspace=@clsh/agent — 22 tests pass
  • npm run typecheck --workspace=@clsh/agent — clean
  • npm run dev — agent starts, QR code prints, phone can connect
  • Verify existing passwords still work (backward-compatible scrypt)
  • Verify biometric auth UI degrades gracefully (frontend follow-up needed)

cshumac added 15 commits March 21, 2026 13:05
Install vitest, add vitest.config.ts with node environment and globals,
update test script to vitest run --passWithNoTests for clean zero-test bootstrap.
Remove the unauthenticated /api/auth/biometric route and the
/api/auth/lock/biometric storage route. Strip credentialId, userId,
and biometricConfigured from /api/auth/password/status and
/api/auth/lock/state responses. Add test asserting these fields
and routes are absent.
Replace 4-var blocklist in buildSafeEnv with an explicit allowlist so that
secrets like AWS keys, GitHub tokens, and database URLs cannot leak into PTY
child processes. ANTHROPIC_API_KEY is explicitly allowed because running
Claude Code inside PTY is the primary use case. Export buildSafeEnv for testing.
Add MAX_STDIN_SIZE = 4096 constant and enforce it in handleStdin,
returning an error to the client if the payload exceeds the limit.
…my-claude-utils#20)

Add explicit script-src 'self' to Content-Security-Policy header and
pin better-sqlite3 and node-pty to exact versions to prevent unexpected
native binary rebuilds on version drift.
Replace -L clsh (named socket in world-accessible tmpdir) with
-S ~/.clsh/tmux.sock (explicit path in user-owned directory) to
prevent local users from connecting to or hijacking the tmux socket.
…y-claude-utils#14,my-claude-utils#17)

- Increase scrypt N from 16384 (2^14) to 131072 (2^17) per OWASP recommendation
- New hash format `scrypt:<N>$salt$key` encodes the cost parameter
- Backward-compatible verification of legacy `scrypt$salt$key` hashes (N=16384)
- Remove clientHash handling from POST /api/auth/password/setup
- Add tests for new format, N value, and legacy hash verification
…nding my-claude-utils#12)

Writes JSON-lines to stderr for auth.login, auth.login.failed,
auth.logout, auth.password.setup, ws.connected, ws.auth.failed,
and ws.disconnected events.
…utils#3)

Tracks consecutive password failures at the module level and locks
the account for 1 hour after 10 consecutive failures, bypassing the
IP-based rate limiter which fails when all clients share 127.0.0.1
through an SSH tunnel.
@cshumac cshumac merged commit 8841f90 into main Mar 21, 2026
@cshumac cshumac deleted the fix/security-remediation branch March 21, 2026 22:37
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