hats-finance / Most--Aleph-Zero-Bridge-0xab7c1d45ae21e7133574746b2985c58e0ae2e61d

Aleph Zero bridge to Ethereum
Apache License 2.0
0 stars 1 forks source link

Wrong `modifier()` implemented in `Migrations.sol` #24

Open hats-bug-reporter[bot] opened 5 months ago

hats-bug-reporter[bot] commented 5 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0xf214da4962e8bf41d0d0ce7aca5c48c7ba251045dd559f11aaec80fa0adcf5fa Severity: minor

Description: Description\ In the Migrations.sol file, there's a modifier named restricted() that's supposed to prevent certain functions from being called by anyone except the contract owner. However, there's an issue with this modifier. Currently, it doesn't perform strict checks, meaning it allows any account to call the restricted functions without causing a revert. Although the transaction appears successful, it doesn't actually change the state variables.

To rectify this issue, it's recommended to modify the restricted() modifier to include strict checks and revert the transaction.

PoC

here is step by step process:

same scenario for upgrade() function.

Reccomendation

Here's a suggested fix:

// Define a custom error message for unauthorized callers
error UnauthorizedAccess();

// Modify the restricted modifier to perform strict checks
modifier restricted() {
    // Only allow the owner to proceed, otherwise revert with an error message
    if (msg.sender != owner) 
        revert UnauthorizedAccess();
    // If the caller is the owner, continue with the function execution
    _;
}
krzysztofziobro commented 5 months ago

duplicate of https://github.com/hats-finance/Most--Aleph-Zero-Bridge-0xab7c1d45ae21e7133574746b2985c58e0ae2e61d/issues/18