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

Huge Navy Condor - wrong implement of verify. #1060

Open
sherlock-admin3 opened this issue Dec 30, 2024 · 0 comments
Open

Huge Navy Condor - wrong implement of verify. #1060

sherlock-admin3 opened this issue Dec 30, 2024 · 0 comments

Comments

@sherlock-admin3
Copy link
Contributor

Huge Navy Condor

Medium

wrong implement of verify.

Summary

here in the verify function we are not verifying the nonce as we are keeping that value is zero.

Root Cause

https://github.com/sherlock-audit/2024-11-autonomint/blob/main/Blockchain/Blockchian/contracts/Core_logic/CDS.sol#L864
function verify(
bytes memory odosExecutionData,
bytes memory signature
) external view onlyBorrowingContract returns (bool) {
return
_verify(
FunctionName.BORROW_WITHDRAW,
0,
0,
odosExecutionData,
signature
);
}

function _verify(
    FunctionName functionName,
    uint256 excessProfitCumulativeValue,
    uint256 nonce,
    bytes memory odosExecutionData,
    bytes memory signature
) private view returns (bool) {
    bytes32 digest;
    if (functionName == FunctionName.CDS_WITHDRAW) {
        digest = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256(
                        "Permit(uint256 excessProfitCumulativeValue,uint256 nonce)"
                    ),
                    excessProfitCumulativeValue,
                    nonce
                )
            )
        );
    } else if (functionName == FunctionName.BORROW_WITHDRAW) {
        digest = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256("OdosPermit(bytes odosExecutionData)"),
                    odosExecutionData
                )
            )
        );
    }

    address signer = ECDSA.recover(digest, signature);
    bytes32 hashedSigner = keccak256(abi.encodePacked(signer));
    if (hashedSigner == hashedAdminTwo) {
        return true;
    } else {
        return false;
    }
}

}

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

verify can be replayed.

PoC

No response

Mitigation

donot keep the nonce as zero as constant.

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