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

An attacker who transfers directly to the underlying token may control _exchangeRateStored #445

Closed
code423n4 opened this issue May 15, 2023 · 4 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 downgraded by judge Judge downgraded the risk level of this issue duplicate-220 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L1476

Vulnerability details

Impact

Proof of Concept

  1. Assume that the current _totalSupply is 0 and the initial initialExchangeRateMantissa is 1:1
  2. The attacker mint 1, _totalSupply is 1, underlying.balanceOf(address(this)) is 1
  3. The attacker transfers 1 underlying token to this contract, _totalSupply is 1, underlying.balanceOf(address(this)) is 2
  4. The user expects mint 1000 and transfers 1000 underlying tokens. At this time, cashPlusBorrowsMinusReserves = 2/1 = 2, and the user gets 1000/2=500 vTokens.

Tools Used

manual

Recommended Mitigation Steps

Maintain totalCash yourself instead of using underlying.balanceOf(address(this))

Assessed type

Other

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels May 15, 2023
code423n4 added a commit that referenced this issue May 15, 2023
@c4-judge
Copy link
Contributor

0xean marked the issue as duplicate of #314

@c4-judge c4-judge added duplicate-314 partial-25 Incomplete articulation of vulnerability; eligible for partial credit only (25%) labels May 17, 2023
@c4-judge
Copy link
Contributor

0xean marked the issue as partial-25

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards and removed partial-25 Incomplete articulation of vulnerability; eligible for partial credit only (25%) labels Jun 5, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jun 5, 2023

0xean marked the issue as satisfactory

@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jun 5, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jun 5, 2023

0xean changed the severity to 2 (Med Risk)

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 downgraded by judge Judge downgraded the risk level of this issue duplicate-220 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants