Open code423n4 opened 2 years ago
Nice report, thank you. Communicated clearly and efficiently, and without overly far-fetched issues to sift through.
(The zero check in init()
only serves to ensure the contract does not get called twice. Passing zero in setFeeTo()
does no harm other than having to update it again.)
Note: throughout this report, findings related to
NFTPair.sol
also apply toNFTPairWithOracle.sol
. Rather than note that everything applies to both contracts, I'll note explicitly if a finding only applies to one or the other.Initializer can be frontrun
If a clone contract is not deployed and initialized in the same transaction, the
init
function can be frontrun. Since clones are meant to be deployed and initiated atomically using theBoringFactory
, this is unlikely, but note that this is possible if a clone contract is deployed outside the factory.Functions can be declared external
Several
public
functions are not called internally and can be declaredexternal
:NFTPair#init
NFTPair#updateLoanParams
NFTPair#withdrawFees
NFTPair#setFeeTo
Missing zero address check in
init
NFTPair#init
validates that thecollateral
address is notaddress(0)
, but does not check theasset
address.Missing zero address check in
setFeeTo
NFTPair#setFeeTo
does not check that thenewFeeTo
parameter is notaddress(0)
.Avoid use of native
ecrecover
NFTPair#requestAndBorrow
andNFTPair#takeCollateralAndLend
use the nativeecrecover
function, which is susceptible to signature malleability. Since these functions also use a nonce, this can't be exploited for a replay attack as implemented, but note that this could be a vulnerability if used without a nonce. Consider using OpenZeppelin's ECDSA library, which rejects malleable signatures.Effects after interactions in
_requestLoan
_requestLoan
changes state after callingcollateral.transferFrom
. It's safer and more idiomatic to perform interactions after state changing effects.NFTPair.sol#_requestLoan
Recommendation: Move the collateral transfer interaction after state changing effects. For example:
Incorrect comment on signature hashes
Comments describing the format of lend and borrow signature hashes mention including the asset and collateral address in the signature hash, but these hashes are not actually constructed with the asset/collateral address:
NFTPair#L337-L345
Unused library
NFTPair
includes and uses theRebaseLibrary
library, but theRebase
type is unused.Duplicated interfaces
Both
NFTPair.sol
andNFTPairWithOracle.sol
share the sameILendingClub
andINFTPair
interfaces defined inline at the top of the contract code. It's recommended to extract each interface to a reusable file to remove duplication, enable reuse, and avoid errors.Unused function in
ILendingClub
The
ILendingClub
interface defines alendingConditions
function, but it is unused throughout the codebase.