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

CreditLine.sol assumes 365 day year #86

Open
code423n4 opened this issue Dec 14, 2021 · 1 comment
Open

CreditLine.sol assumes 365 day year #86

code423n4 opened this issue Dec 14, 2021 · 1 comment
Labels
0 (Non-critical) Code style, clarity, syntax, versioning, off-chain monitoring (events etc), exclude gas optimisation bug Something isn't working sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

sirhashalot

Vulnerability details

Impact

CreditLine.sol assumes a year is 365 days with the YEAR_IN_SECONDS constant, but this is not always true. This assumption impacts the calculateInterest function and will more interest than it should during leap years (roughly 1 / 365 = 0.274% more). Solidity documentation warns against assuming a year is 365 days, and the years suffix was removed for this reason from Solidity 0.5.0.

Proof of Concept

CreditLine.sol
https://github.com/code-423n4/2021-12-sublime/blob/9df1b7c4247f8631647c7627a8da9bdc16db8b11/contracts/CreditLine/CreditLine.sol

Recommended Mitigation Steps

Handle leap year edge case in calculateInterest function to improve interest calculation accuracy

@code423n4 code423n4 added 0 (Non-critical) Code style, clarity, syntax, versioning, off-chain monitoring (events etc), exclude gas optimisation bug Something isn't working labels Dec 14, 2021
code423n4 added a commit that referenced this issue Dec 14, 2021
@ritik99 ritik99 added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Dec 23, 2021
@ritik99
Copy link
Collaborator

ritik99 commented Dec 23, 2021

We're aware that 365 days doesn't hold true for every year but we'll be retaining this assumption to simplify calculations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 (Non-critical) Code style, clarity, syntax, versioning, off-chain monitoring (events etc), exclude gas optimisation bug Something isn't working 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

2 participants