Skip to content
Access control Write-up Intermediate

Sovryn Loan Vulnerability Bug Fix Review

The Sovryn smart contract's borrow() and marginTrade() functions failed to verify that the caller was the borrower, allowing an attacker to borrow against someone else's unused collateral and steal funds equal to the collateral. The marginTrade() flaw could force users into unfavourable positions but did not allow direct theft.

immunefi.com

Published on immunefi.com

Whitehat Turbo (Discord: turbo#1177) submitted a “critical” and a “high” vulnerability in Sovryn’s smart contract to Immunefi on March 11, 2021. The critical vulnerability consisted of a failure to validate that the receiver of the proceeds of a collateralized loan was the same entity as the borrower, meaning a…

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The borrow() and marginTrade() functions did not check that the caller (msg.sender) matched the borrower or trader associated with the loanId, only that the loanId was valid.

Impact

An attacker could steal funds equal to the unused collateral of another user's loan, and could force users into unfavourable margin positions, though the critical vulnerability was not exploited and the risk to user funds was relatively low (6,798.17 USDT).

What the attacker needed

Knowledge of a valid loanId with unused collateral; no special privileges required

The fix

The fix added a requirement that the caller must be the borrower (for borrow) or trader (for marginTrade) when a loanId is provided, while still allowing the loan originator to specify a receiver.

How it was found

  1. Identify a loan based on loanId that has unused collateral
  2. Call borrow() with valid parameters for that loan, passing the attacker's address as receiver
  3. The attacker now has a loan using someone else's collateral and can steal an amount equal to the collateral

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

In a lending system, you can borrow money by putting up collateral. The contract should check that only the person who owns the collateral can borrow against it. Here, it didn't, so anyone who knew a loan ID could borrow using someone else's collateral and keep the money.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.