Closed c4-bot-9 closed 8 months ago
bytes032 marked the issue as insufficient quality report
Roles can be configured by the deployer based on the Access Control implementation in use by the system, rendering this submission incorrect as the role is meant to be externally assigned.
alex-ppg marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-01-opus/blob/4720e9481a4fb20f4ab4140f9cc391a23ede3817/src/core/shrine.cairo#L793-L798 https://github.com/code-423n4/2024-01-opus/blob/4720e9481a4fb20f4ab4140f9cc391a23ede3817/src/core/roles.cairo#L127-L202
Vulnerability details
Impact
Function
update_yin_spot_price()
fromshrine.cairo
is responsible for updating spot price of yin. However, it uses a role, which is nowhere set. This leads to the scenario, whereupdate_yin_spot_price()
cannot be called by anyone - since protocol does not define anyone withshrine_roles::UPDATE_YIN_SPOT_PRICE
role.Proof of Concept
File: shrine.cairo
When we take a look at
update_yin_spot_price
implementation, we can see, that it can be called byUPDATE_YIN_SPOT_PRICE
role:self.access_control.assert_has_role(shrine_roles::UPDATE_YIN_SPOT_PRICE);
.Now, let's take a look how roles are defined:
File: roles.cairo
However, this role is nowhere defined. Let's scroll over every role for
shrine_roles
:As demonstrated above, no function uses that role. This basically means, that it's not possible to call
update_yin_spot_price()
by anyone, since no one hasUPDATE_YIN_SPOT_PRICE
role.When we futher analyse the
roles.cairo
file (e.g. let's grep forUPDATE_YIN_SPOT_PRICE
), we can notice that this role occurs only here:But,
all_roles()
has#[cfg(test)]
annotation. This annotation, according to Cairo documentation means that:This implies, that
all_roles()
won't be callable on the production environment (#[cfg(test)]
is only for testing environment).To sum up,
UPDATE_YIN_SPOT_PRICE
is defined only inall_roles()
defined for testing purposes (#[cfg(test)]
annotation). In the production environment, we won't be able to useall_roles()
. And, because no other function definesUPDATE_YIN_SPOT_PRICE
role, it won't be possible to callupdate_yin_spot_price()
.Tools Used
Manual code review
Recommended Mitigation Steps
Add additional role in
roles.cairo
related toUPDATE_YIN_SPOT_PRICE
.Assessed type
Access Control