The attachment reader accepts temp directories as allowed roots and matches by bare prefix #2
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-info
needs-triage
question
ready-for-agent
ready-for-human
svd:go
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/apple-messages-blade-mcp#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by a read of
mainat5bc2758on 2026-11-13, during the verification fordev/messages-mind-mcpPhase A.What is wrong
The check that decides whether an attachment path is under an allowed root accepts the system temp directories in production code, and it compares by string prefix. A prefix match accepts a sibling directory whose name starts with an allowed root's name. The attachment path comes from a row in the Messages history and must be treated as untrusted. Whether a remote sender can control the stored filename has not been established.
What to decide and fix
Acceptance criteria
Blocked by
Filed under: operator word "go" sha256:4cd0e21a9a07
Triage — 2026-11-16
Disposition: confirmed bug; ready-for-agent. Priority: high, because the attachment reader can return bytes outside the promised root. No human design decision or dependency is outstanding. This ticket authorizes preparation of an implementation; it does not itself authorize dispatch or release.
Evidence
Verified against main at
ba2f5dbc1a069dd9dc6e23de035c9c949c98d6f6.Sources/AppleMessagesBlade/AttachmentReader.swift:24–30checks the expanded filename before opening it; it never resolves symlinks.Data(contentsOf:)then follows them.Sources/AppleMessagesBlade/AttachmentReader.swift:64–67admits/private/tmp/and/tmp/unconditionally and useshasPrefixfor the configured attachment root. The default root has no trailing slash, soAttachments-other/filepasses its check.MessagesBladeConfigalready accepts an explicitattachmentsRoot. Fixture tests can set their own root; a production-wide temp exception is unnecessary.AttachmentPathTestscheck an ordinary descendant, unrelated paths, and a missing temp file. They do not cover temp-file reads, prefix siblings, or symlink escapes.A throwaway Swift harness compiled the current reader with the current config, errors and attachment model declarations. It used synthetic files only and did not open chat.db or real attachments. Result: ordinary file under an explicit root passed; default-config temp-file rejection failed (bytes returned); default-root sibling predicate rejection failed (accepted); explicit-root symlink escape rejection failed (bytes returned). The symlink fixture and target were both under temp, so that read demonstrates the current failure to confine to the configured root, rather than isolating it from the broad temp allowance. No remote-sender exploit was tested or established.
Implementation brief
config.attachmentsRootthe only attachment byte root. Remove the unconditional temp roots. Tests that need temp files must pass their own isolated attachment root explicitly.attachmentNotFoundfor missing files, directories and rejected paths, and preserve the existing attachment size cap and response shape.MessagesCorestore-path policy, add an attachment reader there, or broaden the public API unnecessarily.Required verification
AttachmentReader.read(meta:), checking the specific rejection error, not just any thrown error.AttachmentPathTestsand theAppleMessagesBladeTeststarget after the change.The three original acceptance criteria remain in force, with the temp-directory decision resolved to removal of implicit exceptions.
Blocked by: none. No implementation was changed during triage.⏸ SVD architect gate: dev/apple-messages-blade-mcp#2 the-attachment-reader-accepts-temp-directories-as-allowed-ro
Status: CLEAN after 1 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
standard· dispatch effortmediumRun:
20261116T111805Z-1cde15e3Held because: CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
swift test --filter AppleMessagesBladeTestson base4669119and record the failure set. With only the read(meta:) tests applied, the rows marked red (AC 1-3, RV 3, 4, 5a, 5b, 5c) must fail and the rows marked green must pass. After the fix, every scenario row passes under its own filter, and the target failure set is otherwise unchanged. [verification]Change: Keep the read(meta:) shape at AttachmentReader.swift:22-54 and replace only the confinement step. isUnderAllowedRoot (:64-68: a bare hasPrefix check over [root, "/private/tmp/", "/tmp/"]) becomes static canonicalPath (tilde-expand, then realpath(3)), isStrictlyBelow (compares pathComponents) and confinedPath(raw, config) helpers, with config.attachmentsRoot as the only root. Every later fileExists, attributesOfItem and Data(contentsOf:) call uses the canonical path. The filename stays lastPathComponent of the display path, and errors are unchanged (attachmentNotFound and attachmentTooLarge). Extend AttachmentPathTests (UnitTests.swift:208-230) with a per-test UUID fixture under temporaryDirectory and explicit MessagesBladeConfig(attachmentsRoot:). Every scenario goes through read(meta:) with specific error equality. Add a CHANGELOG Security entry.
Files:
Sources/AppleMessagesBlade/AttachmentReader.swift·Tests/AppleMessagesBladeTests/UnitTests.swift·CHANGELOG.mdDecision: accept the 4 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-16-the-attachment-reader-accepts-temp-directories-as-allowed-ro.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-16-the-attachment-reader-accepts-temp-directories-as-allowed-ro.mdspec-verify-dispatch Half B for dev/apple-messages-blade-mcp#2 the-attachment-reader-accepts-temp-directories-as-allowed-ro completed integration verify.
0675815f980675815: absent0675815: local build green. AppleMessagesBladeTests passed (38 tests, 3 skipped, 0 failures). AttachmentPathTests passed (10 of 10). Remote CI: no statuses (absent). No blockers.0675815; remote CI truth is absent, not green.0675815: Forgejo returned no commit statuses for head0675815and no CI context has reported. No tracking pointer was found. — reported as absent, not blocking (gh#633)codex-svd ship --run-id 20261116T114111Z-8827a41a --confirm-merge)