Skip to content
Access control Audit finding Intermediate

PaladinRewardReserve.sol may have potential bugs if it uses new tokens as rewards

The contract's approvedSpenders mapping does not record which token a spender is approved for, so if a new token is added as a reward, existing approvals from a previous token carry over. An attacker already approved for one token could then call updateSpenderAllowance for the new token.

TerrierLover Follow

Originally disclosed on Code4rena

Submitted by TerrierLover

PaladinRewardReserve.sol may have potential bugs if it uses new tokens as rewards.

Proof of Concept

Currently, PaladinRewardReserve.sol has following behaviors:

  • mapping(address => bool) public approvedSpenders does not store the info regarding which token it targets
  • setNewSpender, updateSpenderAllowance, removeSpender and transferToken functions can set token arbitrarily

Hence, some corner cases may happen as follows:

  • Use TokenA at PaladinRewardReserve.sol and do operations.

  • Start TokenB as rewards at PaladinRewardReserve.sol.

  • All the information stored in approvedSpenders was intended for TokenA. So it is possible that following corner cases happen:

    • setNewSpender function cannot set new token
    • If userA is already added in approvedSpenders for TokenA, it can call updateSpenderAllowance.

Recommended Mitigation Steps

Do either of followings depending on the product specification:

(1) If PAL token is only used and other token will never be used at PaladinRewardReserve.sol, stop having address token argument at setNewSpender, updateSpenderAllowance, removeSpender and transferToken functions. Instead, set token at the constructor or other ways, and limit the ability to flexibly set token from functions.

(2) If other tokens potentially will be used at PaladinRewardReserve.sol, update data structure of approvedSpenders mapping and change the logic. Firstly, it should also contain the info which token it targets such as mapping(address => address => bool). Secondly, it should rewrite the require logic at each function as follows.

require(!approvedSpenders[spender][token], "Already Spender on the specified Token");
require(approvedSpenders[spender][token], "Not approved Spender on the specified Token");

Kogaroshi (Paladin) confirmed, resolved, and commented:

Changes made in the PR: PaladinFinance/Paladin-Tokenomics#11.


The original report as published on Code4rena, by TerrierLover. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the approvedSpenders mapping is keyed only by spender address, so approvals are not scoped to a specific token.

Impact

A spender approved for one token could potentially update their allowance for a different token, though the report only describes this as a possible corner case.

What the attacker needed

Contract uses more than one token as reward; attacker already approved for the old token

The fix

The issue was fixed by changing the mapping to include the token address and updating the require checks accordingly.

How it was found

  1. Use TokenA at PaladinRewardReserve.sol and do operations.
  2. Start TokenB as rewards at PaladinRewardReserve.sol.
  3. If userA is already added in approvedSpenders for TokenA, it can call updateSpenderAllowance.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract keeps a list of who is allowed to move its reward tokens. That list only records the person's address, not which token they were approved for. If the contract later starts using a different token, someone approved for the old token may still be treated as approved for the new one.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by TerrierLover

View all

2 more disclosed reports, best first.

More from Paladin - Warden Pledges contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.