T09 · Insecure Skill Coding Practices
- Location
scripts/swap.mjs:194- Finding
Unvalidated Remote Transaction Is Signed After User Confirmation
- Content
View full analysis
= 500) fail('BACKEND_UNAVAILABLE', `Jupiter swap build error: ${res.status}`, true); fail('BACKEND_QUOTE_FAILED', `Jupiter swap build failed: ${res.status} ${body}`); } const swapData = await res.json(); swapTxBase64 = swapData.swapTransaction; if (!swapTxBase64) fail('BACKEND_QUOTE_FAILED', 'Jupiter returned no swap transaction'); } catch (e) { if (e.code) throw e; fail('BACKEND_UNAVAILABLE', `Jupiter swap build unreachable: ${e.message}`, true); } ``` ```js const prepared = { prepareId, txBase64: swapTxBase64, fromMint, toMint, amountIn, slippage, owner: owner.toBase58(), destination: destination ? destination.toBase58() : owner.toBase58(), expiresAt, executed: false, expectedOut: quoteResponse.outAmount || null, minOut: quoteResponse.otherAmountThreshold || null, priceImpact: quoteResponse.priceImpactPct || null, }; writeFileSync(prepareFilePath(prepareId), JSON.stringify(prepared)); ``` ```js // Sign const keypair = loadKeypair(); let signedTx; try { const txBuf = Buffer.from(prepared.txBase64, 'base64'); const tx = VersionedTransac ...[truncated 3950 chars]- Remediation
View remediation
