Skip to content

Transaction signing safety — validate simulation auth entries before presenting to user #24

Description

@prodbycorne

Problem

The current (stub) unlockAssets and the planned lockAssets / configureBoost flows build a Soroban transaction and immediately pass it to walletApi.signTransaction. They do not inspect the simulateTransaction response's auth array before signing.

A compromised RPC node or a man-in-the-middle could return a simulation response with injected auth entries that authorise additional contract calls beyond what the user intended. The user would see the Freighter dialog and sign without knowing.

Expected Behaviour

Before presenting any transaction to Freighter for signing, the app verifies that the simulation response contains exactly the expected number and type of auth entries. Any unexpected auth entry causes the transaction to be aborted and a clear warning is shown.

Acceptance Criteria

  • A validateSimulationAuth(simResult, expected: { contractId: string; functionName: string }[]) utility is added to src/lib/soroban.ts
  • The utility inspects simResult.result?.auth (a SorobanAuthorizationEntry[]), decodes each credentials field, and asserts the contractFn.contractAddress and contractFn.functionName match the expected list
  • If the auth array is longer than expected, or any entry targets an unexpected contract/function, the utility throws a SecurityError with a user-facing message
  • lockAssets, unlockAssets, and configureBoost all call validateSimulationAuth before assembling the final transaction
  • The error is surfaced to the user via the useErrorHandler toast (not swallowed silently)
  • A unit test provides a mock simResult with an extra unexpected auth entry and asserts the function throws

Relevant Files

  • src/lib/soroban.ts — add validateSimulationAuth; call it inside unlockAssets, lockAssets, configureBoost
  • src/context/ErrorContext.tsxuseErrorHandler for user-facing error display
  • src/lib/error-handler.ts — may need a new SecurityError class

Metadata

Metadata

Assignees

Labels

Official CampaignCampaign: Official CampaignhardRequires deep domain knowledge — Soroban, Stellar SDK, or complex statesecuritySecurity, signing safety, or wallet interaction hardeningsorobanSoroban smart-contract integration (XDR, RPC, transaction building)walletFreighter wallet integration, session, and network switching

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions