SettV3.transferFrom block lock can be circumvented
The block lock in SettV3.transferFrom only checks the caller's address, not the token holder's, so an attacker can bypass it by using a second account to transfer tokens and then withdraw in the same block. This defeats the intended protection against flashloan attacks.
Submitted by cmichel
The SettV3.transferFrom implements a _blockLocked call to prevent users to call several functions at once, for example, deposit and then transferring the tokens.
function _blockLocked() internal view {
require(blockLock[msg.sender] < block.number, "blockLocked");
}
However, as the block lock only checks msg.sender, an attacker can circumvent it using transferFrom:
- Attacker owns accounts
A,BandC - A deposits,
_lockForBlock(msg.sender) = _lockForBlock(A)is called andAis locked. - A approves B.
- B calls
transferFrom(from=A, to=C, amount). This passes the_blockLocked() = _blockLocked(B)check. - C calls
withdraw().
Impact
The protection desired from the _blockLocked call does not work for this function. I assume the call is used to prevent flashloan attacks, but an attacker can bypass the protection on transferFrom.
Recommended Mitigation Steps
The block lock should be on the account that holds the tokens, i.e., on sender (“from” address), not on msg.sender. Parameterize _blockLocked to take an account parameter instead.
GalloDaSballo (BadgerDAO) acknowledged:
The finding is correct, blockLock is ineffective
The Recommended MItigation Steps proposes a DOS vector (I’ll deposit 1 wei for you so you don’t get to withdraw your funds)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The block lock was applied to the caller (msg.sender) instead of the account whose tokens are being transferred (the 'from' address).
Impact
The block lock protection is ineffective for transferFrom, allowing an attacker to bypass it and potentially carry out flashloan attacks.
What the attacker needed
Attacker controls multiple accounts; victim has deposited tokens
The fix
The block lock should be parameterised to check the token holder's address (the 'from' address) instead of the caller's address.
How it was found
- Attacker controls accounts A, B and C.
- Account A deposits tokens, which locks A for the current block.
- Account A approves account B to spend its tokens.
- Account B calls transferFrom from A to C, passing the block lock check because B is not locked.
- Account C calls withdraw().
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A block lock is a security measure that stops someone from doing several actions in the same block (a short time window on a blockchain). Here, the check looked at who was calling the function, not whose tokens were being moved, so an attacker could use a second account to move tokens and then withdraw them immediately, getting around the lock.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.