Trigger Pattern Any env.invoke_contract() or env.try_invoke_contract() detected in contract - Inject Into Breadth agents
Trigger Pattern: Any
env.invoke_contract()orenv.try_invoke_contract()detected in contract Inject Into: Breadth agents Finding prefix:[EPA-N]Rules referenced: R1, R4, R8, R10, R16 Constraint: Interface-level inference only — no production fetch required
invoke_contract|try_invoke_contract|contractimport!|ContractClient|
external_contract|token::Client|token_contract|SorobanInterface
For every external contract the protocol invokes:
| External Contract |
|---|
| Address Source |
|---|
| Hardcoded? |
|---|
| Validated Against Constant? |
|---|
| Upgradeable? |
|---|
| Risk if Substituted |
|---|
Address validation check: For each invoke_contract call, is the target contract address:
Upgradeability assessment: Soroban contracts can be upgraded via update_current_contract_wasm() if the contract has an upgrade entry point. Is the external contract upgradeable?
contractimport! macro risk: Contracts imported via contractimport! bind the caller to the interface of the external contract at compile time. If the external contract upgrades and changes its interface, calls will fail. More critically, if the imported interface definition does not match the deployed contract's actual interface, calls may succeed with incorrect semantics (wrong argument order, wrong return type interpretation).
Soroban provides two call modes with fundamentally different error semantics:
| Call Site | Mode Used | Error Handled? | On Panic: | Risk |
|---|---|---|---|---|
| {location} | invoke_contract / try_invoke_contract | YES/NO | propagates trap / returns Err | {describe} |
invoke_contract (trap mode): If the external call fails (panic, host error), the ENTIRE transaction reverts. This is safe against partial state corruption but means any external contract can DoS the protocol by reverting.
try_invoke_contract (Result mode): Returns Ok(val) or Err(...). The calling contract's state changes are NOT automatically reverted on error — the calling contract must handle the error explicitly and decide whether to revert or continue.
Critical check for try_invoke_contract:
Err branch handled explicitly?Attack pattern (partial state corruption):
try_invoke_contract to external tokenErr)| Call Site | Return Type | Protocol Uses Return Value? | Failure Mode if Unexpected |
|---|
For each return value:
try_invoke_contract returns Err? Does the protocol handle this case explicitly?| Protocol State | Depends on External Contract State | External State Can Change Without Our Knowledge? |
|---|
For each dependency: model what happens when the external contract state changes between our contract's read and use.
Soroban-specific concerns:
| Oracle Address | Type | Confidence Checked? | Staleness Checked? | Address Validated? |
|---|
Checks:
timestamp field against env.ledger().timestamp() with max age)Tag: [TRACE:oracle read → price={X} at timestamp={T} vs current={U} → {accepted/rejected}]
After each external call that modifies storage:
| External Call | Creates/Extends Storage? | Who Pays TTL Extension Fees? | TTL Sufficient? |
|---|
Soroban-specific: External contracts may create or extend storage entries on behalf of the calling contract. Storage entries have TTLs; if not extended, data expires and is wiped. If an external call creates state that the calling contract later depends on, but the TTL is not extended, that state may vanish.
XLM reserve for contract instances: Each deployed contract and each storage entry requires XLM held in reserve. If the protocol relies on an external contract maintaining state, verify that the external contract's reserve is adequate and not drainable by an attacker.
**ID**: [EPA-N]
**Verdict**: CONFIRMED / PARTIAL / REFUTED / CONTESTED
**Step Execution**: (see checklist below)
**Rules Applied**: [R1:___, R4:___, R8:___, R10:___]
**Severity**: Critical/High/Medium/Low/Info
**Location**: src/{file}.rs:LineN
**Title**: {missing call validation / partial state on try_invoke error / stale external state}
**Description**: {specific issue with code reference}
**Impact**: {what attacker can achieve via the external call weakness}
| Section | Required | Completed? | Notes |
|---|---|---|---|
| 1. External Call Target Inventory and Validation | YES | Address source for every invoke_contract | |
| 2. invoke_contract vs try_invoke_contract Error Handling | YES | Every try_invoke_contract error branch checked | |
| 3. Return Value Consumption | IF return value used | ||
| 4. State Dependency Mapping | YES | ||
| 4b. Oracle Data Quality Checks | IF oracle consumed | Price bounds, staleness, TTL expiry | |
| 5. XLM Reserve and Storage TTL | YES | Storage entries created by external calls |
If any step skipped, document valid reason (N/A, no external calls, immutable target with no state dependency).