Description:Description\
The VaultBitcoinWallet contract includes a mechanism to update the offchain signer's public key. However, the current implementation appends new public keys to an array (offchainSignerPubKeys) without removing or invalidating the old ones. This can lead to incorrect indexing of public keys in functions that directly depend on the length of the array to determine the index of the latest key. Specifically, functions that use uint256 _offchainPubKeyIndex = offchainSignerPubKeys.length - 1; may point to an incorrect public key if the array size is updated due to the addition of new keys.
Attack Scenario\
Initial Setup:
The contract owner sets an initial offchain signer public key.
This key is used for various operations within the contract.
Key Update:
The contract owner updates the offchain signer public key.
Each update appends a new key to the offchainSignerPubKeys array without removing the old ones.
Incorrect Indexing:
Functions like deriveChangeInfo and generateOrder use the length of the offchainSignerPubKeys array to determine the index of the latest key.
Due to the accumulation of old keys, the index might point to an incorrect or outdated key.
Security Risk:
If an old key is compromised and not invalidated, it could be used maliciously.
Functions that rely on the index of the public key might retrieve an outdated or compromised key, leading to security vulnerabilities.
The current implementation of updateOffchainSignerPubKey in the VaultBitcoinWallet contract appends new keys to an array without removing old ones. This can lead to incorrect indexing of public keys in functions that depend on the length of the array to determine the index of the latest key. To mitigate these issues, implement a mechanism to remove or invalidate old keys when a new key is added. This ensures that the contract remains efficient, secure, and accurate in its key management.
Github username: -- Twitter username: -- Submission hash (on-chain): 0x7f1d9c03edb42432be307e31bee3be6ac7f865798c343078bde740fac37396ab Severity: medium
Description: Description\ The
VaultBitcoinWallet
contract includes a mechanism toupdate
theoffchain signer's public key
. However, the current implementationappends
new public keys to an array (offchainSignerPubKeys
) withoutremoving
orinvalidating
the old ones. This can lead to incorrectindexing
of public keys in functions thatdirectly
depend on thelength
of the array to determine the index of the latest key. Specifically, functions that useuint256 _offchainPubKeyIndex = offchainSignerPubKeys.length - 1;
may point to anincorrect
public key if the array size is updated due to the addition of new keys.Attack Scenario\
Initial Setup: The contract owner sets an initial offchain signer public key. This key is used for various operations within the contract.
Key Update: The contract owner updates the offchain signer public key. Each update appends a new key to the
offchainSignerPubKeys
array without removing the old ones.Incorrect Indexing: Functions like
deriveChangeInfo
andgenerateOrder
use thelength
of theoffchainSignerPubKeys
array to determine the index of the latest key. Due to the accumulation of old keys, the index might point to an incorrect or outdated key.Security Risk: If an old key is compromised and not invalidated, it could be used maliciously. Functions that rely on the index of the public key might retrieve an outdated or compromised key, leading to security vulnerabilities.
Attachments
Proof of Concept (PoC) File