-
Notifications
You must be signed in to change notification settings - Fork 619
Open
Description
Description
The WalletSwarmCoordinator class in hivemind_exp/chain_utils.py accepts a private key directly as a string argument and stores it as a plain text attribute on the instance. This creates a critical security vulnerability where the private key could be leaked through exception logging, object state dumps, or inadvertent exposure.
Location
hivemind_exp/chain_utils.py - WalletSwarmCoordinator.__init__()
Severity
🔴 CRITICAL - This vulnerability could lead to complete compromise of user funds and on-chain identity.
Impact
- If an exception occurs and the object state is logged, the private key will be exposed
- Any debugging or monitoring tools that inspect object attributes could capture the key
- Gives attackers full control over the user's on-chain identity and funds
Steps to Reproduce
- Instantiate
WalletSwarmCoordinatorwith a private key - Trigger any exception that logs the object state
- Private key is visible in logs
Proposed Solution
Refactor the code to:
- Load the private key from secure sources (environment variables, secrets manager) within the class
- Never store the key as a plain text attribute
- Ensure logging mechanisms explicitly exclude sensitive attributes
- Consider using a secure key management library
# Instead of passing the key directly:
# coordinator = WalletSwarmCoordinator(private_key="0x...")
# Load from environment:
import os
class WalletSwarmCoordinator:
def __init__(self):
self._private_key = os.getenv('WALLET_PRIVATE_KEY')
if not self._private_key:
raise ValueError("WALLET_PRIVATE_KEY environment variable not set")References
Metadata
Metadata
Assignees
Labels
No labels