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

potential overflow with amount parameter may have unintended effects #107

Closed
code423n4 opened this issue Dec 8, 2022 · 2 comments
Closed
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-369 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Dec 8, 2022

Lines of code

https://github.com/code-423n4/2022-12-escher/blob/5d8be6aa0e8634fdb2f328b99076b0d05fefab73/src/minters/LPDA.sol#L58-L59
https://github.com/code-423n4/2022-12-escher/blob/5d8be6aa0e8634fdb2f328b99076b0d05fefab73/src/minters/FixedPrice.sol#L57-L74
https://github.com/code-423n4/2022-12-escher/blob/5d8be6aa0e8634fdb2f328b99076b0d05fefab73/src/minters/OpenEdition.sol#L57-L72

Vulnerability details

Impact

The variable _amount is uint256 but the variable amount is uint24 so the variable amount the full value may not be stored.

These calculations and operations may produce incorrect results if the amount variable has a different value than what was intended.

This could still cause the contract to behave unexpectedly and potentially lead to financial losses for users of the contract or incorrect balances being stored.

Proof of Concept

This possibility exists because the amount variable is defined as an uint48 type, which has a narrower range of possible values than the _amount parameter's uint256 type.

If the value assigned to the amount variable is greater than the maximum value that can be stored in an uint48 type, the value will be truncated. This truncation may result in the amount variable having a different value than intended.

Tools Used

Manual Audit

Recommended Mitigation Steps

if (_amount <= uint48.max()) {
  uint48 amount = uint48(_amount);
  ...
} else {
  // Handle _amount being too large
}
@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 8, 2022
code423n4 added a commit that referenced this issue Dec 8, 2022
@code423n4 code423n4 changed the title LPDA.sol: potential overflow with amount parameter may have unintended effects potential overflow with amount parameter may have unintended effects Dec 9, 2022
@c4-judge
Copy link
Contributor

berndartmueller marked the issue as duplicate of #369

@c4-judge
Copy link
Contributor

c4-judge commented Jan 3, 2023

berndartmueller marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jan 3, 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-369 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants