Paladin contest - 0xDjango's results

A governance lending protocol transforming users voting power into a new money lego.

General Information

Platform: Code4rena

Start Date: 29/03/2022

Pot Size: $50,000 USDC

Total HM: 16

Participants: 42

Period: 5 days

Judge: 0xean

Total Solo HM: 9

Id: 105

League: ETH

Paladin

Findings Distribution

Researcher Performance

Rank: 17/42

Findings: 3

Award: $723.29

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: IllIllI

Also found by: 0xDjango, csanuragjain

Labels

bug
duplicate
2 (Med Risk)
disagree with severity
sponsor disputed

Awards

560.4852 USDC - $560.49

External Links

Lines of code

https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/HolyPaladinToken.sol#L1108-L1133

Vulnerability details

Impact

By design, a user's cooldown period is extended if they receive a transfer of hPal. The cooldown is extended based on the weight of the receiver's original balance and cooldown period compared to the sent amount and sender's cooldown period. Due to this mechanic, a malicious but generous user can indefinitely freeze the funds of another user by continuously extending the receiver's cooldown period, disabling them from unstaking.

In the most extreme case, it is possible that Pal can have negative price action in the period while the funds are frozen such that the user will be losing value despite accruing more hPal. Disregarding negative price action, having a user's funds frozen based on the authority of others would not be desired.

Proof of Concept

  • User A stakes 10 Pal and receives 10 hPal
  • User A calls cooldown() and waits 9 days, making his remaining cooldown period equal 1 day
  • User B stakes 10 Pal, receives 10 hPal and starts their cooldown()
  • User B immediately sends all 10 hPal to User A.
  • User A now has a cooldown period = 5.5 days based on the following formula.
((amount * _senderCooldown) + (receiverBalance * receiverCooldown)) / (amount + receiverBalance);

With values:

((10 hPal * 10 days) + (10 hPal * 1 day)) / (10 hPal + 10 hPal) = 5.5 days

Tools Used

Manual review

Understanding that this is a mechanism to combat users transferring funds between their own accounts to work around the cooldown system, I recommend adding an acceptTransfer() function. This function will allow the receiver to accept the sent funds and resulting new cooldown period.

#0 - Kogaroshi

2022-04-02T15:41:21Z

This behavior is wanted in the token design. Any implementation of a acceptTransfer() or any similar design will remove the ability of the hPAL token to be compatible with the ERC20 design, which is not something desired for that token.

And as shown in the example, to effectively have an impact on the cooldown of another user through a transfer, it would require an important amount of token (100% of the balance to push back to 5 days out of 10 days cooldown if the target cooldown is about to be reached), which is the desired logic to reduce this kind of scenario

(for a live example, this system is taken from the stkAave system, where that type of scenario is rarely seen)

#1 - 0xean

2022-04-08T00:17:18Z

Downgrading to Medium based on the fact that there does an exist an attack vector, albeit an expensive one.

2 β€” Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

I think this falls into the hypothetical attack path with external requirements and therefore is a Med.

#2 - 0xean

2022-04-11T12:36:40Z

duplicate of #69

Awards

111.355 USDC - $111.35

Labels

bug
QA (Quality Assurance)

External Links

Issue 1 (Low) - Missing 0 address check for immutable rewardsVault address

In the constructor for HolyPaladinToken.sol, the rewardsVault is set without requiring that the address not be 0. All other addresses in the constructor are properly verified. Moreover, rewardsVault is immutable, so the contract would need to be redeployed.

https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/HolyPaladinToken.sol#L194

Issue 2 (Low) - Floating Pragma

https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/PaladinRewardReserve.sol#L2

Both files contain a floating pragma. It is recommended to specify a compiler version to reduce the risk of deploying contracts with different versions, potentially leading to compiler-specific bugs.

Issue 3 (Low) - Use of SafeApprove() deprecated

https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/PaladinRewardReserve.sol#L31

OpenZeppelin has marked this function as deprecated and recommends using safeIncreaseAllowance(). See following comments:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/742e85be7c08dff21410ba4aa9c60f6a033befb8/contracts/token/ERC20/utils/SafeERC20.sol#L39-L43

Issue 4 (Non-critical) - Make the emergency logic a modifier

Repeated emergency checks can be made a modifier to reduce code duplication.

Example: https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/HolyPaladinToken.sol#L254

#0 - Kogaroshi

2022-04-03T06:54:00Z

QA & gas optimizations changes are done in the PR: https://github.com/PaladinFinance/Paladin-Tokenomics/pull/6 (some changes/tips were implemented, others are noted but won't be applied)

Awards

51.4511 USDC - $51.45

Labels

bug
G (Gas Optimization)
sponsor acknowledged

External Links

Issue 1 - Redundant requires

Detail

In the following code, the second block.timestamp require statement is more exclusive than the first, making the first redundant.

Code

https://github.com/code-423n4/2022-03-paladin/blob/9c26ec8556298fb1dc3cf71f471aadad3a5c74a0/contracts/HolyPaladinToken.sol#L1280-L1283

#0 - Kogaroshi

2022-04-02T15:42:58Z

This is wanted, to allow the user (or the devs) to know why the Lock could not be kicked, based on the current timestamp.

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