T07 · Tool Hijacking and Spoofing
Error
- Location
- colony-cli.mjs:379
- Finding
- Blind Signing of Remotely Supplied Jupiter Transactions<![CDATA[ ## Vulnerability Details **File Location**: `colony-cli.mjs:379-383, 443-467` **Vulnerability Type**: Blind signing of untrusted serialized transactions **Risk Level**: High ### Vulnerable Code ```js async function sendVersionedTx(connection, keypair, vtx) { vtx.sign([keypair]); const rawTx = vtx.serialize(); const signature = await connection.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 5, }); ``` ```js async function jupiterSwap(keypair, solAmount) { requireJupiterKey(); const quote = await jupiterQuote(solAmount); const swapResp = await fetch("https://api.jup.ag/swap/v1/swap", { method: "POST", headers: jupiterHeaders(), body: JSON.stringify({ quoteResponse: quote, userPublicKey: keypair.publicKey.toBase58(), dynamicComputeUnitLimit: true, prioritizationFeeLamports: "auto", }), }); if (!swapResp.ok) { throw new Error(`Jupiter swap failed: ${swapResp.status} ${await swapResp.text()}`); } const swapData = await swapResp.json(); const txBuf = Buffer.from(swapData.swapTransaction, "base64"); const vtx = VersionedTransaction.deserialize(txBuf); const connection = new Connection(SOLANA_RPC_URL, "confirmed"); const signature = await sendVersionedTx(connection, keypair, vtx); return { signature, inputAmount: solAmount, outputAmount: tokensToDisplay(Number(quote.outAmount)), priceImpact: quote.priceImpactPct, }; } ``` ### Technical Analysis The swap endpoint returns a Base64-encoded serialized transaction. The CLI deserializes that transaction and signs it with the wallet key without inspecting its message or validating its instructions. The code does not verify: - The programs invoked by the transaction. - The actual SOL amount transferred. - The input and output token mints. - The destination token account. - Whether unrelated SOL or token transfers are included. - Whether token authority, delegate, or account-closing instructi ...[truncated 1968 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Decode and inspect the complete versioned transaction message before signing. 2. Maintain an allowlist of expected Jupiter, token, associated-token, compute-budget, and system program IDs. 3. Reject transactions containing unrelated programs or instructions. 4. Verify that the wallet is the expected signer and that no additional unexpected signers are required. 5. Confirm that the source mint is wrapped SOL and the destination mint is the configured OLO mint. 6. Validate source and destination token accounts against locally derived associated token accounts. 7. Calculate wallet SOL and token balance deltas from the instructions and enforce the quoted maximum input and minimum output. 8. Reject delegate approvals, authority changes, account closures, and unrelated transfers. 9. Bind the returned transaction to the original quote and enforce a short quote-expiration window. 10. Present a decoded transaction summary for explicit approval, especially for high-value swaps. 11. Where practical, construct the transaction locally from independently verified instructions rather than blindly signing an opaque remote payload. ]]>
