Repository navigation
fix(security): write secret-bearing files 0600 over a pre-existing 0644 file (Closes #2105) - #2203
Merged
Merged
Conversation
…44 file Four writers used an in-place writeFileSync. Its `mode` option applies only when the file is created, so a pre-existing 0644 file stayed 0644: - slack-app.json (client_secret), in the extension service and the overlay copy - standalone.json (server password handshake); its comment said atomic, it was not - auth.json and account.json (provider API keys) in disconnectProviders All now go through atomicWriteFileSync (0600 tmp file + rename). The new test pre-creates each file at 0644 in a temp HOME and asserts 0600 after the write. It failed first (420 instead of 384) and passes after. The overlay copy cannot be imported from the extension tests, so it gets a source-level check. Closes #2105 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
The slack-app.json fix edits the overlay copy of connections.ts, so its hash in manifest.json was stale. drift_gate (app-bundle-gate) and the notturno drift step (fast) failed on it. Ran materialize.mjs and refresh_manifest.mjs; the manifest changes one file hash and extracted_at. Refs #2105 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Closes #2105
Description
Four writers of secret-bearing files used an in-place
writeFileSync. Itsmodeoption applies only when the file is created. A pre-existing 0644 file therefore stayed 0644 (readable by other users).~/.amico/slack-app.json(Slackclient_secret)amicode_service/connections.tsand the overlay copy ofconnections.ts~/.amico/ops/server/standalone.json(server password)writeHandshakeinserver_handshake.ts(its comment said atomic; it was not)auth.jsonandaccount.json(provider API keys)disconnectProvidersincredential_scanner.tsAll now use the existing
atomicWriteFileSync(0600 tmp file + rename). Rename swaps the inode, so the result is 0600 even over a 0644 file. No new helper.Changes: the four writers above,
test/secret_write_modes.test.ts(new, written first), andapp-bundle/manifest.json(one file hash refreshed withrefresh_manifest.mjs, because the overlayconnections.tschanged).Type of Change
Verification
pnpm -r run buildexits 0pnpm -r run testexits 0 (orpnpm -r run typecheckif tests aren't relevant)pnpm -r run typecheckpasses. The new test pre-creates each file at 0644 in a temp HOME and asserts 0600 after the write. In WSL (Linux) it failed first (mode 420 instead of 384) and passes with the fix. The related server, handshake, scanner and service tests also pass in WSL (904 tests).Manual Testing Notes
maintoo.connections.tsruns inside the engine and cannot be imported from the extension tests. It has a source-level check only, not a behavior test. The extension copy has the behavior test.🤖 Generated with Claude Code