Skip to content

feat: add external call return-value and returndata safety analysis - #110

Merged
Manuelshub merged 2 commits into
StellarChainproof:masterfrom
tunmisedasa:feat/returndata-safety-analysis-81
Aug 30, 2026
Merged

feat: add external call return-value and returndata safety analysis#110
Manuelshub merged 2 commits into
StellarChainproof:masterfrom
tunmisedasa:feat/returndata-safety-analysis-81

Conversation

@tunmisedasa

Copy link
Copy Markdown
Contributor

Summary

  • Implements production-grade external call return-value and returndata safety analysis with 16 rules (CP-RTD-001 through CP-RTD-016)
  • Models call, delegatecall, staticcall, send, transfer, and interface-call success/returndata flows with guard and wrapper recognition
  • Merges equivalent Slither findings while preserving richer ChainProof evidence paths

Architecture

Core logic in packages/core/src/returndata/:

  • Call classifier identifies low-level call kinds requiring success checks
  • Guard detector recognizes SafeERC20, Address.functionCall, try/catch, assembly bounds, and documented optional calls
  • Decode analyzer flags unsafe abi.decode and stale returndata reuse across sequential calls
  • 16 rules cover ignored success flags, overwritten results, unchecked token returns, batch failures, assembly copies, swallowed try/catch, multicall partial failures, and proxy decode assumptions

Precision/Recall

  • Distinguishes intentionally optional calls via @dev optional documentation and naming conventions
  • SafeERC20/Address wrapper patterns suppress token and low-level call findings
  • Vulnerable fixture triggers CP-RTD-003, CP-RTD-004, CP-RTD-005, CP-RTD-007

Test plan

  • npm run build
  • npm run test:ci --workspace=packages/core (337 tests pass)
  • Returndata analyzer unit tests with vulnerable/secure fixtures
  • CLI chainproof returndata command registration
  • Manual scan of examples/contracts/returndata/ via chainproof scan

Security boundaries

Implements a production returndata safety engine with 16 rules (CP-RTD-001
through CP-RTD-016), call classification, decode analysis, guard detection,
Slither merge support, and scanner/CLI integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Nanle-code

Copy link
Copy Markdown
Contributor

@tunmisedasa Fix conflicts

@Manuelshub Manuelshub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @tunmisedasa , nice work

@Manuelshub
Manuelshub merged commit 7e3472b into StellarChainproof:master Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement External Call Return-Value and Returndata Safety Analysis

3 participants