You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 9, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
An inconsistency in the behaviour of balanceOf() and balanceOfBatch().
Summary
balanceOf() checks _isActive() and _isEligible(), but balanceOfBatch() returns static _balanceOf directly.
Vulnerability Detail
The hats protocol overrides balanceOf() to checks _isActive() and _isEligible(), but it doesn't override balanceOfBatch(). The balanceOfBatch() returns static _balanceOf directly:
function balanceOfBatch(address[] calldataowners, uint256[] calldataids)
publicviewvirtualreturns (uint256[] memorybalances)
{
require(owners.length== ids.length, "LENGTH_MISMATCH");
balances =newuint256[](owners.length);
// Unchecked because the only math done is incrementing// the array index counter which cannot possibly overflow.unchecked {
for (uint256 i =0; i < owners.length; ++i) {
balances[i] = _balanceOf[owners[i]][ids[i]];
}
}
}
Impact
It's inconsistency in the behaviour of balanceOf() and balanceOfBatch().
It would fail if someone creates a new version of singer gates and misuses balanceOfBatch(). Also, some protocols will be broken if a third party protocol integrates the Hats protocol with balanceOfBatch().
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
GimelSec
medium
An inconsistency in the behaviour of
balanceOf()
andbalanceOfBatch()
.Summary
balanceOf()
checks_isActive()
and_isEligible()
, butbalanceOfBatch()
returns static_balanceOf
directly.Vulnerability Detail
The hats protocol overrides
balanceOf()
to checks_isActive()
and_isEligible()
, but it doesn't overridebalanceOfBatch()
. ThebalanceOfBatch()
returns static_balanceOf
directly:Impact
It's inconsistency in the behaviour of
balanceOf()
andbalanceOfBatch()
.It would fail if someone creates a new version of singer gates and misuses
balanceOfBatch()
. Also, some protocols will be broken if a third party protocol integrates the Hats protocol withbalanceOfBatch()
.Code Snippet
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/lib/ERC1155/ERC1155.sol#L122-L139
Tool used
Manual Review
Recommendation
Override
balanceOfBatch()
and check_isActive()
and_isEligible()
.Duplicate of #85
The text was updated successfully, but these errors were encountered: