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

Include _proposalId in root_merklehash for _propose Function Body: #4

Open
waterflier opened this issue Jul 31, 2023 · 1 comment
Open

Comments

@waterflier
Copy link
Member

I would like to suggest a security enhancement for the _propose function. Currently, the _proposalId is not included in the root_merklehash. This might leave room for potential replay attacks.

To mitigate this risk, I propose that the _proposalId be included in the root_merklehash. This change would ensure that each proposal is uniquely identified in the root_merklehash, thus providing additional security against replay attacks.

    function _propose(
        address from,
        uint duration,
        bytes32[] memory params,
        bool isFull
    ) internal returns (uint) {
        uint _proposalId = curProposalId++;
        //TODO:
        bytes32 root = MerkleProof.processProof(params, bytes32(0));

Thank you for considering this proposal. I believe this enhancement would significantly improve the security of the system.

@weiqiushi
Copy link
Member

Why does adding proposal id to merkle root can prevent replay attacks?

Under the current code, consider the following scenario:
calling contract perpareActionA(PA) creates a proposal P, params PA, merkle root MerkleRoot(PA)
Members vote for P, P accepted.
Call ActionA(P, PA) to execute the action

Under normal logic, ActionA's contract code should call setProposalExecuted(P), which sets P to Executed state.
When being replay attacked, someone call ActionA(P, PA) again, the operation will be rejected because the state of P is already Executed.

If ActionA does not call setProposalExecuted, replay attack ActionA(P, PA) will work

The situation does not change if the ID is added to the calculation of the merkle root:
Contract interface perpareActionA(PA) creates a proposal P,parameterized by PA, merkle root is MerkleRoot(PA+P)

At this point, if the logic is normal, replay attack ActionA(P, PA) still won't work
If setProposalExecuted is not called, then replay attack ActionA(P, PA) will also work.

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

2 participants