Platform: Code4rena
Start Date: 23/06/2023
Pot Size: $60,500 USDC
Total HM: 31
Participants: 132
Period: 10 days
Judge: 0xean
Total Solo HM: 10
Id: 254
League: ETH
Rank: 109/132
Findings: 1
Award: $18.42
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: alexweb3
Also found by: D_Auditor, DedOhWale, DelerRH, LuchoLeonel1, Musaka, Neon2835, Silvermist, Timenov, TorpedoPistolIXC41, adeolu, cartlex_, hals, josephdara, koo, lanrebayode77, mahyar, mladenov, mrudenko, pep7siup, zaevlad, zaggle
18.4208 USDC - $18.42
https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/configuration/LybraConfigurator.sol#L85-L88 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/configuration/LybraConfigurator.sol#L90-L93
A malicious user can manipulate the basic functions of the LybraConfigurator.sol
contract and set arbitrary values to variables, which would significantly harm the protocol.
In LybraConfigurator.sol
there are two modifiers onlyRole
and checkRole
they restrict the functions that non-privileged users can use.
modifier onlyRole(bytes32 role) { GovernanceTimelock.checkOnlyRole(role, msg.sender); _; } modifier checkRole(bytes32 role) { GovernanceTimelock.checkRole(role, msg.sender); _; }
Inside the onlyRole
modifier it calls onlyRole
function of GovernanceTimelock.sol
contract and check if user has a specified role. onlyRole
function returns bool
and if it returns true
it means that user has a role and can call functions in Configurator.sol
contract. But there is an issue onlyRole
modifier doesn't check if onlyRole
function returns anything. Same situation with checkRole
modifier.
Since that, anyone can call an admin function and harm the protocol.
Manual review, foundry.
Add require to checkRole
and onlyRole
modifiers to check if the functions inside them return true
:
modifier onlyRole(bytes32 role) { require(GovernanceTimelock.checkOnlyRole(role, msg.sender)); _; } modifier checkRole(bytes32 role) { require(GovernanceTimelock.checkRole(role, msg.sender)); _; }
Access Control
#0 - c4-pre-sort
2023-07-09T02:05:22Z
JeffCX marked the issue as duplicate of #704
#1 - c4-judge
2023-07-28T15:24:05Z
0xean marked the issue as satisfactory