<!-- canonical: https://0xsimao.com/findings/fuji-finance-fails-record-message-gas -->

# ConnextRouter fails to record failed message if gas sent is not enough

Crit/High · Three Sigma · Lending aggregator · 6th May, 2023

Finding 3S-FUJI-M06 of the Fuji Finance security review.

- Report: /reports/fuji-finance
- Source: https://cdn.sanity.io/files/qoqld077/staging/32181a28eac3175d15fb8924d249bb0d91ca350c.pdf

---

### Description

The ConnextRouter places the xBundleConnext(...) call on a try/catch block to prevent
failed actions to make the transaction revert and the funds being given to Connext. The EVM
saves 1/64th of gas before an external call to try to finish execution after the external call.
However, if the xBundleConnext(...) transaction inside the try/catch fails, the following
execution consumes a non significant amount of gas (transferring and recording the failed
message), such that 1/64 of the sent gas could not be enough to finish the execution.

### Recommendation

Calculate the minimum amount required of gas to finish execution after the try/catch block
and revert if this gas is not available prior to the block with gasleft(). This ensures that
whatever actions users do inside the try/catch block, the message will always be recorded if
it fails.

### POC

https://github.com/threesigmaxyz/fuji-issues/blob/master/test/POC/POCXReceiveGas.t.sol#L34

### Status

Acknowledged with the following statement:
The issue identified is acknowledged by the Fuji team, however, as indicated the likelihood
of its occurrence is low. Along with issue 3S-FUJI-N05, during Q3-2023 we will be working
on general optimizations/improvements on the router contracts that will allow a more
consistent estimation of gas during a failed transfer and implement fix as suggested.

---

Related findings:

- [Slashing fails when node operator doesn't have enough staked `GGP`](https://0xsimao.com/findings/gogopool-slashing-fails-node-ggp): GoGoPool
- [mTapiocaOFT can't be rebalanced because the Balancer in tapiocaz-audit calls swapETH() or swap() of the RouterETH but does not forward ether for the message fee](https://0xsimao.com/findings/tapioca-dao-rebalanced-balancer-eth-fee): Tapioca DAO
- [Metadata is not set in Cap, which is required by the inherited Router to specify gas limit to the mailbox](https://0xsimao.com/findings/mitosis-metadata-inherited-gas-mailbox): Mitosis
