Skip to content

fix: harden security anti-patterns across codebase#67

Open
marcus wants to merge 1 commit intomainfrom
security-footgun
Open

fix: harden security anti-patterns across codebase#67
marcus wants to merge 1 commit intomainfrom
security-footgun

Conversation

@marcus
Copy link
Copy Markdown
Owner

@marcus marcus commented Mar 21, 2026

Summary

  • Timing-attack mitigation: Replace == token comparison with crypto/subtle.ConstantTimeCompare in auth middleware (server.go)
  • SQL injection prevention: Add entity type allowlist (validEntityTables) in events.go so entityType is validated against known table names before interpolation into SQL — defense-in-depth beyond the caller's EntityValidator
  • SQL injection prevention: Add validTableName regex checks in migrations.go for all functions that interpolate table names into PRAGMA/DDL statements
  • Editor validation: Verify editor binary exists via exec.LookPath before exec in note.go and form_operations.go, with clear error messages

Test plan

  • All existing tests pass (go test ./... — 0 failures)
  • TestApplyEvent_InvalidEntityType covers rejection of unknown entity types
  • Build succeeds (go build)

🤖 Generated with Claude Code


Automated by nightshift

- Use crypto/subtle.ConstantTimeCompare for auth token comparison
  to prevent timing-attack side channels (server.go)
- Add entity type allowlist validation in sync events to prevent
  SQL injection via entityType interpolation (events.go)
- Add table name regex validation in migration helpers to prevent
  SQL injection via PRAGMA/DDL interpolation (migrations.go)
- Validate editor binary exists in PATH before exec (note.go,
  form_operations.go)

Nightshift-Task: security-footgun
Nightshift-Ref: https://github.com/marcus/nightshift

Co-Authored-By: Claude Opus 4.6 (1M context) <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