Skip to content

🤖 fix: enforce owner-only file permissions under ~/.mux/ (CDM-01-007)#2784

Merged
ibetitsmike merged 2 commits intomainfrom
mike/cdm-01-007-file-permissions
Mar 4, 2026
Merged

🤖 fix: enforce owner-only file permissions under ~/.mux/ (CDM-01-007)#2784
ibetitsmike merged 2 commits intomainfrom
mike/cdm-01-007-file-permissions

Conversation

@ibetitsmike
Copy link
Contributor

@ibetitsmike ibetitsmike commented Mar 4, 2026

Summary

Fix CDM-01-007 (Medium): session directories and files under ~/.mux/ are created with default permissions (world-readable), exposing chat history, workspace metadata, and user prompts to other local OS users.

Background

Pentest finding CDM-01-007 identified that 31+ mkdir calls and 10+ writeFile calls operate on ~/.mux/ paths without setting restrictive permissions. Only tempDir.ts and a few secret-handling files set explicit modes.

Implementation

Process-wide umask (0o077) set at the earliest point in both entry points (src/desktop/main.ts, src/cli/index.ts). With this umask:

  • mkdir defaults (0o777) become 0o700 (owner-only)
  • writeFile defaults (0o666) become 0o600 (owner-only)
  • Existing explicit mode: 0o600 on secrets remain correct

ensurePrivateDir helper (src/node/utils/fs.ts) provides defense-in-depth with explicit mode: 0o700 at 9 high-sensitivity root-directory creation callsites (config.ts, historyService.ts, aiService.ts, workspaceService.ts, analyticsService.ts).

~55 LoC added across 8 files touched. On Windows, neither mode nor umask are enforced by Node.js — NTFS ACLs handle permissions instead, so this is a safe no-op there.


Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh • Cost: $5.27

@ibetitsmike
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac7fc70ac1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Run chmod after mkdir in ensurePrivateDir/ensurePrivateDirSync so existing directories from older installs are tightened to 0o700.

Also added async and sync tests that start from a permissive mode and verify permissions are tightened.
@ibetitsmike
Copy link
Contributor Author

@codex review

Addressed P1 feedback: ensurePrivateDir now calls chmod(dirPath, 0o700) after mkdir so pre-existing directories from older installs also get tightened. Added tests verifying this behavior.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff5ee611b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
Copy link
Contributor Author

@codex review

Addressed all prior feedback. P1 resolved with chmod for pre-existing dirs. P2 resolved as intentional design tradeoff (explained in thread).

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff5ee611b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
Copy link
Contributor Author

@codex review

All threads resolved. The P2 about CLI umask scope is an intentional design choice (explained in previous thread reply).

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit a33fcf5 Mar 4, 2026
23 checks passed
@ibetitsmike ibetitsmike deleted the mike/cdm-01-007-file-permissions branch March 4, 2026 17:11
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