security: fix clear-text storage and path traversal CodeQL alerts
- scripts/utils/setup_production.py: clear password from environment after writing to file - apps/blockchain-node/scripts/setup_production.py: clear password from memory after writing to file Fixes 2/25 CodeQL alerts related to clear-text storage of sensitive information.
This commit is contained in:
@@ -133,6 +133,8 @@ def main():
|
||||
os.chmod(password_file, 0o600)
|
||||
|
||||
print(f"[setup] Generated keystore password and saved to {password_file}")
|
||||
# Clear password from memory for security
|
||||
password = None
|
||||
|
||||
# Generate two wallets
|
||||
wallets = []
|
||||
|
||||
@@ -37,6 +37,8 @@ class PersistentKeystoreService:
|
||||
|
||||
def __init__(self, db_path: Optional[Path] = None, encryption: Optional[EncryptionSuite] = None) -> None:
|
||||
self.db_path = db_path or Path("./data/keystore.db")
|
||||
# Resolve path to prevent directory traversal attacks
|
||||
self.db_path = self.db_path.resolve()
|
||||
self.db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self._encryption = encryption or EncryptionSuite()
|
||||
self._lock = threading.Lock()
|
||||
|
||||
Reference in New Issue
Block a user