IMPORTANT
AI Context & Knowledge Heritage
- Subsystem: Architecture & Documentation / Core Docs / SECURITY
- Architecture:
@docs ARCHITECTURE:Documentation - Failure Path: Information drift, legacy terminology, or documentation mismatch.
- Observability: Traceability via
execution/parity_guard.py([SECURITY])
🛡️ Tadpole OS: Security Policy & Architecture
Intelligence Level: High-Fidelity (Sovereign Context)
Status: Selected engine controls documented; Plane 2 runtime and company isolation pending Version: 1.1.464
Last Hardened: 2026-11-20 (Dual-Token RBAC, Backup V2 210k PBKDF2, Hardware Biometric CryptoObject & Command Guard Hardening) Classification: Sovereign
Last Code/Docs Parity Check: 2026-11-20
🏗️ 2026-11-20 Technical Hardening (v1.1.464)
- Dual-Token RBAC & Step-Up Admin Auth: Production (
TADPOLE_ENV=production) requires distinctNEURAL_TOKEN(AuthenticatedRole::Deploy) andNEURAL_ADMIN_TOKEN(AuthenticatedRole::Admin) plus 64-hex Ed25519OVERSIGHT_PUBLIC_KEY.RequireAdminreturns403 Forbiddento deploy tokens on all privileged routes; the browser UI supports an optional in-memory-only Step-Up Administrative Token (tadpole_os_admin_key, stripped fromlocalStorage). - Encrypted Backup V2: Upgraded to
TADPOLE_SNAP_V2(210,000PBKDF2-HMAC-SHA512 rounds, min 12-char passphrase, legacyTADPOLE_SNAP_V1100k decrypt compatibility), confined snapshot paths (backups/,data/backups/,TADPOLE_BACKUP_ROOT), removed plaintext passphrase serialization fromsystem_backup.json, and enforced 48h pruning. - WebSocket & Privacy Shield (Voice & Local Audio): Post-connect JSON auth is scoped to
/v1/engine/ws, WSoversight:decisionenforcesAuthenticatedRole::Admin, and Privacy Shield (PRIVACY_MODE=true) blocks/v1/engine/live-voice(403) as well as cloud TTS (/v1/engine/speak) and cloud STT (/v1/engine/transcribe). Optional local-only audio servers (LOCAL_WHISPER_URL,LOCAL_TTS_URL) enforce strict loopback-only SSRF validation (localhost,127.0.0.1,::1) and remain permitted under Privacy Shield. Audio cache keys use engine+voice-scoped SHA-256 hashes. - Command Guard & Android Companion:
command_guard.rsblockspython,node,cargo,npm,pnpm,rustcunlessTADPOLE_TRUST_INTERPRETERS=1, restrictsgitto a strict read-only allowlist (including read-onlybranch/tagflags), and blocks UNC/drive paths and%VAR%expansion. AndroidBiometricSignatureManager.ktenforces hardware AndroidKeyStore RSA-2048 OAEPBiometricPrompt.CryptoObject(BIOMETRIC_STRONG).
🏗️ 2026-06-23 Technical Hardening (Audit Ledger v3)
Audit Ledger promoted to v3 (AUDIT-V2 domain separator retained for chain continuity); Shell Safety Scanner hardened for test isolation.
server-rs/src/security/audit/ — Merkle Audit Ledger v3
- X-001 TOCTOU Elimination: Hash computation, Ed25519 signing, and DB insertion now serialized on a single writer task. The v2 cache+DB race condition is architecturally closed.
- X-002 Field-Omission Hardening: Canonical hash uses explicit presence bytes (
0x00/0x01) formission_idanduser_idOptional fields, preventing hash collisions fromSome(x)↔Nonesubstitutions. - V2-002/V2-003/AV3-001 Secret Hygiene: Ed25519
SigningKeywrapped insecrecy::SecretBox<SecretSigningKey>; hex-decode staging buffer and env-var source string wrapped inzeroize::Zeroizing. All sensitive buffers zeroized on drop. - V2-004 Error Surface Reduction:
AuditErroris a discriminant-only enum. The underlyingsqlx::Errormessage is never propagated to callers, closing the log-injection vector. - V2-006 Bounded Startup: Worker startup DB read is bounded by a 5-second timeout; returns
Erron timeout instead of hanging indefinitely. - AV3-004 Panic Recovery: Writer task wraps
process_oneinAssertUnwindSafe + catch_unwind. A panic in one write no longer kills the entire worker loop. - Public API:
AuditWriteRequestandresp_txare now fully private.get_last_hashremoved (dead code that embodied the v2 TOCTOU).MerkleAuditTrail::recordreturnsanyhow::Result<AuditEntry>. - Test gate:
cargo testmust pass in CI as a merge gate (rand v0.10.1use rand::RngExtimport fixed).
server-rs/src/security/scanner.rs — Shell Safety Scanner
- Test Isolation: Added
ShellScanner::mock()constructor backed bySecretRedactor::noop(). Prevents test-time panics when no env secrets are loaded. - Compliance Link:
server-rs/src/security/scanner.rs(scanmethod) — no behavioral changes to production scanning logic.
🏗️ 2026-04-17 Technical Hardening (v1.1.13)
Modernized the security foundation for "Sovereign Traceability":
- Neural Shield (v1.1.5): Unified dual-mode redaction (ENV exact-match + Regex pattern-match) into a single high-performance engine. Added coverage for Anthropic, Groq, AWS, and DB connection strings.
- Sovereign Trace Synchronization: Automated injection of
X-Request-Idand W3Ctraceparentfrom headers into the internaltracingspans, ensuring 100% request-to-log correlation. - Redacted Error Surface: All
ProblemDetails(RFC 9457) responses now pass through the Neural Shield before serialization to prevent PII leakage. - Registry-Enforced Error Contracts: Stable
ProblemDetails.error_codevalues use underscore-separated codes and are covered bydocs/ERROR_REGISTRY.json; dynamic domain, infrastructure, recruitment, and quantization families declare explicit code patterns. Rust tests load the registry directly to prevent code/document drift. - Outward Gateway State Safety: Malformed imports are rejected before catalog mutation, poisoned shared-state locks fail closed through typed internal errors, and business-profile updates never hold the gateway and catalog locks simultaneously.
- Path Integrity: Canonicalized absolute root locking remains the primary defense against traversal.
🛡️ Zero Trust Security Layers
graph TD
User["Human Operator (Overlord)"]
Gate["Oversight Gate (Enforcement)"]
Merkle["Merkle Audit Hub (Integrity)"]
Shell["Shell Safety Scanner (Proactive)"]
Vault["Neural Vault (Secrets)"]
Agents["Agent Swarm (Untrusted)"]
Agents -- "Request Tool Call" --> Gate
Gate -- "Verify Status" --> Merkle
Gate -- "Approve/Deny" --> User
User -- "Grant Permission" --> Gate
Gate -- "Execute" --> Shell
Vault -- "Inject Key" --> GateOverview
Tadpole OS implements selected controls for agent execution, secrets, and financial oversight. The FR-11 Dual-Plane Permission Firewall and company isolation (NFR-1) remain requirements, not a complete Plane 2 runtime. The generic runner rejects only identities whose stored department exactly matches Plane 2: SMB-Digital-Twin (case-insensitive); other labels do not trigger the guard. Until company-scoped authorization and storage exist, use synthetic inputs and stop business workflows at preview.
1. Governance & Oversight
1.1 The Oversight Gate
Tadpole OS utilizes a "Human-in-the-loop" governance model for high-risk operations. The system automatically intercepts and blocks tool execution for:
- File System Modification: Deleting or overwriting non-workspace files.
- Budgetary Impact: High-token-usage calls or manual budget adjustments.
- Subprocess Spawning: Executing shell scripts or external binaries.
- Mission Completion: Finalized delivery of mission-critical reports.
- External Web Access: All
fetch_urlcalls trigger a mandatory Oversight Gate to prevent data exfiltration. - Privacy Shield (Model Routing): When enabled, runner calls prefer local endpoints and exclude configured cloud model slots. It is not a general network-egress control; the global monitor also sends periodic reachability probes. Use host/network controls for a true air gap.
1.2 Skill-Based Security (CBS)
Skills (Skills) are defined via structured JSON manifests.
- Permissions-First: Every skill must explicitly declare required permissions (e.g.,
shell:execute). - Standardization: All tool calls are routed through the kernel's
McpHost, ensuring consistent policy enforcement regardless of tool source.
1.3 Capability Ingestion Security
The Import Engine implements a restricted parsing model for .md files.
- Preview Safety: Imported content is parsed for review before registration. The Import Preview Modal is a human-in-the-loop review gate; it is not a network air gap or company-isolation boundary.
- Category Isolation: All manually imported capabilities are strictly assigned to the User Services category, preventing collision with protected system-level tools.
- Validation: The engine validates the structured JSON definition against strict schema requirements (
SkillDefinitionorWorkflowDefinition) before persistence.
1.4 Sapphire Shield Protocol
Enforces zero-trust execution for downloaded swarm templates.
- Binary Restriction: Templates are strictly forbidden from containing compiled binaries or executables.
- Risk Assessment: Any dynamic skill containing high-risk permissions (e.g.,
shell:execute) is automatically flagged for mandatory manual approval during the swarm initialization phase.
1.5 MCP Process and Credential Boundaries
MCP subprocesses receive a cleared environment containing the safe host variables needed to launch and the provider variables explicitly configured in their MCP entry. Provider credentials such as ${GEV_MCP_AUTHORIZATION} and ${OPENAI_API_KEY} remain supported. Engine access/admin tokens, capability signing keys, audit signing keys, and the workflow encryption key are rejected as placeholder sources or configured child environment names.
npm and pnpm, including lifecycle scripts and execution aliases, require TADPOLE_TRUST_INTERPRETERS=1 at subprocess launch. HTTP MCP discovery remains available when a dual-transport entry has an untrusted stdio fallback. This opt-in permits local code execution; it does not provide a process sandbox. Successful template install, import, and uninstall operations refresh the MCP configuration cache and close affected pooled clients.
1.6 Signed Capability Manifests & Mandatory Security Floors (SEC-05 & SEC-06)
- SEC-05 (Cryptographically Signed Manifests): High-risk capability activations (
Execute,Install,Modify,Delete,Approve) require an Ed25519-signed manifest payload (SignedCapabilityManifest).verify_and_activate()verifies the 64-byte Ed25519 signature over canonical length-prefixed bytes (canonical_payload), SHA-256 content hash, and approval ID. Active manifests are stored insigned_capability_manifests. - SEC-06 (Mandatory Security Floors & Invariants):
- Establishes a mandatory non-overridable security floor for each
CapabilityClass:Execute$\rightarrow$Prompt,Install$\rightarrow$Prompt,Modify$\rightarrow$Prompt,Delete$\rightarrow$Prompt,Approve$\rightarrow$Deny. - Unsigned policy writes (
set_capability_mode,set_agent_capability_mode,set_role_capability_mode) attempting to set a permission weaker than the mandatory floor are rejected at write time. - Evaluation (
check_capability_decision) clamps permission mode againstcapability.mandatory_floor(), unless backed by a cryptographically verified active signed capability manifest (is_signed_capability_active).
- Establishes a mandatory non-overridable security floor for each
2. Proactive Defenses
2.1 Shell Safety Scanner (scanner.rs) [DEFINE: Shell Safety Scanner]
- @docs SECURITY:ScanningPolicies (
security/scanner.rs) The engine includes a proactive regex-based scanner that inspects agent-generated code (Python/Bash) before execution. - Multi-Phase Mitigation:
- Secret Detection: Checks against known environment secrets (via
SecretRedactor) and matches patterns for OpenAI, Google, GitHub, Slack, and more. - Injection Protection: Detects command concatenation (
;,&&,||), piping (|), and output/input redirection (>,<). - Substitution Defense: Blocks command substitution (
$(),`) to prevent secondary payload execution. - Export Enforcement: Identifies and blocks raw secret exports (e.g.,
export KEY=...).
- Secret Detection: Checks against known environment secrets (via
- Enforcement Modes:
- AUDIT: Logs detections without blocking (Informational).
- ENFORCE: Terminates the tool call and notifies the agent of the safety violation (Block). Defaults to
ENFORCEin production.
- Compliance Link:
server-rs/src/security/scanner.rs(scanmethod).
2.2 Budget Guard & Persistent Metering
Financial security is enforced at the kernel level using SQLite persistence.
- Persistent Quotas: Budgets survive server restarts and are enforced across multiple sessions.
- Downtime protection: If the
BudgetGuardcannot verify remaining quota (e.g., DB lock), it defaults to a Fail-Closed state, blocking execution. - Self-Healing Throttle: The
AgentHealthmodule monitors for "fail-looping" agents. If an agent wastes budget on consecutive errors, it is automatically throttled or suspended.
2.3 Dependency Guard (dependency_guard.rs)
Pre-flight validation that all binary and environment dependencies declared by a skill's manifest are available before the skill is executed.
- Binary Availability Check:
is_binary_available(name)— shell-resolves binaries (e.g.,python,node) before allowing skill activation. - Batch Validation:
check_skill_dependencies(skills)— checks all declared deps for a set of skills, returning a structuredMissingDependencieserror if any are absent. Called byswarm.rsat recruitment time. - Source:
server-rs/src/security/dependency_guard.rs
2.4 Security Monitoring (monitoring.rs)
Continuous runtime health monitoring surfaced via the Security Dashboard.
- Resource Metrics: Tracks RAM pressure, CPU saturation, and agent error rates in real time.
- Anomaly Alerts: Emits structured tracing events tagged
[monitoring]when thresholds are breached. - Source:
server-rs/src/security/monitoring.rs
Prometheus scrapes the authenticated /v1/engine/metrics endpoint. The Compose stack mounts an operator-provided token file at /run/secrets/tadpole_metrics_token; the collector reads it through authorization.credentials_file. Store only the active engine access token in that file, without a Bearer prefix. The default host path is .secrets/prometheus-token, which is ignored by Git; set TADPOLE_METRICS_TOKEN_FILE to use a different private file. Restrict host file access and ensure the Prometheus container user can read the mount. Keep the file synchronized when the engine token changes.
3. Cryptographic Accountability
3.1 Merkle Audit Trail (security/audit/) — v3
Tadpole OS records all critical actions (ToolCalls, Decisions, PolicyChanges) in a tamper-evident cryptographic ledger (server-rs/src/security/audit/).
- Single-Writer Serialization: Hash computation, signing, and DB insertion are serialized on exactly one Tokio writer task. No other code path computes or updates the chain head (closes v1 X-001 TOCTOU race).
- Canonical Hash — Domain Separation + Length Prefixes: Every entry's hash is
SHA-256("AUDIT-V2" ‖ len(prev_hash) ‖ prev_hash ‖ len(agent_id) ‖ agent_id ‖ mission_presence_byte ‖ … ‖ len(timestamp)). Domain separator and presence bytes prevent the length-extension and field-omission attack class (closes v1 X-002). - Ed25519 Signatures: Every audit entry is optionally signed using Ed25519. The signing key is wrapped in
secrecy::SecretBoxand zeroized on drop (V2-002, AV3-001). - Bounded Liveness: Channel send and worker ACK are bounded by 5-second timeouts (v1 X-005). Worker startup DB read is also bounded (V2-006).
- Panic Recovery: The writer loop catches panics from
process_oneviacatch_unwindand continues processing (AV3-004). - Error Surface Reduction:
AuditErrorsurfaces only a kind discriminant to callers. Underlying SQL error messages are never propagated (V2-004). - Granular Verification: Full-chain (
verify_chain()), last-N (verify_last_n()), and per-record (verify_record()) verification supported. - Production Requirement:
AUDIT_PRIVATE_KEY(hex-encoded 32-byte Ed25519 secret) required for signed mode. SetAUDIT_REQUIRE_SIGNED=1to fail closed if the key is absent — the engine will refuse to start rather than run unsigned. - Source:
server-rs/src/security/audit/
4. Secret Management (Neural Vault)
4.1 Client-Side Encryption (Web Worker Isolated)
API keys are protected via the use_vault_store (Neural Vault) infrastructure.
- AES-256-GCM: Keys are encrypted client-side using a user-provided Master Passphrase.
- SubtleCrypto Protocol: Encryption relies on the browser's hardware-accelerated SubtleCrypto API.
- Secure Context Barrier: Cryptographic functions are automatically disabled if the application is not served over a secure channel (HTTPS) or local host alias (
localhost/127.0.0.1). - Worker Isolation: Decryption occurs inside a dedicated Web Worker thread, isolating key material from the main UI thread during sensitive operations.
- Selective Persistence: The encrypted API key blobs are persisted to
localStorage(key:tadpole-vault-secrets) via Zustand. The plaintext Master Key/passphrase is never written to disk, indexedDB, or sessionStorage — it lives only in memory and is cleared on lock. - Auto-Locking: Inactivity timers (default 30m) wipe the Master Key from memory, deep-freezing the engine until re-authorization.
- Emergency Purge: An Emergency Vault Reset (
reset_vault()) clears all encrypted configs from localStorage and broadcasts a LOCK signal to all open tabs, ensuring no stale encrypted data remains.
5. Resource Guard & Sandbox Awareness
Tadpole OS proactively monitors its execution environment to prevent platform-level attacks and resource starvation.
5.1 Resource Exhaustion Defense
The engine tracks critical system metrics to maintain stability and security:
- RAM Pressure Monitoring: Real-time tracking of memory usage. The interface alerts the operator if the engine or host system approaches memory limits, preventing OOM (Out Of Memory) conditions that could lead to denial of service.
- CPU Load Verification: Monitors processing intensity to detect recursive agent loops or malformed tool execution that could saturate host resources.
5.2 Sandbox Detection
The system automatically identifies its runtime environment to assess available security primitives:
- Environment Awareness: Detects if running within Docker, Kubernetes, or a Virtual Machine.
- Skill Mapping: Adjusts security assumptions based on the sandbox type (e.g., restricted filesystem access in containerized environments).
6. Network & Infrastructure Safety
6.1 Sandboxed Workspaces
Runner workspace file operations resolve paths under data/workspaces/<cluster-id>/ and apply traversal checks against the configured workspace root. This is a filesystem path boundary for those operations; it does not isolate company data, constrain every other tool, or provide a network egress boundary.
- Absolute Paths: All file tools enforce absolute, canonicalized paths to prevent symlink-escape attacks.
- Process Guard: External subprocesses are wrapped in an asynchronous watchdog with a 60s timeout to prevent resource exhaustion (Fork Bombs / Deadlocks).
7. Filesystem & Execution Security Guards (security/path_guard.rs, security/ssrf_guard.rs, security/command_guard.rs, utils/security.rs)
Tadpole OS implements specialized defense primitives decomposed across dedicated security submodules:
- Path Integrity & Workspace Boundary Enforcement (
security/path_guard.rs): Centralized path validation (validate_path) and non-forgeableSafePathwrappers applied to ALL filesystem interactions involving user-controlled data. Components are broken down and verified against illegal traversal tokens (.., root prefixes), symlink-escape attacks, and device paths, strictly locking access within authorized roots (WORKSPACE_ROOT, Execution Dir, or Codebase Root). Also provides identifier sanitization (sanitize_id()). - SSRF Prevention & Outbound URL Boundaries (
security/ssrf_guard.rs): Strict pre-flight URL verification (validate_outbound_url) blocking private and loopback IP ranges (IPv4 RFC 1918, link-local, loopback, IPv6 RFC 4193/4291) to prevent DNS rebinding, internal subnet port scanning, and cloud metadata exfiltration (e.g., AWS IMDS10.0.0.1and private subnets such as10.0.0.1). - Command Injection & Binary Whitelisting (
security/command_guard.rs): Enforces explicit executable binary whitelists, safe tokenization (parse_command_tokens/validate_shell_command), strict read-onlygitsubcommand & flag allowlists, interpreter blocking (python,node,cargo,npm,pnpm,rustcunlessTADPOLE_TRUST_INTERPRETERS=1), and injection defenses (|,;,&&,$(), UNC/drive paths,%VAR%). - Unified Security Facade (
utils/security.rs): Provides backward-compatible re-exports and core utility functions across the engine.
8. Reporting Vulnerabilities
If you discover a security vulnerability in Tadpole OS, please do not open a public issue. Instead, report it to the core security team via the designated sovereign channel.
