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

StableVault doesn't support tokens above 18 decimals #116

Closed
code423n4 opened this issue Dec 13, 2022 · 2 comments
Closed

StableVault doesn't support tokens above 18 decimals #116

code423n4 opened this issue Dec 13, 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 duplicate-533 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/StableVault.sol#L49

Vulnerability details

Impact

The StableVault has a deposit function, which allows a user to deposit a whitelisted token in exchange for tigAsset.
If the whitelisted token has above 18 decimals, the deposit and depositWithPermit functions will revert, thus rendering any asset with > 18 decimals incompatible with the protocol.

Proof of Concept

  1. Deploy a MockERC20 with 19 decimals in the deploy/00.Mocks.js script.
  2. Add the following test in test/06.StableVault.js:
it("Listing and depositing a token with > 18 decimals", async function () {
      await stablevault.connect(owner).listToken(MockBigDecimal.address);
      await mockBD.connect(owner).approve(StableVault.address, 5000000);
      await (stablevault.connect(owner).deposit(MockBigDecimal.address, 100000));
    })
  1. Result:
Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)

Tools Used

VS Code Plugins, Hardhat

Recommended Mitigation Steps

Explicitly add a check or a comment if the StableVault is not meant to support tokens with > 18 decimals.

@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 13, 2022
code423n4 added a commit that referenced this issue Dec 13, 2022
@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as duplicate of #533

@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jan 22, 2023
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-533 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants