Skip to content

fix(storage): create config and cache paths with owner-only permissions - #806

Open
carfeii wants to merge 1 commit into
TheR1D:mainfrom
carfeii:fix/sensitive-storage-owner-only-permissions
Open

carfeii wants to merge 1 commit into
TheR1D:mainfrom
carfeii:fix/sensitive-storage-owner-only-permissions

Conversation

@carfeii

@carfeii carfeii commented Oct 16, 2026

Copy link
Copy Markdown

Fixes #805.

The config file (which can contain OPENAI_API_KEY) and the chat/completion cache directories under the platform temp directory were created with mkdir()/open() using no explicit mode, so under a common umask of 022 the config file ended up 0644 and the directories ended up 0755, letting any other local account on a shared host read API credentials and cached conversations.

This creates the config directory and both cache directories as 0700, and the config file as 0600, explicitly chmod'ing after creation since mkdir()'s/os.open()'s own mode argument is still subject to the process umask.

Verified with a script exercising Config, Cache, and the same pattern ChatSession uses, under umask 022: before the fix, the config file and all three directories were world-readable/traversable (0644/0755); after the fix, all four are owner-only (0600/0700).

The config file (which can contain OPENAI_API_KEY) and the chat/completion
cache directories under the platform temp directory were created with
mkdir()/open() using no explicit mode, so under a common umask of 022 the
config file ended up 0644 and all directories 0755, letting any other
local user read API credentials and cached conversation content.

Create the config directory and cache directories as 0700, and the config
file as 0600, explicitly chmod'ing after creation since mkdir()/os.open()
mode arguments are still subject to the process umask.

This branch has not been deployed

No deployments
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.

API key and chat cache are stored with permissive default permissions

1 participant