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

Malicious lender can claim revenue and steal it from borrower #153

Closed
code423n4 opened this issue Nov 8, 2022 · 4 comments
Closed

Malicious lender can claim revenue and steal it from borrower #153

code423n4 opened this issue Nov 8, 2022 · 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-110 partial-50

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/debtdao/Line-of-Credit/blob/e8aa08b44f6132a5ed901f8daa231700c5afeb3a/contracts/modules/credit/SpigotedLine.sol#L93-L133

Vulnerability details

Impact

Lender can use swap data with no slippage and sandwich attakc to steal claimed revenue and extract more value from borrower

Proof of Concept

uint256 newTokens = claimToken == credit.token ?
    spigot.claimEscrow(claimToken) :  // same asset. dont trade
    _claimAndTrade(                   // trade revenue token for debt obligation
        claimToken,
        credit.token,
        zeroExTradeData
    );

uint256 repaid = newTokens + unusedTokens[credit.token];
uint256 debt = credit.interestAccrued + credit.principal;

SpigotedLine#claimAndRepay allows the lender to claim and swap revenue tokens to pay borrower debt. Caller is allowed to provide arbitrary swap data allowing a malicious lender to claim revenue and then steal it by using no slippage bounds and sandwiching the trade. This allows the lender to extract more value from the borrower.

Tools Used

Manual Review

Recommended Mitigation Steps

Only borrower should be allowed to claim and swap if the credit token because lender has no incentive to get borrower a good swap price.

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

dmvt marked the issue as duplicate of #88

@c4-judge
Copy link
Contributor

dmvt marked the issue as partial-50

@c4-judge c4-judge added partial-50 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 Nov 17, 2022
@c4-judge
Copy link
Contributor

dmvt changed the severity to 2 (Med Risk)

@C4-Staff
Copy link
Contributor

captainmangoC4 marked the issue as duplicate of #110

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-110 partial-50
Projects
None yet
Development

No branches or pull requests

3 participants