Skip to content

fix(core): restrict global directory permissions#28645

Open
xmh1011 wants to merge 1 commit into
anomalyco:devfrom
xmh1011:fix/global-dir-permissions-28421
Open

fix(core): restrict global directory permissions#28645
xmh1011 wants to merge 1 commit into
anomalyco:devfrom
xmh1011:fix/global-dir-permissions-28421

Conversation

@xmh1011
Copy link
Copy Markdown

@xmh1011 xmh1011 commented May 21, 2026

Issue for this PR

Closes #28421

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

OpenCode creates several managed directories under the user data, cache, config, state, and temp roots. On Unix-like systems those directories could be created with permissions widened by the process umask, or existing directories could remain at 0755, making user-specific files readable by other local users.

This PR centralizes global directory creation through ensurePrivateDir(), creates each managed directory with mode 0700, and then applies chmod 0700 so existing directories are tightened as well. It also includes the cache root in the module-load initialization list, since bin lives under it.

The regression test imports src/global.ts in a fresh process with isolated XDG roots and verifies the data, cache, config, state, temp, log, bin, and repos directories are all 0700, including an existing data directory that starts as 0755.

How did you verify your code works?

  • npx -y bun@1.3.14 test test/global.test.ts from packages/core
  • npx -y bun@1.3.14 typecheck from packages/core
  • git diff --check
  • npx -y prettier@3.6.2 --check packages/core/src/global.ts packages/core/test/global.test.ts

Screenshots / recordings

N/A - filesystem permissions change with automated test coverage.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@xmh1011 xmh1011 force-pushed the fix/global-dir-permissions-28421 branch from 0fbf1b6 to 44bca31 Compare May 21, 2026 12:39
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.

opencode create folder with permission 0755 should be 0700

1 participant