sherlock-audit / 2024-08-woofi-solana-deployment-judging

2 stars 2 forks source link

zigtur - Attacker will initialize WooOracle before the project #31

Open sherlock-admin3 opened 1 month ago

sherlock-admin3 commented 1 month ago

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

Internal pre-conditions

  1. The Wooracle PDA account with the correct seeds is not initialized

External pre-conditions

No response

Attack Path

  1. Attacker executes create_wooracle instruction with the correct parameters.

Impact

Attacker gains authority over the wooracle at create_wooracle.rs#L86. This allows him to:

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:

    #[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.

toprince commented 1 month ago

Same with https://github.com/sherlock-audit/2024-08-woofi-solana-deployment-judging/issues/54

sherlock-admin2 commented 1 month ago

The protocol team fixed this issue in the following PRs/commits: https://github.com/woonetwork/WOOFi_Solana/pull/31

gjaldon commented 2 weeks ago

Restricting the creation of pools and oracles to only the WooConfig authority fixes the issue.