Skip to content

Commit 11a2de2

Browse files
yeldarbyclaude
andcommitted
security(cli): fix config file permissions and login alias api_key dest
1. Config file now written with 0600 permissions (owner read/write only) instead of default 0644. Prevents other users on shared systems from reading stored API keys from ~/.config/roboflow/config.json. 2. Login alias --api-key flag now uses dest="login_api_key" to match what _login() handler reads, fixing a dead code path where the alias's --api-key value was silently ignored. 278 tests pass, all linting clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a06a059 commit 11a2de2

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

roboflow/cli/handlers/_aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def register(subparsers: argparse._SubParsersAction) -> None: # type: ignore[ty
2222
from roboflow.cli.handlers.auth import _login
2323

2424
login_p = subparsers.add_parser("login", help="Log in to Roboflow (alias for 'auth login')")
25-
login_p.add_argument("--api-key", dest="api_key_flag", default=None, help="API key (skip interactive login)")
25+
login_p.add_argument("--api-key", dest="login_api_key", default=None, help="API key (skip interactive login)")
2626
login_p.add_argument("--force", "-f", action="store_true", help="Force re-login")
2727
login_p.set_defaults(func=_login)
2828

roboflow/cli/handlers/auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ def _load_config() -> dict:
7878
def _save_config(config: dict) -> None:
7979
import json
8080
import os
81+
import stat
8182

8283
path = _get_config_path()
8384
os.makedirs(os.path.dirname(path), exist_ok=True)
84-
with open(path, "w") as f:
85+
# Write with owner-only permissions (0600) since the file contains API keys
86+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IRUSR | stat.S_IWUSR)
87+
with os.fdopen(fd, "w") as f:
8588
json.dump(config, f, indent=2)
8689

8790

0 commit comments

Comments
 (0)