Merge PR #14706: docs: describe absolute automation paths within granted roots

This commit is contained in:
David Mann committed 2026-11-22 00:24:38 +01:00
commit e0e1ab7de5
5 files changed
+38 -18

No files matched your search

+3 -2
View File
@@ -18,8 +18,9 @@ The control and headless TCP listeners are restricted to loopback addresses. Std
Loopback is not authentication. TCP transports require a bearer token and enforce request-byte,
batch-step, and active-connection limits. Remote file methods use an `AuthorizedWorkspace` with
independent read and write directory capabilities; paths are relative to a configured root and
fail closed when the applicable root is absent. General per-method scopes, client identity,
independent read and write directory capabilities; paths may be relative or absolute beneath an
applicable granted root. File methods fail closed when the applicable read or write authority is
absent. General per-method scopes, client identity,
encryption, and operation budgets are not implemented. See the
[Automation security model](../automation/security-model.md) and
[Automation security](../security/automation-security.md) before exposing or extending these
+8 -3
View File
@@ -24,9 +24,14 @@ socket I/O and handler waits use timeouts; MCP and headless batches are limited
JSON-lines replies and encoded MCP tool results are capped at 8 MiB, with aggregate batch reply
budgets. Headless previews have source-pixel, requested-edge, and encoded-PNG ceilings. The
bridge bounds incoming reply frames and screenshot decoding.
Automation file methods require separately configured read and write roots. Request paths are
relative, and absolute, traversal, alternate-separator, device-name, and link-escape paths are
rejected before file effects.
Automation file methods require separately configured read and write roots. Request paths may be
relative or absolute beneath the canonical or configured spelling of the applicable granted root.
Absolute paths outside that root are rejected. Accepted absolute paths are translated to relative
paths and resolved through the held directory capability. Relative requests reject empty or `.`
components and alternate separators. Absolute requests are split into native path components
before checking the root-relative remainder, so repeated separators and interior `.` components
are normalized. Both forms reject parent traversal in the remainder, disallowed component names
and link escapes before file effects.
**Known limitations:** the token is a bearer credential and grants the complete non-filesystem
control surface. There is no encryption, client identity, general per-method capability check,
+7 -3
View File
@@ -43,9 +43,13 @@ Automation is a privilege boundary because requests can cause filesystem access,
- A save without a `path` (MCP `doc_save`, `serve` `doc.save`, the control channel's `app.save`)
writes back only to the document's own PSD, PSB or `.pcraft` file in its own format; any other
save needs an explicit `path`, 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.
- Automation paths may be relative or absolute beneath the canonical or configured spelling of
the applicable granted root. Absolute paths outside that root are rejected. Accepted absolute
paths are translated to relative paths and resolved through the held directory capability.
Relative requests reject empty or `.` components and alternate separators. Absolute requests
are split into native path components before checking the root-relative remainder, so repeated
separators and interior `.` components are normalized. Both forms reject parent traversal in
the remainder, disallowed component names and link escapes 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. The policy also covers every command a command runs on its
+19 -9
View File
@@ -1,7 +1,7 @@
# Secure file handling
PhotoCraft reads and writes documents in the desktop app, CLI, headless RPC server, and MCP server.
Remote automation paths are untrusted relative names resolved beneath explicitly granted roots.
Remote automation paths are untrusted names resolved beneath explicitly granted roots.
## Implemented
@@ -11,11 +11,15 @@ Remote automation paths are untrusted relative names resolved beneath explicitly
- Native `.pcraft` saves use temporary-file/rename patterns in relevant store paths.
- `AuthorizedWorkspace` holds independent read and write directory capabilities for remote
automation.
- Absolute paths, parent traversal, alternate separators, drive/device/stream prefixes, reserved
Windows device names, empty or dot components, and link escapes are rejected before file
effects.
- Non-existent output files are supported when their parent already exists beneath the write
root. Automation does not create caller-selected directory trees.
- Absolute paths beneath the canonical or configured spelling of the applicable granted root
are translated to relative paths and resolved through the held directory capability. Absolute
paths outside that root are rejected.
- Relative requests reject empty or `.` components and alternate separators. Absolute requests
are split into native path components before checking the root-relative remainder, so repeated
separators and interior `.` components are normalized. Both forms reject parent traversal in
the remainder, disallowed component names and link escapes before file effects.
- Ordinary single-file writes support non-existent output files when their parent already exists
beneath the write root; they do not create caller-selected directory trees.
- Filesystem-bearing engine commands that have not migrated to capability I/O fail closed for
automation. Trusted local CLI subcommands and user-driven desktop file pickers keep their
intended ambient authority.
@@ -40,9 +44,15 @@ AuthorizedWorkspace
```
The handle is created from an explicit launch-time grant, preserves separate read/write
permissions, rejects absolute and escaping paths, and performs operations relative to the held
directory capability. New files require an existing in-root parent because a non-existent target
cannot be canonicalized safely.
permissions, checks absolute paths against the granted root and rejects escaping paths. File
contents are read and written through the held directory capability. On Windows UNC write roots,
directory creation and atomic-save renames use guarded ambient paths beneath the canonical root,
with each ancestor verified through its parent handle and held open. See
[Windows UNC write roots](../automation/security-model.md#windows-unc-write-roots) for the
provider and WSL limitations.
Ordinary single-file writes require an existing in-root parent. Capability-scoped multi-file
exports create their required export directory and missing ancestors beneath the write root
before writing files.
## Design requirements
+1 -1
View File
@@ -160,7 +160,7 @@ The transport is the framework's control server (`craft::automation::server` in
- `ui.inspect` `rects` maps each open document's canvas (`canvas.<index>`), each hosted dialog (its `dialogs` id) and `taskBar` to its last on-screen rect `[x0, y0, x1, y1]` in screen points; an id with no rect (absent, behind a modal dialog) is left out
- `ui.pointer` queues its events for the active document's canvas and replies at once; the canvas takes them on its next frame, so a following request sees their effect only after a frame has run. With no open document or no canvas shown it fails with `no canvas to drive` and queues nothing. `modifiers.space` is held as the Space key for the request
- `ui.screenshot {path?, focus?, window?}`: capture the main window, or the document window `window` (its id as `ui.window.open` replied it; `main` is the main window) (PNG). With no path the reply contains
base64 PNG data; a path is relative to the automation write root. Raises the window first
base64 PNG data; a supplied path may be relative to the automation write root or absolute beneath its canonical or configured spelling. Raises the window first
(default) because occluded macOS windows stop rendering. A request sent before the first frame
is queued (within the same limits and deadline) and captures once the window geometry is known,
as on 0.15. At most four captures may be outstanding (waiting for geometry, rendered or awaiting