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

Missing checks allow strategists to steal all fund via tailOff #211

Open
code423n4 opened this issue May 28, 2022 · 2 comments
Open

Missing checks allow strategists to steal all fund via tailOff #211

code423n4 opened this issue May 28, 2022 · 2 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 disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-05-rubicon/blob/8c312a63a91193c6a192a9aab44ff980fbfd7741/contracts/rubiconPools/BathPair.sol#L533-L563
https://github.com/code-423n4/2022-05-rubicon/blob/8c312a63a91193c6a192a9aab44ff980fbfd7741/contracts/rubiconPools/BathToken.sol#L343-L369

Vulnerability details

Impact

Strategists can call tailOff with malicious payload to steal all funds within any BathToken.

There are 2 issues that makes this possible:

  • BathPair.tailOff allows arbitrary _stratUtil address.
  • BathToken.rebalance allows underlying token as filledAssetToRebalance.

These allow malicious strategists to input any token address, including the underlying token of a BathToken, and transfer them to a contract of their choosing.

Proof of Concept

A malicious strategist calls tailOff with the following payload:

{
    targetPool: bathUSDC.address,
    tokenToHandle: USDC.address,
    targetToken: USDT.address, // any address
    _stratUtil: maliciousContract.address,
    amount: USDC.balanceOf(bathUSDC.address),
    hurdle: 0, // any
    _poolFee: 0 // any
}

bathUSDC BathToken will then send all USDC to the strategist's maliciousContract. All deposits are lost.

Recommended Mitigation Steps

  • Whitelist the addresses that can be used as _stratUtil.
  • Add a check in rebalance to prevent transferring underlying token:
    require(filledAssetToRebalance != underlyingToken, "must not be underlying");
    
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels May 28, 2022
code423n4 added a commit that referenced this issue May 28, 2022
@bghughes bghughes added duplicate This issue or pull request already exists sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) and removed duplicate This issue or pull request already exists labels Jun 3, 2022
@HickupHH3
Copy link
Collaborator

Making this the primary issue of strategist stealing funds via the tailOff() function. Rationale of med severity is outlined in #344.

@bghughes
Copy link
Collaborator

Good issue, implemented the require(filledAssetToRebalance != underlyingToken, "must not be underlying"); fix 💯

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 disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants