T05 · Unauthorized Access and Privilege Escalation
- Location
references/cl_lp.py:574- Finding
Unscoped residual-position cleanup can redeem unrelated LP positions
- Content
View full analysis
list[dict]: """Query all LP positions for this pool. Returns list of {tokenId, assets, value}.""" if not WALLET_ADDR: return [] data = onchainos_cmd( [ "defi", "position-detail", "--address", WALLET_ADDR, "--chain", POOL_CHAIN, "--platform-id", PLATFORM_ID, ], timeout=20, ) if not data or not data.get("ok") or not data.get("data"): return [] result = [] try: for platform in data["data"]: for wallet in platform.get("walletIdPlatformDetailList", []): for network in wallet.get("networkHoldVoList", []): for invest in network.get("investTokenBalanceVoList", []): for pos in invest.get("positionList", []): tid = str(pos.get("tokenId", "")) assets = pos.get("assetsTokenList", []) value = sum( float(a.get("currencyAmount", 0)) for a in assets ) result.append( {"tokenId": tid, "assets": assets, "value": value} ) except (KeyError, ValueError, TypeError): pass return result def cleanup_residual_positions(keep_token_id: str) -> int: """Redeem all positions except keep_token_id. Returns count of cleaned positions.""" positions = _query_all_positions() cleaned = 0 for pos in positions: tid = pos["tokenId"] if tid == keep_token_id or not tid: continue val = pos["value"] log(f" Cleaning resid ...[truncated 2195 chars]- Remediation
View remediation
