Magpie V2

QuillAuditsFiles named in the report

Audit · firm’s term: audit report

QuillAudits reviewed Magpie Protocol (Magpie V2) on 24 Sep 2024: 14 findings, 0 critical; 11 marked fixed, 3 open.

No open critical findings
Open the reportOpen Magpie Protocol’s security record

Report hosted on quillaudits.com.

Trustblock does not review code.

Findings14

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High101
Medium105
Low105
HighThe Refund Address Can Be Set To Internal Caller In MagpieCelerBridgeV2Fixed

In MagpieCelerBridgeV2, within the swapIn function the refundAddresses[depositDataHash] is always set to msg.sender. However, the swapIn can be called either by swapInWithMagpieSignature or swapInWithUserSignature which have different authorisation. Therefore, whenever swapInWithUserSignature is called, the refundAddresses can be set to the internal caller. As a result, in the event of the bridge transfer failure, the tokens will be transferred back to the incorrect address.

MediumIneffective Implementation of the Emergency-Stop PatternFixed

The MagpieRouterV3 contract implements the Pausable library. Functions: estimateSwapGas and swapWithMagpieSignature are marked as whenNotPaused. However, there is no public or external function that allows the protocol’s owner to toggle paused state on or off. Thus, it is not possible to use the emergency-stop pattern in the event of an emergency situation.

MediumMagpieCelerBridgeV2 Does Not Support Native Token BridgingFixed

Within the MagpieCelerBridgeV2, the bridgeIn function has an ‘if’ condition suggesting that native tokens can be bridged as well. However, the final call to the sendMessageWithTransfer only passes bridgeFee and not the bridgeFee + amount (amountOut from swapIn). Also, on the contrary the MagpieStargateBridgeV3 calculates the valueToSend, to determine the amount that should be sent. Ultimately, within the Celer Network the separate function exists to send native tokens: sendNative. Thus, this bridge only supports ERC20 tokens and wrapped native token, but not native.

MediumPermit Front-run Affects the Legitimate Execution CallFixed

Within the MagpieRouterV3 contract three functions: estimateSwapGas, swapWithMagpieSignature, swapWithUserSignature make use of permit functionality for ERC20 tokens to set gas-less allowance. However, the permit function can be called by anyone anytime whenever the permit’s signature becomes public. Thus, an adversary can extract the permit signature from the functions’ calldata, front-run legitimate call and execute ERC20 token’s permit. As a result, the legitimate call will revert as the permit's nonce is incremented and the signature is not valid anymore.

MediumSignature Is Not Bound To Particular User in swapWithMagpieSignatureFixed

Within the MagpieRouterV3 contract the swapWithMagpieSignature allows the user to trigger swap operation, if only the user has been given the valid signature signed by the internalCaller. However, this signature-based authorisation is flawed as it does not include from address in the signed message - thus, it is not bound to a particular user. As a result, any user can use any signature generated by the internal caller, triggering swap operation.

MediumThe executeMessageWithTransferRefund can revert due to various reasonsFixed

The MagpieCelerBridgeV2 contract implements the executeMessageWithTransferRefund function, which is designed to handle bridge’s refund in the event of unsuccessful bridging. However, this function attempts to immediately transfer refunded assets to the user. This feature may revert in following use cases:• Whenever a refunded asset is a native token and the receiver address is a contract with custom receive()/fallback function, the transaction can revert due to Out Of Gas error. • Whenever a refunded asset is a USDC or similar token implementing the blacklisting, whenever the address get blacklisted between bridging and refund, it will revert due to ERC20 transfer revert.

LowMagpieCelerBridgeV2’s swapOut Function Lacks Condition CheckFixed

The swapOut function in the MagpieCelerBridgeV2 contract has a condition check to handle the event when Celer changes the mapping for native token address. However, this if and else if conditions lack final else fallback, to handle citation when depositAmount is equal to 0 and it is not native asset.

