DelegateRegistry.checkDelegateForERC20() and checkDelegateForERC1155() will return the maximum amount delegated even if there are multiple matching delegations with different amounts #255
It may over-report the total amount delegated in some cases
Proof of Concept
The key functions are checkDelegateForERC20 and checkDelegateForERC1155. These check if a given address from has delegated tokens to address to.
The logic checks matching delegations in this order:
A delegation with no specified rights
A delegation for the specific contract_
A delegation for the specific rights
It returns the maximum amount from any matching delegation.
This means if there are 2 delegations:
Delegation 1: 1,000 tokens delegated with no rights specified
Delegation 2: 500 tokens delegated with specific rights
checkDelegateForERC20 will return 1,000 tokens, even though the total delegated is only 1,500.
Tools Used
Manual
Recommended Mitigation Steps
• Return an array with all matching delegation amounts instead of just the maximum
• Aggregate the amounts from all matching delegations and return the total
Lines of code
https://github.com/delegatexyz/delegate-registry/blob/6d1254de793ccc40134f9bec0b7cb3d9c3632bc1/src/DelegateRegistry.sol#L210-L226 https://github.com/delegatexyz/delegate-registry/blob/6d1254de793ccc40134f9bec0b7cb3d9c3632bc1/src/DelegateRegistry.sol#L229-L245
Vulnerability details
Impact
It may over-report the total amount delegated in some cases
Proof of Concept
The key functions are checkDelegateForERC20 and checkDelegateForERC1155. These check if a given address from has delegated tokens to address to. The logic checks matching delegations in this order:
Tools Used
Manual
Recommended Mitigation Steps
• Return an array with all matching delegation amounts instead of just the maximum • Aggregate the amounts from all matching delegations and return the total
Assessed type
Other