# A Vault can steal all funds from another Vault through the Registry's flash loan contract due to insufficient access control in Connector.sendTokensToTrustedAddress()

Any vault keeper can abuse the Registry's BalancerFlashLoan contract to make another vault's connector send its tokens out, stealing all funds.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: alexxander
- Disclosed: 2025-02-17
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/1327
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-08
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic vuln:flash-loan

**Target:** BaseConnector.sendTokensToTrustedAddress / BalancerFlashLoan
**Root cause:** BaseConnector.sendTokensToTrustedAddress() trusts msg.sender == registry.flashLoan() without verifying which vault initiated the flash loan, so any vault's keeper can direct the flash loan contract to call another vault's connector.
**Steps:**
1. Keeper of vault ID-1 calls `BalancerFlashLoan.makeFlashloan()` with tokens/amounts and userData packed as vaultId=ID-1, receiver=C-1, destinationConnector=[C-2, Y], callingData=[`sendTokensToTrustedAddress(Y, X, address(0), "")`, `transferTo(C1, X)`], gas=[enough, enough]
2. Balancer calls `receiveFlashLoan()`; receiver C-1 gets flash loan tokens
3. `destinationConnector[0].call(callingData[0])` invokes C-2's `sendTokensToTrustedAddress`, which passes because msg.sender is registry.flashLoan(); C-2 sends X tokens to BalancerFlashLoan
4. `destinationConnector[1].call(callingData[1])` transfers X tokens from BalancerFlashLoan to C-1
5. C-1 repays flash loan and keeps stolen X tokens
**How found:** Code review of BaseConnector.sendTokensToTrustedAddress() revealed the only access check is msg.sender == registry.flashLoan(), and that BalancerFlashLoan.receiveFlashLoan() executes arbitrary destinationConnector/callingData supplied by the caller, enabling cross-vault calls.
**Exploitation:** A vault keeper uses the shared BalancerFlashLoan contract as a confused deputy: the flash loan callback calls arbitrary destination connectors, and because connectors only check that the caller is the registry's flash loan contract, the attacker's userData can point at a victim vault's connector and instruct it to send its tokens to the flash loan contract, then sweep them to the attacker's connector.
**Insight:** When a shared helper contract (flash loan receiver) is whitelisted by many per-tenant contracts, check whether the helper authenticates which tenant initiated the call; if not, any tenant can drive the helper to invoke another tenant's privileged functions.

