sherlock-audit / 2024-04-titles-judging

9 stars 6 forks source link

fibonacci - TitlesGraph's acknowledge/unacknowledge edge functions DoS #230

Closed sherlock-admin3 closed 4 months ago

sherlock-admin3 commented 4 months ago

fibonacci

high

TitlesGraph's acknowledge/unacknowledge edge functions DoS

Summary

TitlesGraph's acknowledge/unacknowledge edge functions, which utilize signatures, can be susceptible to front-running and blocking.

Vulnerability Detail

A user can acknowledge an edge by using an ECDSA signature.

function acknowledgeEdge(bytes32 edgeId_, bytes calldata data_, bytes calldata signature_)
    external
    checkSignature(edgeId_, data_, signature_)
    returns (Edge memory edge)
{
    return _setAcknowledged(edgeId_, data_, true);
}
...
function unacknowledgeEdge(bytes32 edgeId_, bytes calldata data_, bytes calldata signature_)
    external
    checkSignature(edgeId_, data_, signature_)
    returns (Edge memory edge)
{
    return _setAcknowledged(edgeId_, data_, false);
}

The signed message does not include information about the action being performed.

bytes32 digest = _hashTypedData(keccak256(abi.encode(ACK_TYPEHASH, edgeId, data)));

Consequently, the same signature can be used to both acknowledge and unacknowledge an edge.

A malicious user can front-run a call and use the same signature for the opposite action.

Impact

  1. A user intends to acknowledge an edge. To accomplish this, they generate a signature and call the acknowledge function.
  2. A malicious actor notices the transaction, extracts the signature from it, and proceeds to front-run by calling the unacknowledge function with the same signature.
  3. The user's original transaction fails to execute because the same signature cannot be utilized more than once.
_isUsed[keccak256(signature)] = true;
  1. Consequently, the edge remains unacknowledged.

Code Snippet

https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/graph/TitlesGraph.sol#L118-L124 https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/graph/TitlesGraph.sol#L146-L152 https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/graph/TitlesGraph.sol#L40-L50

Tool used

Manual Review

Recommendation

- bytes32 digest = _hashTypedData(keccak256(abi.encode(ACK_TYPEHASH, edgeId, data)));
+ bytes32 digest = _hashTypedData(keccak256(abi.encode(ACK_TYPEHASH, edgeId, acknowledge, data)));

Duplicate of #273

0xf1b0 commented 3 months ago

Escalate

This is a duplicate of issue #273, which is considered valid.

sherlock-admin3 commented 3 months ago

Escalate

This is a duplicate of issue #273, which is considered valid.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

WangSecurity commented 3 months ago

Agree with the escalation, planning to accept and duplicate with #273

Evert0x commented 3 months ago

Result: Medium Duplicate of #273

sherlock-admin4 commented 3 months ago

Escalations have been resolved successfully!

Escalation status: