code-423n4 / 2022-02-foundation-findings

0 stars 0 forks source link

QA Report #89

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Signature Re-Use

The adminAccountMigration() function intends to allow a seller to update auction.seller in the event their account is compromised. However, the signature in requireAuthorizedAccountMigration() can be re-used because there is no use of a nonce to prevent this.

Consider adding a nonce to account for this behaviour.

Approval Race Condition

There is no use of the increaseAllowance() and decreaseAllowance() functions. As a result, users could frontrun calls to approve() by using the allocated amount before the new amount is set. Consequently, it might be possible for the approved spender to spend more tokens then they were allocated.

Ensure this is understand and consider adding the aforementioned functions.

Unclear Function Naming

The _cancelBuyersOffer() function isn't exactly clear as it will only cancel the offer if the buyer is msg.sender. Therefore, it would be more clear to rename this to _cancelSellersOffer() or similar to avoid confusion.

Improper BASIS_POINTS Check in _distributeFunds()

The _distributeFunds() function checks if creatorShares[i] > BASIS_POINTS when it should actually be checking if totalShares > BASIS_POINTS. This ensures that the sum of creator shares do not exceed an expected amount.

Improper State Handling

If _autoAcceptBuyPrice() is executed by a new buyer that is not offer.buyer, then there will be an excess of ETH. The original offer.buyer will then have to wait until the offer expires as it isn't invalidated.

Ensure this is understood.

Unhandled marketLockupFor() Edge Case

marketLockupFor() will revert if too much ETH is provided. This can be modified to refund any surplus ETH to the user's FETH balance.

No Support For ERC1155 Tokens

Many new NFT contracts adhere to the ERC1155 standard. Currently, it is not possible to trade these tokens on the Foundation marketplace.

Consider making the necessary integrations.

Malicious Contract Upgrades Will Lock Funds And NFTs

If the protocol owner becomes malicious or their account is compromised for whatever reason, they can lock users' funds by upgrading the relevant contracts to an malicious contract which always reverts. As a result, NFTs and ETH will be forever locked by the protocol.

Unclear _recipients Array Restriction

The _recipients array is restricted to just 5 receivers. Ensure this is understand by NFT creators as they may intend to use additional receivers but these receivers may be disproportionally rewarded if the majority of creator shares are not included.

Inconsistent Use of sendValue()

_buy() should make use of _sendValueWithFallbackWithdraw() instead of sendValue(). This will ensure invalid transfers are correctly handled.

HardlyDifficult commented 2 years ago

Thanks for the feedback!

alcueca commented 2 years ago

Unadusted score: 100 (80 + 20 from clean formatting)

alcueca commented 2 years ago

Signature Re-Use - Non-Critical (Lack of documentation on desiderability) Approval Race Condition - Invalid in my opinion, since this has never been exploited and is uneconomical to exploit. Unclear Function Naming - Non-Critical Improper BASIS_POINTS Check in _distributeFunds() - Non-Critical (Lack of documentation on trade-offs) Improper State Handling - Non-Critical (Lack of documentation on feature set) Unhandled marketLockupFor() Edge Case - Low No Support For ERC1155 Tokens - Non-Critical (Accepted suggestion) Malicious Contract Upgrades Will Lock Funds And NFTs - Invalid, this kind of issue belongs in a governance audit. Unclear _recipients Array Restriction - Non-Critical (Lack of documentation on trade-offs) Inconsistent Use of sendValue() - Non-Critical (Lack of documentation on flow and trade-offs)

liveactionllama commented 2 years ago

Just a note that C4 is excluding the invalid entries from the official report.