* fix(automation): block ambient filesystem bypasses Co-authored-by: Copilot <[email protected]> Copilot-Session: e77cd34a-ce3e-4981-996f-4d37d49df90d * test(automation): cover ambient path denial Co-authored-by: Copilot <[email protected]> Copilot-Session: e77cd34a-ce3e-4981-996f-4d37d49df90d * fix(automation): guard filesystem path authorization Co-authored-by: Copilot <[email protected]> Copilot-Session: e85c024b-ace5-4415-9208-b8d4e4684505 * automation: judge the first non-empty prefs segment; refuse any path without data prefs.set skips empty path segments, so `.scriptEvents.enabled` reached script events past the section check. Preset import / plugin.install with a whitespace path also read the filesystem. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Brandon Thomas <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Copilot-Session: e77cd34a-ce3e-4981-996f-4d37d49df90d Copilot-Session: e85c024b-ace5-4415-9208-b8d4e4684505
5.9 KiB
Automation security
Automation is a privilege boundary because requests can cause filesystem access, application control, UI input, preferences changes, rendering, and command execution.
Current implementation
- Desktop control binds to
127.0.0.1and uses one JSON request/reply per line. - Headless TCP refuses a successfully bound non-loopback address.
- Every desktop-control and headless-TCP connection must authenticate with a 256-bit bearer token before method dispatch.
- Encoded request lines are limited to 1 MiB on desktop and headless TCP and on the headless
JSON-lines stdio server (
photocraft-cli serve). MCP over stdio has no request-byte cap: the MCP SDK reads its own lines, and only MCP tool results are size-checked. Active TCP connections are limited to 16, and headless/MCP batches to 256 steps. - JSON-lines replies and encoded MCP tool results are limited to 8 MiB; retained batch replies have an aggregate budget and stop later steps when exhausted. The headless stdio JSON-lines transport enforces the same request/reply ceilings as TCP.
- Headless previews reject requested edges above 2048 pixels and source documents above 67,108,864 pixels before compositing. Full-size requests must fit the edge ceiling. Rendered PNGs are limited to 5 MiB before base64 encoding or file writes. Trusted-local CLI rendering retains its existing behavior.
- The MCP bridge bounds incoming replies and does not retry an operation after an oversized reply. Screenshots are decoded under separate dimension, pixel, and allocation ceilings before downscaling; the 5 MiB PNG limit applies to the returned image.
- MCP normally uses stdio and can optionally bridge to loopback control TCP.
- The bridge and UI request paths use timeouts.
- Engine commands are expected to reject invalid parameters without panicking.
- Remote filesystem methods use separately granted read and write directory capabilities.
- A save without a
path(MCPdoc_save,servedoc.save, the control channel'sapp.save) writes back only to the document's own PSD, PSB or.pcraftfile in its own format; any other save needs an explicitpath, so automation never flattens or converts over the file it opened. - Automation paths must be relative beneath the applicable root. Absolute paths, parent traversal, alternate separators, Windows device names, malformed components, and link escapes are rejected before file effects.
- Engine commands that still use ambient paths fail closed at the automation boundary. Synthetic UI input reaches the same command policy, and automation-triggered file hooks do not run user-configured script-event paths.
prefs.setapplies the engine's dotted-path normalization before checking for filesystem-bearing preference sections, including paths with leading or repeated dots. It refuses whole-preferences updates and those sections; individual safe preference keys remain available.- Applying the Preferences dialog with
ui.dialog.applyis deliberately refused over automation.
Known limitations
- no per-client or per-tool capabilities;
- no general per-client or per-tool capability model beyond filesystem read/write authority;
- no automated bulk apply of the Preferences dialog; agents can change individual safe keys with
prefs.set; - no explicit JSON-depth policy, aggregate document/session-memory accounting, compositor scratch-space accounting, or command-duration/cancellation budget;
- one thread per accepted TCP connection;
- no structured security audit event stream;
- desktop screenshot capture/encoding and document import/export have no automation-specific operation budgets; the desktop transport limits replies after their creation;
- expensive engine commands are not charged to a session budget.
Reply rejection can happen after a command has changed state. Such errors report that the operation may have completed. Exhausting a batch reply budget stops subsequent steps, including when normal command errors would allow the batch to continue; it does not roll back prior edits. See Control protocol for the authoritative protocol reference.
Proposed session model
The transport now establishes an authenticated connection from a cryptographically random credential before method discovery. A future security gateway should turn that authenticated connection into a short-lived, capability-scoped session.
Remaining capabilities should be explicit and composable, for example:
DocumentRead
DocumentWrite
UiInspect
UiControl
FilesystemRead (implemented as a root capability)
FilesystemWrite (implemented as a separate root capability)
PreferencesWrite
ApplicationControl
Names and granularity remain a design proposal. The important property is that a client granted document inspection is not implicitly granted arbitrary file writes, pointer injection, preferences changes, or application shutdown.
Proposed request budgets
The gateway should enforce and test finite values for:
- request bytes and JSON nesting;
- batch steps and nested/recursive calls;
- concurrent connections and per-client in-flight requests;
- render dimensions and returned payload bytes;
- document pixels, decoded bytes, and aggregate session memory;
- command duration or cancellation where the engine supports it.
Limits should fail with stable errors, be applied before expensive work, and be configurable only inside safe global ceilings. Audit events should capture session identity, capability decision, method/command ID, outcome, duration, and redacted path handle—not file contents, tokens, or secrets.
Deployment guidance today
Prefer stdio, start control TCP only when needed, grant the narrowest read and write roots, use a private token file, keep the listener on loopback, use a least-privileged OS account, and isolate untrusted agents from sensitive files. Do not commit or log bearer tokens. Do not tunnel or proxy the unencrypted loopback protocol to another host.