T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/src/copy_trade.js:249
- Finding
- Remote Swap Transaction Is Signed Without Instruction Validation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/src/copy_trade.js:249-264` **Vulnerability Type**: Signing of an untrusted remotely supplied blockchain transaction **Risk Level**: High ### Vulnerable Code ```js const { data: swapData } = await axios.post('https://quote-api.jup.ag/v6/swap', { quoteResponse: quote, userPublicKey: wallet.publicKey.toString(), wrapAndUnwrapSol: true, prioritizationFeeLamports: 10000, // ~0.00001 SOL priority fee }); // Deserialize + sign + send const swapTx = VersionedTransaction.deserialize( Buffer.from(swapData.swapTransaction, 'base64') ); swapTx.sign([wallet]); const sig = await connection.sendRawTransaction(swapTx.serialize(), { skipPreflight: false, maxRetries: 3, }); ``` ### Technical Analysis The live-trading path obtains an opaque serialized transaction from the remote Jupiter swap endpoint, deserializes it, and immediately signs it with the configured wallet. The application does not locally inspect or validate: - Program IDs and transaction instructions - Source and destination accounts - Input and output token mints - Input amount and minimum output amount - SOL or token transfer recipients - Fee payer and requested signers - Address lookup tables - Writable accounts - Unexpected token approvals, transfers, or account-closing operations The endpoint is consistent with the declared Jupiter integration, and there is no evidence that the current project intentionally submits a malicious transaction. However, the implementation gives the remote response authority to define what the wallet authorizes. TLS validation and Solana preflight do not confirm that a transaction matches the user's intended swap; they only protect transport and simulate whether the supplied transaction can execute. A compromised remote service, DNS/TLS trust path, proxy, or request dependency could return a valid but malicious transaction that transfers assets to an attacker-controlled account. ### Attack Path ...[truncated 973 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Decode and inspect every transaction before signing it. - Allowlist the expected Jupiter, System, Compute Budget, Associated Token Account, and SPL Token program IDs as narrowly as possible. - Verify the fee payer, required signers, address lookup tables, writable accounts, source accounts, destination accounts, token mints, maximum input amount, minimum output amount, and all transfer recipients. - Compare the decoded transaction against the accepted quote and reject any material discrepancy. - Reject unexpected instructions, additional transfers, approvals, account closures, or signer requests. - Enforce a local transaction policy independently of the remote API response. - Consider requiring explicit user confirmation before each live signature. - Continue using a separately funded burner wallet with only the amount required for intended trades. - Add automated tests using malicious serialized transactions to confirm that local validation fails closed. ]]>
