Platform: Code4rena
Start Date: 24/10/2023
Pot Size: $36,500 USDC
Total HM: 4
Participants: 147
Period: 6 days
Judge: 0xDjango
Id: 299
League: ETH
Rank: 103/147
Findings: 1
Award: $4.52
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xmystery
Also found by: 0x11singh99, 0xAadi, 0xAlix2, 0xG0P1, 0xStalin, 0xWaitress, 0x_Scar, 0xhacksmithh, 0xhunter, 0xpiken, Al-Qa-qa, Arz, Avci, Bauchibred, BeliSesir, Breeje, Bughunter101, DarkTower, Eeyore, Fitro, HChang26, Imlazy0ne, J4X, JCK, Kaysoft, Kral01, Madalad, Mike_Bello90, Noro, PASCAL, PENGUN, Proxy, Rickard, Shubham, SovaSlava, Strausses, Team_Rocket, ThreeSigma, Topmark, Udsen, Walter, Yanchuan, Zach_166, ZanyBonzy, adam-idarrha, adeolu, almurhasan, arjun16, ast3ros, asui, ayden, btk, cartlex_, castle_chain, cccz, chainsnake, codynhat, critical-or-high, cryptonue, csanuragjain, deepkin, degensec, dirk_y, erebus, foxb868, ge6a, hunter_w3b, jasonxiale, kkkmmmsk, lanrebayode77, lsaudit, marchev, matrix_0wl, max10afternoon, nuthan2x, oakcobalt, oxchsyston, pavankv, peanuts, pep7siup, pipidu83, pontifex, ptsanev, qpzm, radev_sw, rokinot, rotcivegaf, rvierdiiev, sorrynotsorry, squeaky_cactus, supersizer0x, tnquanghuy0512, twcctop, twicek, young, zhaojie, ziyou-
4.5226 USDC - $4.52
When the redistributeLockedAmount
function in the StakedUSDe.sol is called by the owner to distribute the FULL_RESTRICTED_STAKER_ROLE's tokens to an address the SOFT_RESTRICTED_STAKER_ROLE is not checked.
So the SOFT_RESTRICTED_STAKER_ROLE can still get rewards despite being blacklisted.
There is a check for if (hasRole(FULL_RESTRICTED_STAKER_ROLE, from) && !hasRole(FULL_RESTRICTED_STAKER_ROLE, to))
FULL_RESTRICTED_STAKER_ROLE but missing check for SOFT_RESTRICTED_STAKER_ROLE.
The documentation below states that the the SOFT_RESTRICTED_STAKER_ROLE cannot be provided yield or deposit but can buy or sell on the open market however this is directly from the contract.
Due to legal requirements, there's a SOFT_RESTRICTED_STAKER_ROLE and FULL_RESTRICTED_STAKER_ROLE. The former is for addresses based in countries we are not allowed to provide yield to, for example USA. Addresses under this category will be soft restricted. They cannot deposit USDe to get stUSDe or withdraw stUSDe for USDe. However they can participate in earning yield by buying and selling stUSDe on the open market.
//SPDX-License-Identifier: MIT pragma solidity 0.8.19; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Test} from "forge-std/Test.sol"; import {console} from "forge-std/console.sol"; import {StakedUSDe} from "contracts/StakedUSDe.sol"; contract mockUSDe is ERC20("mock USDe", "USDe") { function mint(address to, uint256 amount) public { _mint(to, amount); } } contract testStakedUSDe is Test { mockUSDe public USDe; StakedUSDe public stakedUSDe; address rewarder = makeAddr("REWARDER_ROLE"); address owner = makeAddr("DEFAULT_ADMIN_ROLE"); address Alice = makeAddr("alice"); address user1 = makeAddr("user1"); address user2 = makeAddr("user2"); address blacklistManager = makeAddr("blacklist"); function setUp() public { USDe = new mockUSDe(); stakedUSDe = new StakedUSDe(USDe, rewarder, owner); // USDe.mint(rewarder, 1000 ether); // USDe.mint(Alice, 100 ether); USDe.mint(user1, 10 ether); USDe.mint(user2, 20 ether); vm.prank(owner); stakedUSDe.grantRole(keccak256("BLACKLIST_MANAGER_ROLE"), blacklistManager); } function testSoftRestricted() public { vm.startPrank(user1); USDe.approve(address(stakedUSDe), 10 ether); stakedUSDe.deposit(10 ether, user1); console.log(stakedUSDe.balanceOf(user1)); vm.startPrank(user2); USDe.approve(address(stakedUSDe), 10 ether); stakedUSDe.deposit(10 ether, user2); vm.startPrank(blacklistManager); stakedUSDe.addToBlacklist(user1, false); stakedUSDe.addToBlacklist(user2, true); vm.startPrank(owner); stakedUSDe.redistributeLockedAmount(user2, user1); console.log(stakedUSDe.balanceOf(user1)); }
create a new test file and paste the whole code above.
manual, foundry.
add if (hasRole(SOFT_RESTRICTED_STAKER_ROLE, to) revert custom error
in the redistributeLockedAmount
function.
Invalid Validation
#0 - c4-pre-sort
2023-11-01T01:50:49Z
raymondfam marked the issue as sufficient quality report
#1 - c4-pre-sort
2023-11-01T01:51:00Z
raymondfam marked the issue as duplicate of #52
#2 - c4-judge
2023-11-10T21:44:04Z
fatherGoose1 marked the issue as satisfactory
#3 - c4-judge
2023-11-27T21:39:51Z
fatherGoose1 marked the issue as not a duplicate
#4 - c4-judge
2023-11-27T21:39:57Z
fatherGoose1 changed the severity to QA (Quality Assurance)
#5 - c4-judge
2023-11-27T21:40:02Z
fatherGoose1 marked the issue as grade-b