wise-foundation / lending-audit

5 stars 4 forks source link

[WLD-02M] Insecure Assumption of NFT Acquisition #111

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

WLD-02M: Insecure Assumption of NFT Acquisition

Type Severity Location
Logical Fault WiseLendingDeclaration.sol:L208

Description:

The WiseLendingDeclaration contract assumes that the FeeManager of the system will possess the 0 NFT ID of the PositionNFTs contract, however, this is not guaranteed and findings in PositionNFTs within the audit have shown that the 0 NFT ID may not even exist.

Impact:

As there are multiple ways to compromise what token ID will be minted by the DeclarationsFeeManager of FeeManager, a misconfigured FEE_MANAGER_NFT can cause significant misbehaviours in the ultimate WiseLending implementation.

Example:

uint256 constant FEE_MANAGER_NFT = 0;

Recommendation:

We advise the code to set the FEE_MANAGER_NFT in the contract's WiseLendingDeclaration::constructor and to set the variable as immutable, retaining almost an identical gas cost to constant whilst representing the correct token ID.

Alternatively, the value may be set by the WiseLendingDeclaration::setSecurity function to a normal contract-level variable.

vm06007 commented 1 year ago

resolved in: https://github.com/wise-foundation/lending-audit/pull/8