Skip to content

Security/cookie auth hardening#603

Open
zvrr wants to merge 3 commits intojackwener:mainfrom
zvrr:security/cookie-auth-hardening
Open

Security/cookie auth hardening#603
zvrr wants to merge 3 commits intojackwener:mainfrom
zvrr:security/cookie-auth-hardening

Conversation

@zvrr
Copy link
Copy Markdown

@zvrr zvrr commented Mar 30, 2026

Description

Related issue:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (if new adapter)
  • Updated docs/adapters/index.md table (if new adapter)
  • Updated sidebar in docs/.vitepress/config.mts (if new adapter)
  • Updated README.md / README.zh-CN.md when command discoverability changed
  • Used positional args for the command's primary subject unless a named flag is clearly better
  • Normalized expected adapter failures to CliError subclasses instead of raw Error

Screenshots / Output

zz and others added 3 commits March 30, 2026 16:51
Addresses five security issues identified in code audit:

1. Daemon Bearer-Token Authentication
   - Generate crypto.randomBytes(32) token at startup
   - Write to ~/.opencli/daemon.token (mode 0o600)
   - Require Authorization: Bearer <token> on all non-/ping endpoints
   - Constant-time comparison prevents timing side-channels
   - daemon-client.ts lazily reads & caches token; auto-refreshes on 401
   - Token file deleted on daemon shutdown

2. Extension ID Pinning (optional hardening)
   - New OPENCLI_EXTENSION_ID env var for strict WebSocket origin check
   - Rejects any chrome-extension:// origin that doesn't match the pin

3. HttpOnly Cookie Warning + Redaction
   - OPENCLI_VERBOSE=1 emits warning when httpOnly cookies are returned
   - OPENCLI_REDACT_COOKIES=1 or getCookies({ redact: true }) replaces
     httpOnly and sensitive-named cookie values with '[REDACTED]'
   - New isSensitiveCookieName() / redactCookies() helpers in types.ts

4. CDP Endpoint Localhost Enforcement
   - assertLocalhostEndpoint() blocks non-loopback OPENCLI_CDP_ENDPOINT
   - Override with OPENCLI_CDP_ALLOW_REMOTE=1 for advanced use cases

5. Pipeline fetch credentials:"include" risk comment
   - Documents CSRF risk and required URL trust requirement

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.

2 participants