Skip to content
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

Function joinTokenSingle in SingleTokenJoin.sol and SingleTokenJoinV2.sol can be made to fail #81

Open
code423n4 opened this issue Dec 16, 2021 · 0 comments
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 sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

pmerkleplant

Vulnerability details

Impact

There's a griefing attack vulnerability in the function joinTokenSingle in
SingleTokenJoin.sol as well as SingleTokenJoinV2.sol which makes any user
transaction fail with "FAILED_OUTPUT_AMOUNT".

Proof of Concept

The JoinTokenStruct argument for joinTokenSingle includes a field outputAmount
to indicate the amount of tokens the user should receive after joining a basket
(see line 135 and 130).

However, this amount is compared to the contract's balance of the token and
reverts if the amount is unequal.

If an attacker sends some amount of a basket's token to the contract, every call
to this function will fail as long as the output token equals the attacker's token send.

Recommended Mitigation Steps

Refactor the require statement to expect at least the outputAmount of tokens,
i.e. require(outputAmount >= _joinTokenStruct.outputAmount).

@code423n4 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 Dec 16, 2021
code423n4 added a commit that referenced this issue Dec 16, 2021
@loki-sama loki-sama added the duplicate This issue or pull request already exists label Dec 29, 2021
@loki-sama loki-sama added sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") and removed duplicate This issue or pull request already exists labels Jan 3, 2022
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 sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

2 participants