Unlock Protocol contest - Reigada's results

Protocol for memberships built on a blockchain, where fans can support their favourite creators by purchasing their NFTs!

General Information

Platform: Code4rena

Start Date: 18/11/2021

Pot Size: $50,000 USDC

Total HM: 18

Participants: 26

Period: 7 days

Judge: leastwood

Total Solo HM: 12

Id: 54

League: ETH

Unlock Protocol

Findings Distribution

Researcher Performance

Rank: 17/26

Findings: 3

Award: $241.81

🌟 Selected for report: 1

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: pauliax

Also found by: 0x0x0x, GiveMeTestEther, Reigada, Ruhum, WatchPug, cmichel, kenzo

Labels

bug
duplicate
1 (Low Risk)

Awards

71.4681 USDC - $71.47

External Links

Handle

Reigada

Vulnerability details

Impact

In the contract MixinPurchase and also PublicLock as PublicLock inherits from MixinPurchase, the purchase function assumes that the smart contract will receive the 100% of the pricePaid amount as can be seen in: https://github.com/code-423n4/2021-11-unlock/blob/main/smart-contracts/contracts/mixins/MixinPurchase.sol#L97 https://github.com/code-423n4/2021-11-unlock/blob/main/smart-contracts/contracts/mixins/MixinPurchase.sol#L103

However, this may not be true if the token is a transfer-on-fee token or a deflationary/rebasing token, causing the received amount by the smart contract to be less than the one set in pricePaid. This would still pass the require check require(pricePaid >= inMemoryKeyPrice, 'INSUFFICIENT_VALUE'); but actually the smart contract would receive less tokens than inMemoryKeyPrice.

Proof of Concept

https://github.com/code-423n4/2021-11-unlock/blob/main/smart-contracts/contracts/mixins/MixinPurchase.sol#L97 https://github.com/code-423n4/2021-11-unlock/blob/main/smart-contracts/contracts/mixins/MixinPurchase.sol#L103

Tools Used

Manual code review

Get the actual received amount by calculating the difference of token balance before and after the transfer. For example:

uint256 balanceBefore = token.balanceOf(address(this)); token.transferFrom(msg.sender, address(this), pricePaid); uint256 receivedAmount = token.balanceOf(address(this)) - balanceBefore; require(receivedAmount >= inMemoryKeyPrice, 'INSUFFICIENT_VALUE');

#0 - julien51

2021-11-23T03:31:18Z

That is a fair point. That said I would not classify this as "high risk". Basically for this to be an issue, someone would have to intentionally deploy a lock with such an ERC20 for them to be impacted. I would assume that when someone deploys a lock with a specific ERC20 that is because they decide to be paid with it, which means that they should know about the fact that it has these characteristics.

#1 - 0xleastwood

2022-01-16T05:50:45Z

I think this is a very unlikely issue. There are no direct or indirect risk of funds and the availability of the protocol is not impacted. However, it does seem that this might cause small issues to unaware content creators. Marking this as low severity.

#2 - 0xleastwood

2022-01-16T09:10:10Z

Duplicate of #162

#3 - 0xleastwood

2022-01-18T13:08:33Z

Bumped to medium as #221 mentions this as a potential risk

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