Security hardening across Go, TypeScript, and Ruby SDKs

Merged
JE
10mo ago
+4145-148

Summary

Comprehensive security audit and hardening across all three SDK implementations. Addresses SSRF, token leakage, DoS, and race condition vulnerabilities.

Security Controls Added

ControlGoTypeScriptRuby
HTTPS enforcement (base URLs)✓✓✓
HTTPS enforcement (OAuth endpoints)✓✓✓
HTTPS enforcement (webhooks, no localhost)✓✓✓
Response size limits (50MB/1MB)✓✓✓
Error message truncation (500 chars)✓✓✓
Pagination same-origin validation✓——
Cross-origin redirect credential stripping✓✓✓
Auth manager race condition fixes✓—✓
PKCE helper utilities✓✓✓
Header redaction for logging✓✓✓

Key Fixes

  • HIGH: Authorization endpoint HTTPS validation with localhost exception
  • MEDIUM: Pagination Link header same-origin validation before first request
  • LOW: Fail-closed when httpResp.Request is nil in pagination

Files Changed

  • SECURITY.md — Documents all security guarantees
  • go/pkg/basecamp/security.go — Shared security helpers
  • go/pkg/basecamp/client.go — Pagination security, redirect protection
  • go/pkg/basecamp/auth.go — Race condition fixes
  • typescript/src/security.ts — Shared security helpers
  • ruby/lib/basecamp/security.rb — Shared security helpers
  • Comprehensive test suites for all security controls

Test plan

  • Go tests pass (go test ./...)
  • TypeScript tests pass (npm test)
  • Ruby tests pass (bundle exec rake test)
  • Race detection passes (go test -race ./...)
  • Security tests cover attack scenarios