[security] api_key_manager.py stores encryption key in plaintext .key file with no file permissions #706
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus#706
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File:
src/api_key_manager.pyProblems:
No file permissions on the encryption key file (line 19): The
.keyfile containing the Fernet encryption key is written with default permissions. Noos.chmod(path, 0o600)orsafe_chmod()call. Any user on the system can read the encryption key, making the encryption worthless.No integrity verification (line 14): The key file is read blindly with no length/format validation. A truncated or corrupted key file silently produces a Fernet instance that can't decrypt existing data.
Plaintext encryption key at rest: The Fernet key itself is stored as raw bytes in
.key. Compare withintegrations.pywhich usescore.atomic_ioandsafe_chmodfor its data file. The key file should have the same protection.load()decrypts all keys on every call (lines 44–53):load()decrypts every stored API key and returns them as a dict. Callers get plaintext keys in memory. No access logging or audit trail.Fix:
safe_chmod(key_file, 0o600)after writing the keysecret_storagemodule instead of a standalone Fernet instance