Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Deny ambient installed profile discovery in automation

abc2cb28a3514a73d0
diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs
index d8e82503e..400c0d9e1 100644
--- a/crates/automation/src/workspace.rs
+++ b/crates/automation/src/workspace.rs
@@ -307,7 +307,8 @@ fn params_contain_ambient_path(id: &str, params: &Value) -> bool {
}
fn profile_command_may_read_ambient(id: &str, params: &Value) -> bool {
- if matches!(id, "color.profileMismatch" | "edit.colorSettings" | "view.proofSetup") {
+ // Installed profiles scan OS and user directories even without a request path.
+ if matches!(id, "color.profileMismatch" | "edit.colorSettings" | "edit.installedProfiles" | "view.proofSetup") {
return true;
}
matches!(id, "edit.assignProfile" | "edit.convertToProfile" | "edit.profileInfo")
@@ -752,6 +753,22 @@ mod tests {
assert!(authorize_engine_command("prefs.set", &serde_json::json!({"path": "interface.language", "value": "fr"})).is_ok());
}
+ #[test]
+ fn installed_profile_discovery_requires_filesystem_authority() {
+ for params in [serde_json::json!({}), serde_json::json!({"class": "output", "colorSpace": "cmyk"}), serde_json::json!({"path": "/outside/profile.icc"})]
+ {
+ assert!(authorize_engine_command("edit.installedProfiles", &params).is_err());
+ assert!(authorize_desktop_engine_command("edit.installedProfiles", &params).is_err());
+ assert!(authorize_engine_step("edit.installedProfiles", &params).is_err());
+ assert!(authorize_desktop_engine_step("edit.installedProfiles", &params).is_err());
+ }
+ // Built-in profiles remain usable without reading installed profile files.
+ for id in ["edit.assignProfile", "edit.convertToProfile", "edit.profileInfo"] {
+ assert!(authorize_engine_command(id, &serde_json::json!({"profile": "srgb"})).is_ok());
+ assert!(authorize_desktop_engine_command(id, &serde_json::json!({"profile": "srgb"})).is_ok());
+ }
+ }
+
#[test]
fn registry_filesystem_path_params_are_classified() {
let probe = serde_json::json!({
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index 87d1bbf65..cf4a1159a 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -145,7 +145,7 @@ automation permissions.
UI-level commands (`view.zoomIn`, `window.theme.pro`, `edit.search`, …) are also accepted by `engine.execute` and `ui.menu.invoke`.
-Commands that read or write files by path, instead of through the automation roots, are refused with "automation command `…` uses ambient filesystem paths and is disabled; use capability-scoped document methods". That covers every `file.*` command except `file.new`, the `file.close*` commands and a few path-free ones such as `file.fileInfo`, so `file.open`, `file.save`, `file.saveAs` and `file.saveACopy` always fail here: open and save with `app.open` / `app.save`. Path parameters of other commands (`layer.exportAs {path}`, `filter.distort.displace {mapPath}`, preset imports, and plug-in install/reload) are refused the same way. `prefs.set` rejects whole-preference updates and file-backed sections (`colorSettings`, `scriptEvents`, `historyLog`, `plugIns` and `scratchDisks`) so automation cannot configure ambient file access indirectly. The desktop app also refuses `image.mode.*`, which can load the colour profiles set in its preferences. The rules are in `crates/automation/src/workspace.rs`.
+Commands that read or write files by path, instead of through the automation roots, are refused with "automation command `…` uses ambient filesystem paths and is disabled; use capability-scoped document methods". That covers every `file.*` command except `file.new`, the `file.close*` commands and a few path-free ones such as `file.fileInfo`, so `file.open`, `file.save`, `file.saveAs` and `file.saveACopy` always fail here: open and save with `app.open` / `app.save`. Path parameters of other commands (`layer.exportAs {path}`, `filter.distort.displace {mapPath}`, preset imports, and plug-in install/reload) are refused the same way. `prefs.set` rejects whole-preference updates and file-backed sections (`colorSettings`, `scriptEvents`, `historyLog`, `plugIns` and `scratchDisks`) so automation cannot configure ambient file access indirectly. `edit.installedProfiles` is also refused because it scans OS and user profile directories outside the automation roots, even without a request path. The desktop app also refuses `image.mode.*`, which can load the colour profiles set in its preferences. The rules are in `crates/automation/src/workspace.rs`.
Embedded Smart Objects can be opened with `layer.smartObjects.editContents {layer?}` or
unpacked with `layer.smartObjects.convertToLayers {layer?}`. This includes Photoshop sources