# Wrong position address in vault operations

Withdraw/transfer calls naming address(this) or a predicted address instead of the real position or vault

_Area: DeFi accounting and math bugs. Seen in 3 disclosed reports; latest 2025-02-17. Updated 2026-11-09._

## How it works
A function that should act on a specific position or vault instead names the wrong address: the calling contract itself (`address(this)`), or an address predicted before the real contract exists. The assumption that breaks is that the address argument identifies the real account holding the funds or the real counterparty. When it does not, the call reads or moves the wrong balance, reverts, or credits accounting to an address that is not the position. In the prediction case, a guard that checks recipient state at transfer time is bypassed by acting before the recipient is deployed.

## Where it shows up
- Withdraw, decrease, or transfer calls passing `address(this)` where a `position`/`leverParams.position` parameter exists [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md)[E3](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md)
- Overridable hooks where the base contract passes a position parameter but an override substitutes `address(this)` [E3](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md)
- Guards like `_isPublicVault(to)` that validate the recipient only at transfer time [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md)
- Transfers to addresses derived from CREATE (predicted, not yet deployed) [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md)
- Accounting that reads `ownerOf(id)` or similar to attribute balances [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md)
- Sibling functions where one was fixed and another still carries the same wrong-argument pattern [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md)

## How to review
For every call that takes an address argument, confirm the argument is the actual position/vault that holds the funds, not the caller. The invariant: the address passed to withdraw/decrease/transfer must equal the address whose balance the operation is meant to change, and must be the same address used elsewhere in the flow. For recipient guards, the invariant is that the check must hold for the recipient's eventual state, not just its state at call time; a predicted-but-undeployed address must be treated as the future contract it will become. Grep overrides of hooks that receive a position parameter and verify each uses it.

## How finders spotted it
- Read `transferFrom`'s `_isPublicVault(to)` guard and noticed it is time-of-transfer only, while CREATE addresses are predictable, so a pre-deployment transfer slips through [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md)
- Noticed a prior fix (M-35) patched only `_onDeposit`; reviewing `_onWithdraw` showed the same `address(this)` vs `position` mistake remained [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md)
- Reviewed the `Position4626` override of `_onDecreaseLever` and saw the withdraw target is `address(this)` rather than the `leverParams.position` used elsewhere [E3](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md)

## Variants seen
- Transfer to a predicted future vault address bypassing a recipient guard [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md)
- Withdraw from `address(this)` instead of the position in `_onWithdraw` [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md)
- Withdraw from `address(this)` instead of `leverParams.position` in `_onDecreaseLever`, causing reverts [E3](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md)

## Why fixes fail
A prior audit fix corrected `_onDeposit` but left the identical wrong-argument pattern in `_onWithdraw`, so the bug survived [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md).

## Impact and severity
Corrupted vault accounting from misattributed balances [E1](https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md); withdrawals that revert or misdirect collateral [E2](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md); `decreaseLever` always reverting for 4626 vaults [E3](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md). Severity is raised when the wrong address corrupts shared accounting rather than just failing a single call.

## Evidence
- E1: https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AM-04.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AM-03.md
- E3: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-09.md
