-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In some cases TokenManager.giveToken will revert and cause DOS #371
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-332
satisfactory
satisfies C4 submission criteria; eligible for awards
Comments
code423n4
added
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
labels
Jul 21, 2023
0xSorryNotSorry marked the issue as duplicate of #317 |
berndartmueller marked the issue as not a duplicate |
berndartmueller marked the issue as duplicate of #345 |
c4-judge
added
duplicate-345
satisfactory
satisfies C4 submission criteria; eligible for awards
labels
Sep 1, 2023
berndartmueller marked the issue as satisfactory |
berndartmueller marked the issue as not a duplicate |
berndartmueller marked the issue as duplicate of #332 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-332
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2023-07-axelar/blob/main/contracts/its/token-manager/TokenManager.sol#L161-L165
Vulnerability details
Impact
InterchainTokenService._processSendTokenPayload/_processSendTokenWithDataPayload is used to process token sending commands. Both will eventually call tokenManager.giveToken to send the token to the receiver. If the token is ERC777, the
giveToken
may be manipulated by the receiver, which can make the subsequentgiveToken
revert from other users. This will consume the relayer's gas, which is paid by the user in the source chain.Proof of Concept
For existing ERC20, TokenManager can be TokenManagerLockUnlock or TokenManagerLiquidityPool.
TokenManager.giveToken
first calls_giveToken
from the child contract to send the token to the receiver, and then calls _addFlowIn to add a flow in amount.TokenManagerLockUnlock._giveToken and TokenManagerLiquidityPool._giveToken have similar logic. They use the
AfterBalance(to)-BeforeBalance(to)
mode to return the amount of token transferred. This method is no problem for erc20 without callback. But if the token is ERC777 andto
is a malicious contract, the return value of_giveToken
can be manipulated.The attack flow is as follows:
If the current flow limit is not 0, then if the amount returned by
_giveToken
just meets this condition, that is,flowToAdd + flowAmount
is close toflowToCompare + flowLimit
.flowAmount
is the amount returned by_giveToken
. In this way, the subsequent_addFlowIn
will revert because the condition is not met.However,
_addFlowIn
internally reads FlowInSlot and FlowOutSlot by epoch, and the interval between each epoch is EPOCH_TIME (six hours). 4 epochs a day. The attacker can send tokens (very small amount) across chains every 6 hours without paying gas, then the relayer will not call such a transaction. In this way, when a new epoch arrives, the attacker callsInterchainTokenService.execute
to trigger _processSendTokenPayload. Make subsequent calls to revert by attack flow mentioned above.Tools Used
Manual Review
Recommended Mitigation Steps
For TokenManagerLockUnlock:
For TokenManagerLiquidityPool:
Assessed type
DoS
The text was updated successfully, but these errors were encountered: