[Bug]: request_secret file delivery leaves plaintext secrets on disk for up to ~25 hours, long enough to end up in regular backups #48078
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Have an agent call
request_secretwithdelivery: "file"(for example, for a sudo password) and enter the value in the secret card. - The agent runs its command using the returned file path.
- Look in
<secret store>/files/afterwards: the file is still there, holding the value in plain text. - Run your regular backup (hourly or daily snapshots, file versioning, cloud sync of the home folder, etc.).
Expected behavior#
A secret delivered as a file stays on disk only as long as the command needs it, and is kept somewhere backup tools skip, so it never ends up in backups.
Actual behavior#
SecretRequests.ts writes the value in plain text to <store>/files/<id> (mode 600) inside the user's persistent T3 data folder. Nothing deletes it after use. The hourly sweepExpiredFiles job removes it only once it is older than SECRET_REF_TTL_MS (24 h), so it can stay on disk for about 25 hours. The folder isn't marked to be skipped by backup tools.
Impact: anyone with a responsible backup schedule will almost certainly back up the secret before the sweep deletes it. A sudo password or API token then lives on in backups for as long as they're kept, often months or years. Until the sweep runs, any process running as the user can also read the file.
Suggested fixes:
- Delete the delivered file within minutes rather than 24 h, or let the agent signal that it's done so the file can be deleted right away.
- Write delivered secrets somewhere backup tools normally skip, such as a per-user temporary or runtime folder (for example
$XDG_RUNTIME_DIRon Linux), instead of the persistent data folder. Also mark the folder to be skipped where the operating system supports it, e.g. aCACHEDIR.TAGfile or the system backup tool's exclusion setting. - Tell the user on the secret card where the value will be saved and how long it will stay.
Related: #34318 (same feature, different problem), #47230 (other plaintext secret).
Impact#
Major degradation or frequent failure
Version or commit#
0.1.13
Environment#
T3 Code desktop, Claude provider
Logs or stack traces#
No response
tanstack-source added labelsbug
Sign in to join this conversation.