The last claimer of the FjordAuction
will lose his eligible claim funds
(DoS the FjordAuction.claimTokens()
transaction), if fee-on-transfer token is used as the auctionToken
.
The FjordAuctionFactory.sol
contract is used to create a new auction
. After the deployment of the new auction
the total token amount for the auction is transferred to the auction contract
as shown below:
The totalTokens
parameter is used as the FjordAuction.constructor
parameter for the auctionToken amount
and it is transferred to the auction
by calling the IERC20(auctionToken).transferFrom
. This passed in totalTokens
constructor parameter is subsequently used in the calculations in the FjordAuction.auctionEnd
function to calculate the claim token amounts
for the bidder.
Now the issue is all these auction tokens
are deposited in the Fjord treasury
and these are native tokens of the projects which have used to the Fjord protocol
. Hence these auction tokens
could have the fee on transfer
feature in them. As a result when the totalTokens
is transferred to the FjordAuction
contract fee will be charged an less amount of tokens will be transferred to the auction contract as a result. But the state FjordAuction.totalTokens
will still have the initialized totalTokens
parameter when the contract was deployed by FjordAuctionFactory.createAuction
.
As a result of the above vulnerability, when the bidders are claiming their auction tokens
the last claimer (or last claimers) will not be able to claim his auction token
since there is not enough balance of auctionTokens
in the FjordAuction contract
. Hence this is loss of funds to the last claimer
since his FjordAuction.claimTokens
transaction will always revert. And his points are also burnt
since the FjordStaking.auctionEnd
function burns all the FjordPoints
at the end of its execution. Hence this is loss of funds to the last claimer of the FjordAuction
.
Please add the following testcase to the test/unit/auction.t.sol
and execute the following command.
forge test --match-test testClaimTokensFeeOnTransfer
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuctionFactory.sol#L58-L63
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L136
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L197
https://github.com/Cyfrin/2024-08-fjord/blob/main/src/FjordAuction.sol#L220
Manual Review, Foundry and VSCode
Hence it is recommended to initially calculate the FjordAuction contract address
using CREATE 2
in the FjordAuctionFactory.createAuction
function and then transfer the totalTokens
amount of the auctionToken
to the FjordAuction contract
. Then the FjordAuction
contract can be deployed at the predetermined auction address
and then when the FjordAuction.totalTokens
is initialized the auction token
balance of the FjordAuction contract
can be used as the amount of totalTokens
for the auction.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.