Ajna Protocol - kodyvim's results

A peer to peer, oracleless, permissionless lending protocol with no governance, accepting both fungible and non fungible tokens as collateral.

General Information

Platform: Code4rena

Start Date: 03/05/2023

Pot Size: $60,500 USDC

Total HM: 25

Participants: 114

Period: 8 days

Judge: Picodes

Total Solo HM: 6

Id: 234

League: ETH

Ajna Protocol

Findings Distribution

Researcher Performance

Rank: 62/114

Findings: 2

Award: $70.26

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

bug
3 (High Risk)
partial-50
upgraded by judge
duplicate-488

Awards

34.0183 USDC - $34.02

External Links

Lines of code

https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L170

Vulnerability details

Impact

Anyone can call memorializePositions with any user NFT and transfer ownership of any previously approved LP tokens to the PositionManager contract. memorializePositions stamps the given NFT with the underlying liquidity positions in a given array of bucket indexes and transfers the LPB to the PositionManager contract, since this function does not check if the caller is the owner of the NFT, the LP tokens may be transfer to the PositionManager contract at an inappropriate time, impacting the position management strategy of the owner.

Proof of Concept

https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L170

Tools Used

Manuel Review

Add a check to compare the owner of the nft against the msg.sender in memorializePositions.

Assessed type

Access Control

#0 - c4-judge

2023-05-12T10:08:26Z

Picodes marked the issue as duplicate of #488

#1 - c4-judge

2023-05-29T20:25:11Z

Picodes marked the issue as partial-50

#2 - Picodes

2023-05-29T20:25:31Z

The impact described does not qualify for High Severity - the loss of funds scenario without external requirements is not obvious.

#3 - c4-judge

2023-05-30T21:48:18Z

Picodes changed the severity to 3 (High Risk)

Approved NFT users can not stake in RewardsManager.

if a user has approved his/her nft to someone or any protocol building on top of ajna they would not be able to stake on behave of the user, since the stake function only allows the owner. https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L213 Recommended Mitigation: consider adding this check:

address owner = IERC721(address(positionManager)).ownerOf(tokenId_);
address approved = IERC721(address(positionManager)).getApproved(tokenId_);
if (owner != msg.sender && approved != msg.sender) revert NotOwnerOfDeposit();

fromPosition.depositTime is never resets to zero

There is a check if a user has already move liquidity after they've already done so but the fromPosition.depositTime which is a storage variable was never set to zero after moving the liquidity. https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L268-L271

vars.depositTime = fromPosition.depositTime;
   // handle the case where owner attempts to move liquidity after they've already done so
        if (vars.depositTime == 0) revert RemovePositionFailed();

Recommendation.

set fromPosition.depositTime to zero after moving liquidity.

fix misleading comments

https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/Funding.sol#L99 fix comment to show the exact intent

- * @param values_          The amounts of ETH to send to each target.
+ * @param values_          The amounts of ETH to send to each target should always be zero.

variable known at compile time should be constant.

https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-grants/src/grants/base/Funding.sol#L21 change immutable to constant. address public immutable ajnaTokenAddress = 0x9a96ec9B57Fb64FbC60B423d1f4da7691Bd35079;

#0 - c4-judge

2023-05-18T19:19:18Z

Picodes marked the issue as grade-b

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