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

fix: Guard against malicious processors [SUP-8873] #639

Merged
merged 54 commits into from
Oct 25, 2024

Conversation

TamaraRingas
Copy link

Problem

A malicious processor can take advantage of the refund mechanism.

completeCrossChainRebalance() complete a cross chain rebalance initiated by the user with startCrossChainRebalance(). This function could be called only by an address with a ROUTER_PLUS_PROCESSOR_ROLE. As the processor can pass arbitrary data as function arguments to both functions he can take advantage of the refund mechanism, leading to two possible scenarios:

Processor can force unnecessary refunds in completeCrossChainRebalance(): by passing a specific expectedAmountInterimAsset, he can force unnecessary refunds on every payload to be processed.
Processor can steal all SuperformRouterPlusAsync funds: by starting a cross chain rebalance himself and thus passing a fake expectedAmountInterimAsset, he can issue a refund to himself stealing funds from the SuperformRouterPlusAsync contract.

Solution

  • Refactor refund mechanism to include a requestRefund() function and a corresponding approveRefund() function that is only callable by CORE_STATE_REGISTRY_RESCUER

  • Update tests

Copy link

linear bot commented Oct 16, 2024

@TamaraRingas TamaraRingas changed the base branch from v1.5-yAudit to v1.5 October 17, 2024 07:44
Copy link
Contributor

@0xTimepunk 0xTimepunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in RouterPlus async look good to me.
Please review formatting changes in all the other src files and forge-scripts folder (which should be reverted to their original state).

Once you commit CI should run and let us know if there was any coverage drop with the function changes.

Also wondering why yAudit mentioned to revert at slippage check failure, it doesn't seem necessary to me - after we clean up let's bring this PR for discussion in discord for them to review the fix.

src/router-plus/SuperformRouterPlusAsync.sol Show resolved Hide resolved
Copy link
Contributor

@0xTimepunk 0xTimepunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few final fixes and LGTM

src/router-plus/SuperformRouterPlusAsync.sol Show resolved Hide resolved
src/router-plus/SuperformRouterPlusAsync.sol Show resolved Hide resolved
@superform-xyz superform-xyz deleted a comment from TamaraRingas Oct 24, 2024
@0xTimepunk 0xTimepunk merged commit 3d85405 into v1.5 Oct 25, 2024
6 checks passed
@0xTimepunk 0xTimepunk deleted the tamara-sup-8873-guard-against-malicious-processors branch October 25, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants