[ghost-dao-contracts] External-deposit lock bypassed by unstake/wrap/unwrap (variant of daffh #135)

Component: ghost-dao-contracts @ b87dff4, src/Staking.sol:144-160 (unstake), src/Staking.sol:162-170 (wrap), src/Staking.sol:172-179 (unwrap).

Description: daffh #135 established that GhostStaking.stake()'s direct-claim branch skips the locks[to] check, letting anyone force funds into an opted-out wallet. The same missing check exists in three more external functions that take an arbitrary to: unstake (no lock check, forces FTSO into to), wrap (no lock check, mints gHST to to), and unwrap (no lock check, forces sFTSO into to). Meanwhile claim() (line 116) and claimByAmount() (line 124) both enforce if (locks[to] && to != msg.sender) revert ExternalDepositsLocked();, so the omission is inconsistent, not a design choice. toggleLock() exists precisely so users can opt out of external deposits (dusting/privacy), and these three functions defeat it.

Impact: Anyone can force FTSO, gHST, or sFTSO into a wallet that explicitly opted out of external deposits. No theft or loss; the harm is non-consensual receipt (dusting, unwanted association).

Reproduction: test/poc/Tim4Round2.t.sol: 3 passed. Setup: victim calls toggleLock(); attacker stakes normally. All three tests show the victim receiving tokens despite the lock, including a control proving claim() to the locked wallet reverts.

Severity: Low. Reason: same class as the reported #135; no fund-loss or privilege-escalation path, only violation of an explicit user opt-out.

Recommendation: Add the same locks[to] && to != msg.sender guard to unstake, wrap, and unwrap (or, equivalently, to the direct-claim branch of stake per #135, for consistency across all six).

Verification: VERIFIED (forge PoC executed, passed).

Thank you for your report!

You are right - and moreover, this was done intentionally to give the user flexibility in choosing the destination for their funds. If possible, could you outline the possible issues with this approach? At the moment, it’s unclear how it could be used to harm anyone.

Fair point on the flexibility rationale. The reason I flagged it is the inconsistency inside the codebase itself: stake(), claim(), and claimByAmount() all enforce locks[to], while unstake(), wrap(), and unwrap() take an arbitrary to with no check. So either the lock is a real user protection that is unevenly applied, or it is vestigial and the three existing guards are dead code. Whichever way, the six external-deposit paths disagree with each other.

Concrete issues with the bypass, given a user explicitly opted out via toggleLock():

  1. Dusting / deanonymization. The lock exists so users can refuse unsolicited deposits; forcing FTSO, gHST, or sFTSO into a locked wallet defeats that explicit privacy choice. Unsolicited micro-receipts are the classic chain-analysis clustering vector.
  2. Unwanted association. Receiving tokens from arbitrary parties can taint an address’s history, which is a real headache for regulated users and entities with compliance obligations.
  3. Griefing. Anyone can repeatedly push tokens into a locked wallet; no fund loss, but a harassment vector the user explicitly tried to close.

No theft or fund-loss path here, so I keep this at Low. Two clean resolutions: apply the same locks[to] && to != msg.sender guard to all six paths, or document that toggleLock is advisory-only so users do not rely on it.

Looks like the changes are in the commit. Can you verify they are good to go?