hats-finance / Palmera-0x5fee7541ddcd51ba9f4af606f87b2c42eea655be

Palmera hierarchical module
0 stars 1 forks source link

An attacker can steal reverted transaction signatures and use them to his advantage #71

Open hats-bug-reporter[bot] opened 4 days ago

hats-bug-reporter[bot] commented 4 days ago

Github username: @Rotcivegaf Twitter username: rotcivegaf Submission hash (on-chain): 0x2689978b33a5ee4ff3140655311c842ed2a4825a3e4cff3f099bb9d1dce6aff9 Severity: high

Description:

Description

The function execTransactionOnBehalf of the contract PalmeraModule:

These arguments make it possible that the signatures of the revert calls to execTransactionOnBehalf remain valid and public and an attacker could use these signatures to send the same transaction generating some benefit for the attacker

Attack Scenario

Recommendation

As the behavior of `execTransactionFromModule of ModuleManager.sol of Safe if the call is not success, it should not revert:

@@ -183,7 +183,6 @@ contract PalmeraModule is Auth, Helpers {
         result =
             safeTarget.execTransactionFromModule(to, value, data, operation);

-        if (!result) revert Errors.TxOnBehalfExecutedFailed();
         emit Events.TxOnBehalfExecuted(
             org, caller, superSafe, targetSafe, result
         );

Attachments

PoC

PalmeraModule.sol#L183-L186:

        result =
            safeTarget.execTransactionFromModule(to, value, data, operation);

        if (!result) revert Errors.TxOnBehalfExecutedFailed();
alfredolopez80 commented 1 day ago

Ok, first point @rotcivegaf this is not a issue because is a expected behavior, that's why is because we work with the safe signing flow, if we not permit a any EOA, can call a executionOnBehalf with the rights signatures (as you mention), the user of the RootSafe/SuperSafe, need to signing twice the transaction, and this is very bad UI/UX experience, so we decide to follow the Safe Approach and permit, if the EOA have the right signature right rigth arguments, can execute and pay gas fee of the executuon On Behalf!!!

About the period of valid signature, we recomend our user handle this with ERC4337 control the valid signature with timestamp (Valid After/ Valid until)) with module ERC-4337 of Safe, we think is the better approach at the moment.

https://github.com/safe-global/safe-modules/blob/9a18245f546bf2a8ed9bdc2b04aae44f949ec7a0/modules/4337/contracts/Safe4337Module.sol#L45