T09 · Insecure Skill Coding Practices
- Location
scripts/secrets_manager.py:61- Finding
Fast, Unsalted Master-Password Verifier Stored on Disk
- Content
View full analysis
Vulnerability Details
File Location:
scripts/secrets_manager.py, lines 61-69
Vulnerability Type: Insecure password storage and offline password-cracking oracle
Risk Level: HighVulnerable Code:
python def _save_session(self): """Save session state.""" with open(SESSION_FILE, 'w') as f: json.dump({ 'created': datetime.now().isoformat(), 'password_hash': hashlib.sha256(self.master_password.encode()).hexdigest() }, f) os.chmod(SESSION_FILE, 0o600)Technical Analysis
The session file contains a raw SHA-256 hash of the vault's master password. SHA-256 is a fast general-purpose hash and is unsuitable for password storage without a unique salt and a computationally expensive password-based key derivation function.
This verifier undermines the vault's stronger PBKDF2 protection. An attacker who obtains
~/.secrets-vault/.sessioncan test password guesses using one inexpensive SHA-256 operation per candidate instead of deriving each candidate through PBKDF2-HMAC-SHA256 with 600,000 iterations.File mode
0600limits direct access by other local users but does not protect against processes running under the same account, malware, exposed backups, copied home directories, or permission failures beforechmodis applied. In addition, the verifier provides no functional session-unlock capability:_get_session_password()returns the hash, butunlock()explicitly does not use it for decryption.Attack Path
- A user initializes or unlocks the vault, causing
_save_session()to create~/.secrets-vault/.session. - An attacker obtains the file through same-user process access, malware, an exposed backup, or a copied home directory.
- The attacker extracts the hexadecimal SHA-256 digest from
password_hash. - The attacker performs an offline dictionary or brute-force attack by hashing candidate passwords with SHA-256 and compar ...[truncated 803 chars]
- A user initializes or unlocks the vault, causing
- Remediation
View remediation
Remediation Suggestions
- Remove
password_hashfrom the session file and never persist the master password or a reusable verifier. - Because the current hash cannot decrypt the vault, remove the session mechanism entirely and require the password for each separate process invocation.
- If persistent session unlocking is required, generate a random short-lived session key and protect it with an operating-system credential facility such as macOS Keychain, Windows Credential Manager/DPAPI, or Linux Secret Service.
- Store only non-sensitive session metadata, such as an expiration timestamp, in the filesystem.
- Create sensitive files atomically with restrictive permissions at creation time rather than writing them before calling
chmod. - Delete existing
.sessionfiles during migration and advise users to rotate weak or reused master passwords because previous copies may remain in backups.
- Remove
