Skip to main content
Phase 2 Baseline

Platform

Security

How TaurusX is built, hardened, and operated securely.

Back to Documentation

Overview

TaurusX is designed with security as a first-class architectural concern — not an add-on. The platform uses a layered defence model: each surface enforces its own security controls, and all controls reinforce each other. No single point of failure can compromise the system.

The Phase 2 security baseline covers ten areas: web hardening, API hardening, mobile security, OS Chat input safety, Meta-Agent limits, Governance enforcement, Routing Engine isolation, Preferences encryption, Terminal/CLI hardening, and developer guidelines.

TaurusX undergoes continuous security review. Discovered vulnerabilities should be reported to security@taurusx.app. Do not open public issues for security findings.

Web Security Hardening

All TaurusX web surfaces (OS, Guardian Console, public site) enforce the following controls on every response:

ControlImplementationValue
Content-Security-PolicyNext.js Middlewaredefault-src 'self'; frame-ancestors 'none'; form-action 'self'
HSTSMiddleware + proxymax-age=63072000; includeSubDomains; preload
X-Frame-OptionsMiddlewareDENY
X-Content-Type-OptionsMiddlewarenosniff
Referrer-PolicyMiddlewarestrict-origin-when-cross-origin
Permissions-PolicyMiddlewarecamera=(), microphone=(), geolocation=()

CSRF Protection

TaurusX uses a double-layer CSRF defence. For JSON API calls, Origin/Referer headers are validated against the allowed-host list. For form-based submissions, the Double-Submit Cookie pattern is enforced: the tx_csrf cookie must match the X-CSRF-Token header. Bearer token and API-key callers are exempt (not browser CSRF targets).

XSS Prevention

All user-generated content (personal notes, profile fields, preferences) passes through sanitize.ts before storage and before rendering. The sanitizer strips dangerous HTML tags, event handlers, and javascript: / data: URIs. AI-generated Markdown is sanitized before rendering to prevent injected scripts.

Session Security

PropertyValue
Cookie nametx_session (OS), tx_admin_session (Guardian)
HttpOnlytrue — not accessible via JavaScript
SameSitelax (OS session), strict (admin session)
Secure flagtrue in production — HTTPS only
Session TTL7 days (auto-renew on activity)
Re-auth window15 minutes for sensitive operations
Sessions are validated in every Route Handler, not just at the middleware level. Middleware checks cookie presence; DB validation happens at the handler layer.

API Hardening

Authentication & Authorization

Every API endpoint is protected by one or more of: session cookie, Bearer token, or API key validation. All three are checked and validated against the database — not just verified for presence. The apiGuard() helper combines auth, role checks, IDOR validation, rate limiting, and input validation in a single composable call.

Input Validation

All JSON bodies, query parameters, and path parameters are validated against Zod schemas before processing. Validation errors return structured 400 responses with per-field issue details. Raw validation errors never reach production responses.

Rate Limiting

TierScopeLimit
Edge (middleware)Per IP60 req/min (default), 20 req/min (sensitive)
Postgres-backedPer user / workspace / IPPlan-tiered (60–10,000 req/5 min)
Zero-TrustPer email (auth flows)Escalating cooldown on failures
CLI revocationPer IP10 req/min

Sensitive endpoints — /api/security, /api/meta-agent,/api/governance, /api/preferences,/api/billing, /api/agents,/api/workflows — are on the 20 req/min strict tier.

Error Responses

Production API errors return a sanitized envelope: error (code),message (user-safe text). No stack traces, no file paths, no SQL details, no internal class names. Development environments include a dev field with the full error for debugging.

Safe Logging

All server-side logs pass through safeLog.ts. The logger automatically redacts Bearer tokens, session cookies, API keys, JWTs, email addresses, phone numbers, credit card numbers, and file paths before writing to stdout. Strings are truncated at 2,000 characters.

Mobile App Security

The TaurusX mobile app (iOS / Android) applies the following security measures:

ControlImplementation
Sensitive data storageexpo-secure-store (AES-256, backed by Keychain on iOS, Keystore on Android)
Token storageSecureStore — never written to AsyncStorage or local JSON
TLS enforcementAll network calls via secureFetch — non-HTTPS rejected in production
Host allowlistsecureFetch validates hostname against registered TaurusX hosts
Request timeout30 seconds — prevents hanging requests
Deep-link validationdeepLinkGuard.ts — validates scheme, path, params before processing
Blocked deep-link paramstoken, access_token, password, session, api_key
Deep links to sensitive paths (/settings/profile/security,/settings/billing, /admin) are blocked regardless of authentication status. Those paths require intentional in-app navigation.

OS Chat & Desktop Hardening

The OS Chat Screen and Desktop Continuum apply a security pipeline to every message before it reaches the Routing Engine and before any response is rendered:

StageWhat it does
Input sanitizationStrips dangerous HTML tags and event handlers from user messages
Link sanitizationValidates all Markdown links — unsafe URLs are replaced with #
Prompt injection detectionPattern-matches against known injection phrases; replaces with safety placeholder
Response sanitizationsanitizeRenderedHtml() on all assistant output before display
Session re-auth checkHigh-risk actions (delete account, billing, key rotation) require re-auth within 15 min

Prompt injection detection looks for patterns such as "ignore previous instructions", "DAN mode", injected system prompts via code fences, and role-reset instructions. Detected patterns are neutralized — the user message is still processed with the injected content replaced by a safety placeholder.

Meta-Agent Safety Limits

LimitValueWhy
MAX_RECURSION_DEPTH5Prevents infinite delegation chains
MAX_PLAN_STEPS20Caps plan complexity and execution time
MAX_TOOL_CALLS_PER_RUN50Hard stops runaway tool loops
MAX_CONTEXT_TOKENS32,000Prevents context poisoning attacks
PLAN_REVIEW_THRESHOLD5 stepsPlans with ≥ 5 steps require user confirmation

