From 941879d5d6657c1a3b5e7f77b2b8a4ab76e2f574 Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Fri, 6 Jun 2025 17:01:48 +0100 Subject: [PATCH] fix(BalancerV3Executor): Slice callback data nicely Make a stricter data validation Took 35 minutes --- foundry/src/executors/BalancerV3Executor.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/foundry/src/executors/BalancerV3Executor.sol b/foundry/src/executors/BalancerV3Executor.sol index da79327..19aa12f 100644 --- a/foundry/src/executors/BalancerV3Executor.sol +++ b/foundry/src/executors/BalancerV3Executor.sol @@ -87,8 +87,9 @@ contract BalancerV3Executor is IExecutor, RestrictTransferFrom, ICallback { returns (bytes memory result) { verifyCallback(data); - result = _swapCallback(data[68:]); - // Our general callback logic returns a not ABI encoded result. + // Remove the first 68 bytes 4 selector + 32 dataOffset + 32 dataLength and extra padding at the end + result = _swapCallback(data[68:181]); + // Our general callback logic returns a not ABI encoded result (see Dispatcher._callHandleCallbackOnExecutor). // However, the Vault expects the result to be ABI encoded. That is why we need to encode it here again. return abi.encode(result); } @@ -112,7 +113,7 @@ contract BalancerV3Executor is IExecutor, RestrictTransferFrom, ICallback { address receiver ) { - if (data.length < 113) { + if (data.length != 113) { revert BalancerV3Executor__InvalidDataLength(); }