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

MaslarovK - 'hashProposal' function will lead to wrong hash due to a wrong questionId type in the abi.encode #303

Open
sherlock-admin2 opened this issue Oct 7, 2024 · 1 comment
Labels
Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Oct 7, 2024

MaslarovK

Medium

'hashProposal' function will lead to wrong hash due to a wrong questionId type in the abi.encode

Summary

In the hashProposal function, the questionId is set to be uint256, but in the Proposal struct it is set as bytes32.

Root Cause

No response

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

This will lead to wrong hash being generated dues to uint256 being interpret in a different way compared to bytes32.

PoC

No response

Mitigation

Change the hashProposal function as follows:

function hashProposal(Proposal calldata proposal) public view returns (bytes32 digest) {
        digest = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256(
                        "Proposal(address from,uint256 loanAmount,uint256 collateralAmount,uint8 questionType,bytes32 questionId,bool outcome,uint256 interestRatePerSecond,uint256 duration,uint256 validUntil,uint256 salt,uint256 nonce,uint8 proposalType,uint256 protocolFeeBasisPoints)"
                    ),
                    proposal.from,
                    proposal.loanAmount,
                    proposal.collateralAmount,
                    proposal.questionType,
                    proposal.questionId,
                    proposal.outcome,
                    proposal.interestRatePerSecond,
                    proposal.duration,
                    proposal.validUntil,
                    proposal.salt,
                    proposal.nonce,
                    proposal.proposalType,
                    proposal.protocolFeeBasisPoints
                )
            )
        );
    }
@sherlock-admin3 sherlock-admin3 added the Sponsor Confirmed The sponsor acknowledged this issue is valid label Oct 8, 2024
@sherlock-admin2
Copy link
Author

The protocol team fixed this issue in the following PRs/commits:
https://github.com/PredictDotFun/predict-dot-loan/pull/37

@sherlock-admin3 sherlock-admin3 added the Will Fix The sponsor confirmed this issue will be fixed label Oct 10, 2024
@sherlock-admin2 sherlock-admin2 changed the title Custom Rusty Urchin - 'hashProposal' function will lead to wrong hash due to a wrong questionId type in the abi.encode MaslarovK - 'hashProposal' function will lead to wrong hash due to a wrong questionId type in the abi.encode Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

2 participants