The meta-agent action registry defines exactly which actions the agent may execute. Any action not in the registry is rejected. Actions are classified by category (read / write / external / system) and risk level (low / medium / high / critical).

The following actions are permanently blocked regardless of governance settings: shell execution, eval, mass notifications, delete operations on data or users, billing modifications, and password changes.

Governance Engine

The Governance Engine evaluates every high-impact action before execution. Actions are classified by risk, reversibility, and external effect.

Risk LevelExamplesDefault Behaviour
LowUpdate profile, store memoryAllowed automatically
MediumTrigger workflow, update workspaceAllowed; audit-logged
HighDelete agent, execute integration, change roleRequires explicit confirmation
CriticalDelete account, cancel billing, override governanceRequires confirmation + re-auth

Governance rules are validated on creation using a strict Zod schema. Invalid configurations are rejected before saving — you cannot create a rule that would deny all low-risk actions or has a malformed condition value. All governance decisions (allow, deny, require-approval) are written to the immutable audit log.

User boundaries from Personal Preferences are enforced by the Governance Engine. Topics marked as off-limits are checked against every proposed action and response. Boundary violations are denied and logged.

Routing Engine Security

ControlImplementation
Session isolationsessionId → userId binding; cross-user context leakage blocked
Input sanitizationsanitizeMarkdown() on every message before dispatch
Injection detectiondetectPromptInjection() on every message; patterns neutralized
History sanitizationAll conversation history entries sanitized on each request
Metadata strippingOnly primitive values allowed in routing metadata
Message length cap32,000 characters — oversized messages rejected with 400
History length cap200 entries — older history truncated automatically

Session ownership is validated on every routing request. If a session ID is presented for a different user ID than was registered at session creation, the request is rejected with a hard failure (not a safe fallback).

Preferences & Identity Security

Personal Preferences — notes, boundaries, tone settings, accessibility flags — are stored using expo-secure-store on mobile (AES-256 hardware-backed) and in the encrypted session context on web. They are never stored in plaintext local storage or in unencrypted cookies.

Boundary enforcement runs on every AI response and action across all surfaces (web, mobile, terminal, meta-agent, voice). The boundary check happens inboundaryEnforcer.ts and is called before any content is sent to the user or any action is executed.

SurfaceBoundary enforcement
Web / OS ChatcheckBoundaries() before rendering each response
MobilecheckBoundaries() on every assistant message
Voice / Hands-FreecontainsVoiceUnsafeContent() + topic check before TTS
Meta-AgentactionViolatesBoundaries() on each plan step
Terminal / CLItx ask responses are checked before display

Terminal & CLI Security

ControlImplementation
Device bindingAccess tokens include deviceId; validated on every request
Token expiryAccess token: 1 hour. Refresh token: 30 days. Hard expiry enforced.
Replay protectionSigned requests carry X-TX-Timestamp + X-TX-Nonce; nonces stored + rejected on replay
Timestamp tolerance5-minute window — requests outside this are rejected
Nonce TTL10 minutes — nonces pruned after expiry
Device revocationPOST /api/auth/cli/revoke — revokes any device session; audit-logged
Privilege checksEvery CLI command validates role against session; no elevation possible
Rate limitingCLI revocation: 10 req/min per IP; CLI authorize: subject to auth rate limits

The CLI credential file (~/.taurusx/credentials.json) is written with mode 0o600 (owner-only read/write). The preferred storage is the OS keychain via keytar.

TX Terminal routes all commands through the Guardian safety layer. Destructive file operations, privilege escalation, and network configuration changes trigger a confirmation prompt that cannot be skipped.

Developer Security Guidelines

Required for every API route

  • Use apiGuard() or manually call getSession() + hasRole()
  • Validate all inputs with validateBody() / validateQuery() and a Zod schema
  • Use safeError() / safeInternalError() in all catch blocks — never NextResponse.json({ error: err.message })
  • Log with safeLog — never console.log for server events
  • Check resource ownership for user-scoped routes (IDOR prevention)
  • Add rate limiting via checkRateLimitPg() for mutating endpoints

Never do these

  • Log tokens, passwords, session IDs, or API keys
  • Return raw error.message or stack traces in production API responses
  • Store tokens in AsyncStorage, localStorage, or cookies without HttpOnly
  • Render user-provided content as HTML without passing it through sanitize.ts
  • Hard-code secrets, API keys, or credentials in source files
  • Skip governance checks for meta-agent actions that affect external systems
  • Accept deep-link parameters named token, session, or api_key

Security modules reference

ModulePurpose
lib/security/apiGuard.tsComposable API security gate (auth + role + rate limit + validation)
lib/security/csrf.tsCSRF token generation and validation
lib/security/sanitize.tsXSS sanitization for all user content
lib/security/safeError.tsProduction-safe error responses
lib/security/safeLog.tsSecrets-redacting structured logger
lib/security/routingGuard.tsRouting Engine input sanitization + context isolation
lib/security/osChatGuard.tsOS Chat message sanitization + injection detection
lib/security/boundaryEnforcer.tsUser boundary enforcement across all surfaces
services/metaAgentGuard.tsMeta-Agent depth limits, plan validation, action registry
services/governanceGuard.tsGovernance rule validation, action classification, decisions
app/lib/security/networkGuard.tsMobile TLS enforcement, safe fetch wrapper
app/lib/security/deepLinkGuard.tsMobile deep-link validation and injection prevention
tx/src/auth/replayProtection.tsCLI token replay protection, device binding, expiry checks