{"record":{"id":"c4cf00b4d3b12527","repo":"multica-ai/multica","slug":"attachment-path-q-resolves-outside-the-current","errorCode":null,"errorMessage":"--attachment path %q resolves outside the current working directory; attach files generated inside the task workdir rather than machine-shared paths like /tmp, where another run's stale file can be attached by mistake. Pass --allow-external-file to override.","messagePattern":"--attachment path %q resolves outside the current working directory; attach files generated inside the task workdir rather than machine-shared paths like /tmp, where another run's stale file can be attached by mistake\\. Pass --allow-external-file to override\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_issue.go","lineNumber":994,"sourceCode":"}\n\n// ensureAttachmentWithinWorkdir applies the same workdir containment guard as\n// --description-file / --content-file (MUL-4252) to a local --attachment path.\n// An agent that writes a chart/report to a machine-shared path like /tmp and\n// then attaches it could otherwise pick up another run's — possibly another\n// workspace's — stale file (the image version of the /tmp/desc.md leak). URL\n// values are filtered by the caller and never reach here. --allow-external-file\n// overrides, mirroring the text-flag escape hatch.\nfunc ensureAttachmentWithinWorkdir(cmd *cobra.Command, filePath string) error {\n\tif allow, _ := cmd.Flags().GetBool(\"allow-external-file\"); allow {\n\t\treturn nil\n\t}\n\twithin, err := fileWithinWorkingDir(filePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve --attachment path %q: %w\", filePath, err)\n\t}\n\tif !within {\n\t\treturn fmt.Errorf(\n\t\t\t\"--attachment path %q resolves outside the current working directory; \"+\n\t\t\t\t\"attach files generated inside the task workdir rather than machine-shared \"+\n\t\t\t\t\"paths like /tmp, where another run's stale file can be attached by mistake. \"+\n\t\t\t\t\"Pass --allow-external-file to override.\",\n\t\t\tfilePath)\n\t}\n\treturn nil\n}\n\n// pendingAttachment is a local --attachment file that passed URL filtering and\n// the workdir guard and has been read into memory, ready to upload.\ntype pendingAttachment struct {\n\tpath string\n\tdata []byte\n}\n\n// collectLocalAttachments validates and reads ALL local --attachment paths up\n// front, before any upload. URL-shaped values are warned and skipped (the API","sourceCodeStart":976,"sourceCodeEnd":1012,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_issue.go#L976-L1012","documentation":"A local --attachment path resolves outside the current working directory. This is the image-flavored twin of the text-file guard: it prevents attaching another run's (possibly another workspace's) stale file from machine-shared paths like /tmp. URL attachments are skipped earlier with a warning and never reach this check; --allow-external-file overrides it.","triggerScenarios":"Running `multica issue create --attachment /tmp/chart.png` or any path that, after symlink resolution on both sides, lands outside the CWD — without --allow-external-file.","commonSituations":"Agents writing charts/reports to /tmp then attaching them; parallel CI runs sharing a temp dir where run A attaches run B's screenshot; workdir symlinks pointing at outside directories.","solutions":["Generate the attachment inside the task workdir (e.g. ./chart.png) and attach that path.","If attaching an outside file is deliberate and the staleness risk is accepted, add --allow-external-file.","Use realpath on the path to see where it physically resolves — the guard follows symlinks.","Confirm the process CWD matches the directory containing the artifacts."],"exampleFix":"# before\nmv report.png /tmp/\nmultica issue create --title T --attachment /tmp/report.png\n# after\nmultica issue create --title T --attachment ./report.png","handlingStrategy":"validation","validationCode":"# generate attachments in the workdir and verify containment\n case \"$(realpath \"$ATTACH\")\" in \"$(realpath .)\"/*) ;; *) echo \"outside workdir — move it or use --allow-external-file\" >&2; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate charts/screenshots directly into the task workdir.","Never attach from /tmp or other shared dirs in parallel CI without unique subdirectories.","Reserve --allow-external-file for audited one-off overrides."],"tags":["cli","security","filesystem","attachments","workdir-guard"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}