Skip to content

fix: restrict config file permissions to owner-only (0o600)#261

Open
giwaov wants to merge 1 commit intoOpenGradient:mainfrom
giwaov:fix/config-file-permissions
Open

fix: restrict config file permissions to owner-only (0o600)#261
giwaov wants to merge 1 commit intoOpenGradient:mainfrom
giwaov:fix/config-file-permissions

Conversation

@giwaov
Copy link
Copy Markdown
Contributor

@giwaov giwaov commented Apr 8, 2026

Problem

When \opengradient config init\ saves the user's Ethereum private key to ~/.opengradient_config.json, the file is created with default permissions (typically 644), making it readable by all users on the system.

Any process or user on the same machine can read the private key and drain the wallet.

Fix

Add \OG_CONFIG_FILE.chmod(0o600)\ after writing the config file, restricting access to the file owner only.

Changes

  • **\src/opengradient/cli.py**: Added \chmod(0o600)\ call in \save_og_config()\ after \json.dump()\

Closes #257

After writing ~/.opengradient_config.json, set file permissions to
600 (owner read/write only) to prevent other users on the system
from reading the private key stored in the config.

Closes OpenGradient#257
@kylexqian
Copy link
Copy Markdown
Collaborator

Great catch, thanks for the contribution!

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.

Private key stored world-readable on disk (chmod issue in CLI config)

2 participants