agy-profiles treats local profile directories, OAuth tokens, MCP configurations, and localhost control sockets as high-value assets. Every privilege boundary follows fail-closed defaults using Python standard library primitives.
- Strict Permissions: Profile directories (
<root>/<profile>,data/,ide-data/,home/) are created and reconciled to mode0o700. Manifests (profile.json),.zshenv,app_storage.json, OAuth token files, and copied MCP configurations are enforced at mode0o600. - Containment Verification: Every file read, write, clone, or deletion resolves target paths with
ensure_within_root(root, candidate)(config.py) so dot-dot segments or malicious symlinks cannot escape the active profile root. Managed symlinks useensure_symlink_slot_within_rootto verify that parent slots reside strictly inside the sandboxhome/. - Host Credential Blocklist:
validate_link_relpath(isolation.py) blocks any relative link intersectingFORBIDDEN_HOME_RELPATHS, including.ssh,.gnupg,.aws,.kube,.npmrc,.netrc,.pypirc,Library/Keychains,.gemini, and shell dotfiles (.zshenv,.zshrc,.zprofile,.bashrc,.bash_profile). Re-provisioning strips unauthorized symlinks from those slots before creating real directories. - Login Shell HOME Lock: Electron apps spawn interactive login shells that source
~/.zshenvand import variables viaenv. Writing an explicitexport HOME=...andexport ZDOTDIR=...inside<profile>/home/.zshenvkeeps Antigravity environment capture confined to the sandbox.
When --inherit-config is requested during profile creation:
- Host
mcp_config.jsonandsettings.jsonfiles are parsed strictly as UTF-8 JSON objects viasanitize_mcp_json_text. - Malformed JSON or non-object payloads raise
ToolError("mcp_config_malformed")and trigger an immediate rollback deleting the partial profile directory. Raw config files containing parse errors are never copied unredacted. - Nested
env,headers,argsflags, URL userinfo (user:pass@), URL query parameters matching sensitive keys, and recognized API token prefixes are rewritten in memory to redacted markers before writing0o600files to the sandbox.
- No Broad Binary Matching:
command_matches_user_data_dir(process_guard.py) matches--user-data-dir=<resolved_path>strictly at start/whitespace token boundaries so sibling profiles (/profiles/workversus/profiles/work-2) or default host instances never collide. - Verified Ancestor and Child Traversal: Child helper processes (
language_server, MCP servers) are discovered by parent-PID traversal starting exclusively from verified--user-data-dirroot PIDs. - Graceful Escalation:
stop_profileissuesSIGTERM, polls live verified PIDs, and deliversSIGKILLonly to surviving verified PIDs before clearing lock files.
agy-profiles web protects local management endpoints against DNS rebinding, CSRF, clickjacking, and cross-origin reads:
- Loopback-Only Bind:
validate_bind_hostpermits only127.0.0.1and::1. Wildcards (0.0.0.0,::), LAN IPs, and hostnames (localhostsubject to/etc/hoststampering) are rejected before socket creation. - Host Header Enforcement: Every HTTP request is validated in constant time against the exact expected
Host:Portauthority (validate_host_header), stopping DNS rebinding attacks. - Capability URL + HttpOnly Strict Session: Startup generates an ephemeral 32-byte bootstrap token (
?token=...) and an independent 32-bytecsrf_token. Visiting/?token=<bootstrap>sets anHttpOnly; SameSite=Strictsigned session cookie; client JavaScript immediately strips?token=fromwindow.history. - Origin and Custom CSRF Header Enforcement: Every API request requires a valid signed session cookie plus exact
X-AGY-CSRFheader match. Mutating requests (POST,PATCH,DELETE) additionally enforce exactOriginheader equality withexpected_origin, blockingOrigin: nulland missingOriginheaders. ZeroAccess-Control-Allow-Originheaders are emitted. - Strict Content Security Policy and Font Containment: HTML responses emit
default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'alongsideX-Frame-Options: DENYandX-Content-Type-Options: nosniff. Self-hosted variable font requests under/fonts/require single-segment.woff2or.wofffilenames resolved insideweb_static/fonts/. All UI components render untrusted strings through React JSX auto-escaping with zerodangerouslySetInnerHTML.
If you discover a boundary bypass, symlink escape, token leakage vector, or web server flaw, open a private GitHub security advisory on harrymove-ctrl/agy-profiles or inspect the failing invariant using agy-profiles obligations --json.