Open sherlock-admin3 opened 1 month ago
zigtur
High
The missing access control check in create_wooracle instruction allows an attacker to initialize the wooracle, to gain authority over it.
create_wooracle
create_wooracle.rs#L62
create_wooracle.rs#L47-L59
No response
Attacker gains authority over the wooracle at create_wooracle.rs#L86. This allows him to:
create_wooracle.rs#L86
incase_token_got_stuck
set_woo_price
quote_feed_account
quote_token_mint
Moreover, the protocol is not able to regain authority on this oracle and the derived pool.
Add a constraint on admin to ensure that it is trusted. This can be done by checking that the admin is part of the authority like this:
admin
#[account(mut, constraint = wooconfig.authority == admin.key() || wooconfig.wooracle_admin_authority.contains(admin.key) )] admin: Signer<'info>,
Note: External WooConfig accounts that are not owned by the current program can be used to bypass this check. However, as the wooconfig key is used to in the PDA seeds of the wooracle, it does not have impact on the protocol.
WooConfig
wooconfig
Same with https://github.com/sherlock-audit/2024-08-woofi-solana-deployment-judging/issues/54
The protocol team fixed this issue in the following PRs/commits: https://github.com/woonetwork/WOOFi_Solana/pull/31
Restricting the creation of pools and oracles to only the WooConfig authority fixes the issue.
zigtur
High
Attacker will initialize WooOracle before the project
Summary
The missing access control check in
create_wooracle
instruction allows an attacker to initialize the wooracle, to gain authority over it.Root Cause
create_wooracle.rs#L62
, there is no access control to ensure that the admin is trusted (is part of the wooconfig).create_wooracle.rs#L47-L59
, the Wooracle PDA account can be initialized only once with the correct seeds.Internal pre-conditions
External pre-conditions
No response
Attack Path
create_wooracle
instruction with the correct parameters.Impact
Attacker gains authority over the wooracle at
create_wooracle.rs#L86
. This allows him to:incase_token_got_stuck
).set_woo_price
instruction for example)quote_feed_account
unrelated toquote_token_mint
Moreover, the protocol is not able to regain authority on this oracle and the derived pool.
PoC
No response
Mitigation
Add a constraint on
admin
to ensure that it is trusted. This can be done by checking that the admin is part of the authority like this:Note: External
WooConfig
accounts that are not owned by the current program can be used to bypass this check. However, as thewooconfig
key is used to in the PDA seeds of the wooracle, it does not have impact on the protocol.