Hooks.wtf

Recipients

BuyAndBurnRecipient.sol

BuyAndBurnRecipient places revenue into a bid for the launched token. The findings cover revenue currencies without a matching pool and replacement bids priced from manipulated spot.

Reviewed source: src/recipients/BuyAndBurnRecipient.sol at commit 38f14ff.

Findings

IDSeverityFinding
B-02MediumGraduated ETH revenue is locked for Buy-and-Burn routes without an ETH pair
B-07MediumA price push held across one block extracts the Buy-and-Burn budget

[MEDIUM] B-02 · Graduated ETH revenue is locked for Buy-and-Burn routes without an ETH pair

B-02 · Medium

Graduation introduces ETH revenue for every launch, but Buy-and-Burn cannot receive it when the launch has no ETH pair. Once allocated, that share cannot be recovered.

Graduation registers native ETH as a revenue currency, including for launches paired only with ERC20s. The index fund then sends the project's half of constituent liquidity fees to Flaunch in ETH.

BuyAndBurnRecipient accepts a currency only if it identifies a registered Flaunch pool for the launched token. An ERC20-only launch has no ETH pool, so the recipient rejects the payment with InvalidPool. Distribution catches that failure and keeps the amount credited to the same recipient.

The credit can only be paid to that recipient. Changing the royalty route does not move an existing allocation, and the missing ETH pool cannot be added after launch. The retry path therefore has no state in which it can succeed.

Impact

The Buy-and-Burn share of each allocated ETH harvest is permanently locked in Flaunch. No attacker receives it. Both harvesting and distribution are permissionless, so a third party can allocate a harvest before the owner changes the route. If the royalty permission or launch NFT has been burned, the route cannot be changed and every future harvest remains exposed.

The source review rates this Medium, with a borderline High assessment, because the loss is permanent but limited to a share of project revenue.

Affected code

Locations refer to the reviewed commit, 38f14ff.

From src/recipients/BuyAndBurnRecipient.sol:98–104:

bool launchedIs0 = launched < _token;

// These parameters are fixed by Flaunch._createPool; validate the resulting registry entry.
PoolKey memory key = PoolKey(Currency.wrap(launchedIs0 ? launched : _token), Currency.wrap(launchedIs0 ? _token : launched), 0, 60, factory.flaunchHook());
if (factory.poolToken(key.toId()) != launched || factory.poolTokenId(key.toId()) != _tokenId) {
    revert InvalidPool();
}

Proof of concept

  1. Launch with an ERC20 pair and a 50/50 route between Buy-and-Burn and a payable address recipient.
  2. Graduate the launch, trade its index position and harvest the resulting ETH fees.
  3. Call distribute, retry the Buy-and-Burn payment, then replace the route and try again.

BuyAndBurnGraduationEthStuck.t.sol::test_graduatedEthRevenueIsStuckForBuyAndBurnOnErc20OnlyLaunch leaves 0.00225 ETH credited to Buy-and-Burn while the other recipient is paid. Retries and a route change do not release the credit. A second test freezes a 100% Buy-and-Burn route and shows all three harvests remain locked. IndexAudit.t.sol::test_A_graduationETHStuckForERC20PairedBuyAndBurn independently reproduces the path through the real index fund.

A launch with a native-ETH pair can accept the same receipt into its ETH position.

The test source is poc/BuyAndBurnGraduationEthStuck.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:

FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/BuyAndBurnGraduationEthStuck.t.sol' -vv

Give Buy-and-Burn a defined fallback when a revenue currency has no matching pool, such as an escrow credit for the launch NFT owner. Do not leave the receipt permanently unpayable.

Test graduation of an ERC20-only launch against every shipped recipient type, including retries and frozen royalty routes.

[MEDIUM] B-07 · A price push held across one block extracts the Buy-and-Burn budget

B-07 · Medium

Each receipt re-places the unspent Buy-and-Burn budget beside live spot. Holding a price push across one block passes the same-block guard and lets the attacker sell into that bid.

On receipt of new revenue, Buy-and-Burn withdraws its existing position and re-places the full unspent budget in one tick-spacing beside the current spot price. The protection checks only whether the pool has already swapped in the current block.

An attacker can push the price in block N, then make a dust deposit and call the permissionless distribution function in block N+1. The guard now passes even though spot still reflects the attacker's trade. The attacker sells into the freshly placed bid.

The protocol README already states that the same-block guard is not an oracle check and does not stop manipulation carried across blocks. This finding quantifies that documented limitation.

Earlier review: Residual of F-05. The same-block form is fixed; manipulation held across blocks is still possible and documented.

Impact

Revenue intended for buying and burning the launched token is instead paid to the attacker at the manipulated price. The attack needs trading capital and a position held across a block, but the measured extraction exceeds the swap costs.

Affected code

Locations refer to the reviewed commit, 38f14ff.

From src/recipients/BuyAndBurnRecipient.sol:152–156:

if (flaunchHook.lastSwapBlock(key.toId()) == block.number) {
    emit PlacementDeferred(tokenId, paired, block.number, position.pending);
    emit PositionUpdated(tokenId, paired, position.tickLower, position.tickUpper, position.liquidity, position.pending);
    return bytes('');
}

Proof of concept

BuyAndBurnCrossBlockSandwich.t.sol::test_crossBlockSandwichExtractsWholeBuyAndBurnBudget starts with a 2 ETH budget. The attacker uses 8 ETH of capital to push price, waits one block, triggers a receipt and sells into the replacement bid. Net profit after both 1% swap fees is 1.2307 ETH, about 61.5% of the budget, with no tokens left over.

test_control_sameBlockPushIsDeferred confirms that the existing guard correctly defers placement when the price push and receipt occur in the same block.

The test source is poc/BuyAndBurnCrossBlockSandwich.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:

FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/BuyAndBurnCrossBlockSandwich.t.sol' -vv

Check spot against a time-weighted reference before placing a bid. Also consider capping the budget re-placed per receipt or leaving an existing resting bid in place rather than moving it whenever new revenue arrives.

Previous
TrustedSignerFeeCalculator.sol