Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOA-05M] Incorrect Validation Logic #10

Open
Haypierre opened this issue Dec 10, 2024 · 1 comment
Open

[BOA-05M] Incorrect Validation Logic #10

Haypierre opened this issue Dec 10, 2024 · 1 comment

Comments

@Haypierre
Copy link
Collaborator

BOA-05M: Incorrect Validation Logic

Type Severity Location
Logical Fault BaseOpenfortAccount.sol:L163-L169

Description:

The current BaseOpenfortAccount::_validateSignature validation logic will consider all calls with invalid ECDSA payloads that produce a signer address of 0 to be correct.

Impact:

All invalid signatures will be considered correct by the current BaseOpenfortAccount::_validateSignature mechanism.

Example:

function _validateSignature(bytes32 _hash, bytes memory _signature, uint256 _to, bytes calldata _data)
    internal
    returns (bytes4 magic)
{
    magic = EIP1271_SUCCESS_RETURN_VALUE;
    address signerAddress = _recoverECDSAsignature(_hash, _signature);

    // Note, that we should abstain from using the require here in order to allow for fee estimation to work
    if (signerAddress != owner() && signerAddress != address(0)) {
        // if not owner, try session key validation
        if (!isValidSessionKey(signerAddress, _to, _data)) {
            magic = "";
        }
    }
}

Recommendation:

We advise the code to assign an EIP1271_SUCCESS_RETURN_VALUE to the magic variable solely when verification has been successful (i.e. if (signerAddress == owner() || isValidSessionKey(signerAddress, _to, _data)) magic = EIP1271_SUCCESS_RETURN_VALUE;).

@Haypierre
Copy link
Collaborator Author

Haypierre commented Dec 10, 2024

Remark:

Description and Impact are incompatible: only invalid signatures with a hash that recovers to address(0) will be considered valid, NOT All invalid signatures.

The ecrecover precompile will yield the zero address on failure which can be trivially crafted:

This is the reason that the standard OpenZeppelin library checks for this scenario here:

This has been addressed in #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant