Backed Protocol contest - berndartmueller's results

Protocol for peer to peer NFT-Backed Loans.

General Information

Platform: Code4rena

Start Date: 05/04/2022

Pot Size: $30,000 USDC

Total HM: 10

Participants: 47

Period: 3 days

Judge: gzeon

Total Solo HM: 4

Id: 106

League: ETH

Backed Protocol

Findings Distribution

Researcher Performance

Rank: 19/47

Findings: 2

Award: $235.69

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: WatchPug

Also found by: Dravee, berndartmueller, hake, jah, minhquanym

Labels

bug
duplicate
2 (Med Risk)
disagree with severity
sponsor acknowledged

Awards

181.4136 USDC - $181.41

External Links

Lines of code

https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L88 https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L124

Vulnerability details

Impact

While the contracts use in most places safeTransferFrom() to transfer NFTs, there are a few cases where the unsafe counterpart transferFrom() is used.

safeTransferFrom checks that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked.

Proof of Concept

NFTLoanFacilitator.createLoan() NFTLoanFacilitator.closeLoan()

Tools Used

Manual review

Consider using safeTransferFrom() consistently.

As the NFTLoanFacilitator contract is receiving NFTs itself, the contract has to implement the interface ERC721TokenReceiver. To prevent reentrancy, consider adding a reentrancy guard to both functions as a safety precaution in case any other functionality is added later which might make this exploitable.

#0 - wilsoncusack

2022-04-08T00:00:11Z

createLoan case is not relevant, we are transferring to ourself and are handling in our own logic.

closeLoan is an outlier using transferFrom but I think we will probably switch all safeTransferFrom to transferFrom

#1 - wilsoncusack

2022-04-08T00:01:25Z

#11

#2 - wilsoncusack

2022-04-08T00:03:42Z

#83 is now canonical

#3 - gzeoneth

2022-04-15T12:53:07Z

Duplicate of #83

Awards

54.2825 USDC - $54.28

Labels

bug
QA (Quality Assurance)
sponsor acknowledged

External Links

QA Report

Non-Critical Findings

None

Low Risk

Zero-address check is missing

Description

Zero-address checks are a best-practice for input validation of critical address parameters.

Impact: If _nftLoanFacilitator is set to address(0), it will break the contract and deployment of a new contract is necessary.

Findings

NFTLoanTicket.constructor()#_nftLoanFacilitator

Add zero-address check:

require(address(_nftLoanFacilitator) != address(0), "Zero address");

Use _safeMint() instead of _mint()

Description

By using _mint() a minted NFT can get stuck in a recipients contract if the contract not designed to handle them. safeMint() checks whether the recipient contract can handle ERC721 tokens.

Findings

NFTLoanTicket.mint()

Its is recommended to use _safeMint whenever possible.

_safeMint(to, tokenId);
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter