Repository navigation
feat(security): enforce fail-closed capability-based security across Web, Android, iOS, and CLI - #103
Merged
Merged
Conversation
…Web, Android, iOS, and CLI Untrusted or AI-authored 3D and XR scenes can embed declarative `userData.xr` traits, external glTF image/splat/audio URIs, or host attributes that trigger outbound network connections, camera/viewport capture, microphone streaming, spatial sensor reads, persistent storage writes, LLM calls, or external OS AR handoffs without explicit host opt-in. Gate all sensitive host side effects across Web (`<three-live>` and `<xr-live>`), Android (`ThreeLiveCapabilities`), iOS/visionOS (`ThreeLiveCapabilities`), and `three-live-cli` static HTML validation (`TL401` and `TL403`) behind nine canonical capabilities (`scripts`, `network`, `remote_content`, `camera`, `microphone`, `sensors`, `storage`, `ai`, and `external_handoff`): - Default all capabilities to disabled on Web (`CAPABILITIES_NONE`, keeping legacy `allow-client-scripts` as an alias for `scripts`) and default all capabilities except in-memory Boa `scripts` to disabled on Android and iOS (`ThreeLiveCapabilities.DEFAULT` / `.default`). - Support presets (`none`, `viewer`, `all`), `-<cap>` negations, and scheme/origin network allowlists (`network:https,wss@https://cdn.example.com`) while permitting local `blob:`, `data:`, `file:`, `asset:`, and `content:` URIs without network access. - Emit credential-, query-, and fragment-stripped `three-capability-denied` / `CapabilityDeniedEvent` diagnostics with frame-loop deduplication so denied traits degrade gracefully without breaking scene rendering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements fail-closed Capability-Based Security (
ThreeLiveCapabilities) across Web (three-live+xr-live), Android (mobile/android), iOS/visionOS (mobile/ios), andthree-live-clistatic HTML linting (compiler/).Canonical Capabilities (
9)scripts: Compiling or executing<script type="text/three">/executeScript()(legacyallow-client-scriptsremains supported as an alias on Web; enabled by default in nativeThreeLiveCapabilities.DEFAULT/.defaultfor in-memory Boa compilation, disabled in.NONE/.zero).network: Outboundfetch,WebSocket, and WebRTC signaling connections, with scheme and origin allowlist support (network:https,wss@https://cdn.example.com).remote_content: Remote.glb,.usdz,script-src, HDRI environment/skybox maps,texture-pack, externalgltf.images[].uri,.splat/.spzGaussian splat clouds, and remote spatial audio URLs (also requiresnetworkfor network schemes; localblob:,data:,file:,asset:, andcontent:URIs remain local).camera: Immersive AR passthrough sessions, viewport frame capture (captureViewFrame, WebMCPcapture_xr_view,RendererFrameSource,ARViewFrameSource, Gemini Live frame streaming), and object detection loops.microphone: Speech recognition (startVoiceEdit,holdToAsk), realtime voice sessions (AIVoiceSession), Gemini Live PCM audio input, andshared-room-voiceWebRTC signaling.sensors: Immersive VR sessions, WebXR/ARCore/ARKit plane, mesh, and depth reads, WebMCP pose/gaze/depth tools, and 25-joint hand pose/gesture polling.storage: Persistent anchor reads/writes (localStorage,#xr-stateURL hashes) and AI texture disk/IndexedDB caches.ai: LLM scene editing (editScene), image-to-scene (compileFromImage), Talk-to-Select Tier-2 model fallback, AI texture generation (generateTextures), and Gemini Live / realtime voice sessions.external_handoff: Launching external OS AR viewers (Apple AR Quick Look and Google ARCore Scene Viewer).Key Details
none,viewer(network remote_content camera external_handoff),all, and-<cap>negations (capabilities="all -ai -microphone").extras.xrtraits cannot grant capabilities omitted by the host embedder; denied operations emit credential-, query-, and fragment-strippedthree-capability-denied(CapabilityDeniedEventon Android/iOS) diagnostics with 60 Hz frame-loop deduplication while geometry continues to render cleanly.three-live-cli validate): UpdatesTL401to acceptcapabilities="scripts"/capabilities="all"and addsTL403warnings when<three-live>/<xr-live>attributes or inlineuserData.xr.*traits require capabilities omitted from the host tag.Verification
node scripts/build.js(all 23 Web bundles within gzip budgets)node scripts/build.js --test(all 42 Web test suites passing, including newcapabilities_testandxr_capabilities_test)cargo test --release(all 188 Rust compiler & linter tests passing)ThreeLiveCapabilitiesTest+ all 13 suites) & iOS/visionOS (ThreeLiveCapabilitiesTests+ Swift compiler/demo build tests) passing