Skip to content

Security Architecture

Go-Live implements defense-in-depth security across authentication, input validation, transport protection, and rate limiting. This document describes the threat model, security mechanisms, and test coverage.

Threat Model

ThreatMitigation
Unauthorized stream accessMulti-layer authentication (Token, JWT)
Room hijackingRoom name validation + per-room tokens
Denial of servicePer-IP rate limiting + payload size limits
Credential leakageConstant-time token comparison + no secrets in error responses
Path traversalRoom name regex: ^[A-Za-z0-9_-]{1,64}$
XSS via room namesInput sanitization (alphanumeric + hyphen/underscore only)
Timing attackscrypto/subtle.ConstantTimeCompare for all token comparisons

Authentication Layers

Go-Live supports three authentication methods, checked in priority order:

Token Authentication

  • Global token (AUTH_TOKEN): Single shared secret for all rooms
  • Per-room tokens (ROOM_TOKENS): room1:token1;room2:token2 format
  • Room tokens take priority over global tokens
  • Delivered via Authorization: Bearer <token> or X-Auth-Token header

JWT Authentication

  • HMAC-SHA256 signed tokens (JWT_SECRET)
  • Audience validation (JWT_AUDIENCE)
  • Expiry validation (exp claim)
  • Room restriction via room claim in JWT payload

Admin Authentication

  • Separate admin token (ADMIN_TOKEN) for administrative endpoints
  • Required for room closure and recording management

Input Validation

Room Names

Enforced by regex ^[A-Za-z0-9_-]{1,64}$:

InputResultReason
my-roomValidAlphanumeric + hyphen
test_room_1ValidAlphanumeric + underscore
../../../etc/passwdRejectedPath traversal attempt
room/../../configRejectedPath separator
<script>alert(1)</script>RejectedXSS attempt
bad roomRejectedSpace character

SDP Payload

  • Maximum size: 1MB (http.MaxBytesReader)
  • Returns HTTP 413 (Request Entity Too Large) on overflow
  • Prevents payload bombing attacks

CORS Protection

  • Origin whitelist via ALLOWED_ORIGIN environment variable
  • Preflight (OPTIONS) requests validated against whitelist
  • Disallowed origins receive no CORS headers (not *)
  • Default: * (allows all origins — configure for production)

Rate Limiting

Per-IP token bucket algorithm:

ConfigurationDefaultDescription
RATE_LIMIT_RPS0 (disabled)Requests per second per IP
RATE_LIMIT_BURST0Maximum burst size

When enabled, the rate limiter:

  1. Extracts client IP from request
  2. Checks token bucket availability
  3. Allows request and decrements bucket, or returns HTTP 429
  4. Bucket refills at configured RPS rate

Security Test Coverage

TestWhat It Verifies
TestSecurityAuthenticationBypassNo auth header, wrong token, wrong bearer → 401
TestSecurityRoomTokenAuthenticationRoom token overrides global token
TestSecurityJWTAuthenticationInvalid JWT rejected, valid JWT accepted
TestSecurityAdminAuthenticationAdmin endpoints require admin token
TestSecurityRateLimitingBurst passes, excess is limited
TestSecurityCORSProtectionAllowed origin gets CORS headers, disallowed does not
TestSecurityInputValidationPath traversal, XSS, spaces rejected
TestSecurityLargePayloadOversized SDP → 413
TestSecuritySensitiveDataExposureNo passwords/secrets in error responses

Best Practices for Production

  1. Always configure authentication: Set AUTH_TOKEN or JWT_SECRET for any public deployment
  2. Use per-room tokens: Isolate access between rooms using ROOM_TOKENS
  3. Restrict CORS origin: Set ALLOWED_ORIGIN to your domain(s), not *
  4. Enable rate limiting: Set RATE_LIMIT_RPS to prevent abuse
  5. Use HTTPS: Deploy behind a TLS-terminating reverse proxy
  6. Rotate tokens: Change tokens periodically; JWT supports expiry via exp claim
  7. Monitor metrics: Watch /metrics for rate limit rejections and auth failures

Released under the MIT License.