LowNot Optimized Storage Usage Consumes More GasFixed

The *Bridge contracts have defined the swapSequence variable with uint64 type. Thus, this state variable occupies only 8 bytes from the storage slot. However, it is declared in between two other variables that occupy full slots. Eventually, such order of variables impacts the storage slots used, as swapSequence starts occupying a new slot, when it could be attached to other variable which occupies only 20 bytes out of 32.

LowThe execute Function Can Be Front-RunnedFixed

The MagpieCCTPBridge and MagpieSymbiosisBridge contracts implement the execute() function which is meant to be called by the gateway. However, this function can be called by anyone. If the function is front-run, the legitimate call by the gateway will be reverted, as a second call with the same data to validateContractCall function will revert. No identified risk is associated with this behavior in on-chain processing, however, it may have an impact on the off-chain processing. If off-chain expects that this function is called only by specific address and processes the emitted event only in such a case, it may pose a risk that the call will be unhandled.

LowThe swapOut Can Finish Without Consuming AllowanceFixed

The swapOut function in the LibBridge library attempts to swap tokens considering an exchange between native and non-native tokens. Whenever a swap occurs for not equal non-native tokens, the function firstly calls approve for router contract for fromAssetAddress token with amountIn as amount. Then, it attempts to swap tokens, which in the event of failure returns a boolean flag. If the swap is unsuccessful, the fromAssetAddress tokens are transferred to the toAddress instead. However, the allowance set before the swap operation is not reset.

Show 1 more
LowThe UniswapV3SwapCallback Does Not Check CallerFixed

The MagpieRouterV3 implements fallback() function to handle the incoming uniswapV3SwapCallback. The Uniswap’s documentation states that The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. However, no such check is implemented, which is noted in the developer’s comments. The router contract is meant to not hold any ERC20 tokens. Nevertheless, in the event of having positive balance for some ERC20 tokens, this function can be abused to sweep them. The finding was reported as a deviation from leading security practices.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (28)

  • contracts/interfaces/celer/IMessageBus.sol
  • contracts/interfaces/IMagpieCCTPBridge.sol
  • MagpieCCTPBridge.sol
  • contracts/MagpieSymbiosisBridge.sol
  • contracts/interfaces/IMagpieCelerBridgeV2.sol
  • MagpieStargateBridgeV3.sol
  • contracts/interfaces/cctp/IReceiver.sol
  • contracts/interfaces/IMagpieSymbiosisBridge.sol
  • MagpieRouterV3.sol
  • contracts/libraries/LibBridge.sol
  • contracts/MagpieStargateBridgeV3.sol
  • contracts/libraries/LibAsset.sol
  • MagpieCelerBridgeV2.sol
  • contracts/interfaces/axelar/IAxelarGateway.sol
  • contracts/libraries/LibRouter.sol
  • contracts/interfaces/IBridge.sol
  • contracts/interfaces/IMagpieRouterV3.sol
  • contracts/interfaces/stargate/IStargate.sol
  • contracts/MagpieCelerBridgeV2.sol
  • contracts/interfaces/axelar/IAxelarGasService.sol
  • contracts/MagpieRouterV3.sol
  • MagpieSymbiosisBridge.sol
  • contracts/interfaces/IWETH.sol
  • contracts/interfaces/IMagpieStargateBridgeV3.sol
  • contracts/interfaces/stargate/IOFT.sol
  • magpie-contracts/contracts/MagpieRouterV3.sol
  • contracts/MagpieCCTPBridge.sol
  • contracts/interfaces/celer/ILiquidityBridge.sol

Part of Magpie Protocol’s security record

Magpie Protocol
Audits2 audits by 2 firmsLast audit Sep 2024, by QuillAudits.
Critical findingsNo open critical findingsAcross 2 reports.
Open Magpie Protocol’s security record

Security firm

QuillAudits

350 projects reviewed · 459 reports · latest Apr 2025

See QuillAudits’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us