Skip to content

fix(security): the Studio automation discovery file is written by the one writer of secret files, with its checks - #774

Merged
pbertsch merged 6 commits into
mainfrom
fix/automation-discovery
Nov 17, 2026
Merged

pbertsch merged 6 commits into
mainfrom
fix/automation-discovery

Conversation

@pbertsch

Copy link
Copy Markdown
Member

Summary

Finding 4 of the IDE transport note. The discovery file holds the automation token. Studio made its folder 0700 and wrote the file 0600 but did not re-check an existing folder or file, did not refuse a link, and fell back to the system temp folder with no user config folder. probe-mcp --http already did all of that for its token file in writeTokenFile.

  • New internal/secretfile is the one writer, moved from writeTokenFile with its refusals unchanged and one addition: a folder or file that belongs to another user is refused too. probe-mcp --http is now a thin wrapper over it (its tests are unchanged and pass).
  • Studio's discovery file uses it. For a file named by PROBE_STUDIO_AUTOMATION_FILE the folder is the person's own (their home folder may be 0755), so it must only be a real folder, theirs, not writable by others; the default folder must be private (0700). The file itself is always 0600, written by rename.
  • No temp-folder fallback: with no user config folder and no named file the endpoint does not start, and the error says to set PROBE_STUDIO_AUTOMATION_FILE.
  • On exit a server removes the file only while it holds its own document.

Tests and mutants

secretfile table tests (existing file open to others, file link, dangling link, not a regular file, private folder open, folder link, another user's folder and file via a seam, a shared folder writable by others, replaced flag, no temp file left, Remove only its own), and Studio tests through startAutomation (a link or open file refused and the target untouched, a folder link or writable folder refused, a readable named folder accepted with a 0600 file, no config folder leaves the temp folder empty, a stale file replaced and only own removed). Eleven mutants killed: each check removed or inverted, written in place instead of renamed, the temp fallback back, Close removing another server's file.

Test plan

  • go test -race ./internal/secretfile ./internal/mcp ./studio
  • Windows build of internal/secretfile
  • disclosure scan

🤖 Generated with Claude Code

https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF

… one writer of secret files, with its checks

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch requested a review from a team as a code owner November 17, 2026 06:14
pbertsch and others added 5 commits November 17, 2026 00:46
…mporary files are cleaned; the limits are stated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
…t write; the guards of Remove are tested

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch merged commit 4fb6187 into main Nov 17, 2026
10 of 11 checks passed
jay23606 added a commit to jay23606/flutter-probe that referenced this pull request Nov 17, 2026
… one writer of secret files, with its checks (AlphaWaveSystems#774)

## Summary
Finding 4 of the IDE transport note. The discovery file holds the automation token. Studio made its folder 0700 and wrote the file 0600 but did not re-check an existing folder or file, did not refuse a link, and fell back to the system temp folder with no user config folder. `probe-mcp --http` already did all of that for its token file in `writeTokenFile`.

- New `internal/secretfile` is the one writer, moved from `writeTokenFile` with its refusals unchanged and one addition: a folder or file that belongs to another user is refused too. `probe-mcp --http` is now a thin wrapper over it (its tests are unchanged and pass).
- Studio's discovery file uses it. For a file named by `PROBE_STUDIO_AUTOMATION_FILE` the folder is the person's own (their home folder may be 0755), so it must only be a real folder, theirs, not writable by others; the default folder must be private (0700). The file itself is always 0600, written by rename.
- No temp-folder fallback: with no user config folder and no named file the endpoint does not start, and the error says to set `PROBE_STUDIO_AUTOMATION_FILE`.
- On exit a server removes the file only while it holds its own document.

## Tests and mutants
`secretfile` table tests (existing file open to others, file link, dangling link, not a regular file, private folder open, folder link, another user's folder and file via a seam, a shared folder writable by others, replaced flag, no temp file left, Remove only its own), and Studio tests through `startAutomation` (a link or open file refused and the target untouched, a folder link or writable folder refused, a readable named folder accepted with a 0600 file, no config folder leaves the temp folder empty, a stale file replaced and only own removed). Eleven mutants killed: each check removed or inverted, written in place instead of renamed, the temp fallback back, Close removing another server's file.

## Test plan
- [x] `go test -race ./internal/secretfile ./internal/mcp ./studio`
- [x] Windows build of `internal/secretfile`
- [x] disclosure scan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant