31413 - [SC - Medium] DOS attack by delegating tokens at MAX_DELEGATES
Description
Bug Description
function _moveAllDelegates(address owner, address src, address dst) internal {
// You can only redelegate what you own
if (src != dst) {
if (src != address(0)) {
// ...SNIP...
}
if (dst != address(0)) {
uint32 dstCheckpoints = numCheckpoints[dst];
uint256[] memory dstTokensOld = dstCheckpoints > 0
? checkpoints[dst][dstCheckpoints - 1].tokenIds
: checkpoints[dst][0].tokenIds;
uint256 ownerTokenCount = ownerToTokenCount[owner];
require(dstTokensOld.length + ownerTokenCount <= MAX_DELEGATES, "dst would have too many tokenIds"); //@audit DoS
// Create a new array of tokenIds, with the owner's tokens added
uint256[] memory dstTokensNew = new uint256[](dstTokensOld.length + ownerTokenCount);
// Copy array
for (uint256 i = 0; i < dstTokensOld.length; i++) {
dstTokensNew[i] = dstTokensOld[i];
}
// Plus all that's owned
for (uint256 i = 0; i < ownerTokenCount; i++) {
uint256 tId = ownerToTokenIdList[owner][i];
dstTokensNew[dstTokensOld.length + i] = tId;
}
// Find the index of the checkpoint to create or update
uint32 dstIndex = _findWhatCheckpointToWrite(dst);
// dst has a new or updated checkpoint with the _tokenId added
checkpoints[dst][dstIndex] = Checkpoint({ timestamp: block.timestamp, tokenIds: dstTokensNew }); // <==
// Add to numCheckpoints if the last checkpoint is different from the current block timestamp
if (dstCheckpoints == 0 || checkpoints[dst][dstCheckpoints - 1].timestamp != block.timestamp) {
numCheckpoints[dst] = dstCheckpoints + 1;
}
}
}
}Impact
Recommendation
References
Proof Of Concept
Previous31410 - [SC - Medium] Griefing Attack using delegate will expose User...Next31416 - [SC - Insight] Impossible to set boostMultiplier to MIN_BOOST
Last updated
Was this helpful?