From ee3c9e8c7c3899079bcbbb270bcd12c208fddbd1 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:43:57 +0100 Subject: [PATCH 1/9] docs: describe absolute paths inside automation roots Clarify automation file methods and request path handling. --- book/src/automation/control-protocol.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/book/src/automation/control-protocol.md b/book/src/automation/control-protocol.md index 418fa9f50e..129eee9b77 100644 --- a/book/src/automation/control-protocol.md +++ b/book/src/automation/control-protocol.md @@ -24,8 +24,10 @@ 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 +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 are translated to relative paths and resolved through the held directory capability. +Outside-root absolute paths, parent traversal, malformed relative components and link escapes are rejected before file effects. **Known limitations:** the token is a bearer credential and grants the complete non-filesystem From 3fa7e8d1ec1a89f44153d62707706334150a4882 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:44:46 +0100 Subject: [PATCH 2/9] docs: align secure file handling with scoped absolute paths Clarified handling of remote automation paths and their validation against granted roots. Enhanced rejection criteria for absolute paths and escaping paths. --- book/src/security/secure-file-handling.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/book/src/security/secure-file-handling.md b/book/src/security/secure-file-handling.md index 36d81497c6..ffa63bf6ee 100644 --- a/book/src/security/secure-file-handling.md +++ b/book/src/security/secure-file-handling.md @@ -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,9 +11,11 @@ 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. +- 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. +- The relative path rejects parent traversal, alternate separators, drive/device/stream prefixes, + reserved Windows device names, empty or dot components, and link escapes 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. - Filesystem-bearing engine commands that have not migrated to capability I/O fail closed for @@ -40,9 +42,10 @@ 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. Operations +use the held directory capability; the requested path is never resolved with ambient authority. +New files require an existing in-root parent because a non-existent target cannot be canonicalized +safely. ## Design requirements From f107883f2b2f449a9781b691b8bf3e1eb7b0d6f8 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:45:27 +0100 Subject: [PATCH 3/9] docs: clarify granted-root paths in automation security Clarified automation path handling in security documentation. --- book/src/security/automation-security.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/book/src/security/automation-security.md b/book/src/security/automation-security.md index cc65c7dc81..462f232c70 100644 --- a/book/src/security/automation-security.md +++ b/book/src/security/automation-security.md @@ -43,9 +43,10 @@ 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 are translated to relative paths and resolved through + the held directory capability. Outside-root absolute paths, parent traversal, malformed relative + 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. The policy also covers every command a command runs on its From 414febdf1022aab925d86861d4deccaf8c8fbb55 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:35:08 +0100 Subject: [PATCH 4/9] docs: distinguish absolute normalization from relative path syntax --- book/src/automation/control-protocol.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/book/src/automation/control-protocol.md b/book/src/automation/control-protocol.md index 129eee9b77..8d5b49e4e8 100644 --- a/book/src/automation/control-protocol.md +++ b/book/src/automation/control-protocol.md @@ -26,9 +26,12 @@ budgets. Headless previews have source-pixel, requested-edge, and encoded-PNG ce bridge bounds incoming reply frames and screenshot decoding. 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 are translated to relative paths and resolved through the held directory capability. -Outside-root absolute paths, parent traversal, malformed relative components and link escapes are -rejected before file effects. +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, From fac4e4507944b2eceb0b9470693d06d554aab85a Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:35:33 +0100 Subject: [PATCH 5/9] docs: align automation security with native path normalization --- book/src/security/automation-security.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/book/src/security/automation-security.md b/book/src/security/automation-security.md index 462f232c70..b7b7147443 100644 --- a/book/src/security/automation-security.md +++ b/book/src/security/automation-security.md @@ -44,9 +44,12 @@ Automation is a privilege boundary because requests can cause filesystem access, 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 may be relative or absolute beneath the canonical or configured spelling of - the applicable granted root. Absolute paths are translated to relative paths and resolved through - the held directory capability. Outside-root absolute paths, parent traversal, malformed relative - components and link escapes are rejected before file effects. + 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 From e15b4445b8c240c796da2d90b7596834b9f5a6b5 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:36:13 +0100 Subject: [PATCH 6/9] docs: scope parent requirements to ordinary file writes --- book/src/security/secure-file-handling.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/book/src/security/secure-file-handling.md b/book/src/security/secure-file-handling.md index ffa63bf6ee..91861c444b 100644 --- a/book/src/security/secure-file-handling.md +++ b/book/src/security/secure-file-handling.md @@ -14,10 +14,12 @@ Remote automation paths are untrusted names resolved beneath explicitly granted - 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. -- The relative path rejects parent traversal, alternate separators, drive/device/stream prefixes, - reserved Windows device names, empty or dot components, and link escapes 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. +- 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. @@ -44,8 +46,9 @@ AuthorizedWorkspace The handle is created from an explicit launch-time grant, preserves separate read/write permissions, checks absolute paths against the granted root and rejects escaping paths. Operations use the held directory capability; the requested path is never resolved with ambient authority. -New files require an existing in-root parent because a non-existent target cannot be canonicalized -safely. +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 From 996b9a2a1e50889db4de0db06284c5becdf7a4a0 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:04:34 +0100 Subject: [PATCH 7/9] docs: qualify guarded Windows UNC path operations --- book/src/security/secure-file-handling.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/book/src/security/secure-file-handling.md b/book/src/security/secure-file-handling.md index 91861c444b..40b6181577 100644 --- a/book/src/security/secure-file-handling.md +++ b/book/src/security/secure-file-handling.md @@ -44,8 +44,12 @@ AuthorizedWorkspace ``` The handle is created from an explicit launch-time grant, preserves separate read/write -permissions, checks absolute paths against the granted root and rejects escaping paths. Operations -use the held directory capability; the requested path is never resolved with ambient authority. +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. From 299d237afa3acf899902d6e44879d9327bba6662 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:54:59 +0100 Subject: [PATCH 8/9] docs: align architecture overview with granted-root paths Complete the existing absolute-path documentation correction in the architecture overview. Reused mdBook build and source-policy checks passed. --- book/src/architecture/automation.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/book/src/architecture/automation.md b/book/src/architecture/automation.md index cbdd207acd..280c7e14b8 100644 --- a/book/src/architecture/automation.md +++ b/book/src/architecture/automation.md @@ -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 From efb349e838b7ccdef16f2fd4e57d18afcc8a9482 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:11:59 +0100 Subject: [PATCH 9/9] docs: clarify screenshot paths within the write grant Document the same scoped absolute paths accepted by the screenshot writer and the other automation file operations. --- docs/control-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/control-protocol.md b/docs/control-protocol.md index ecf603fe9a..0f4095ee6a 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -154,7 +154,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i - `ui.resize {width, height}`: resize the main window - `ui.gpu.simulateLoss {error?}`: act as if the wgpu device was lost (or reported an error with `error: true`). The app switches to the CPU image compositor (after a loss for the rest of the session; after an error until a successful Retry GPU) and shows the same recovery warning as on a real loss. `gpuFallbackNotice` in `ui.inspect` contains the reason while the warning is open. Keep Using CPU saves CPU compatibility for the next launch. Retry GPU saves GPU mode; after an error (`error: true`) it also builds a new GPU canvas on the same device at once (`gpuInfo.canvas` is `gpu` again, #6577), and after a loss it asks the user to save and restart. The window renderer still requires a working graphics or software adapter. Returns `wasActive` and `gpuInfo`. For testing the fallback. With `destroy: true` it destroys the window's real wgpu device instead, as a driver reset does (see `docs/development.md` › device loss): the app saves every unsaved document for recovery and closes. Returns `destroyed` - `ui.screenshot {path?, focus?}`: capture 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