Skip to content

C3 (SDK): trust-boundary hardening (signed config + allowlists)#10

Open
marceloceccon wants to merge 2 commits intomainfrom
develop
Open

C3 (SDK): trust-boundary hardening (signed config + allowlists)#10
marceloceccon wants to merge 2 commits intomainfrom
develop

Conversation

@marceloceccon
Copy link
Copy Markdown
Member

Summary

Closes the most-dangerous workspace-level failure: poisoned DNS / CDN-edge MITM substitutes the contract address with a clone; users sign against attacker contract. The SDK now refuses to call payIn* without cryptographic provenance.

  • Ed25519 verifyPaymentConfig rejects tampered data, replay >5min, bad signatures.
  • WEB3SETTLE_PAYMENT_CONFIG_PUBKEY_PRIMARY/SECONDARY constants for rotation overlap.
  • KNOWN_CONTRACT_ADDRESSES per-chain allowlist; signed config can elevate per-storefront.
  • hashWalletAddress(address, storefrontId, dayUtc) — no longer reversible cross-storefront (closes GDPR finding).
  • KNOWN_PERMIT_TOKENS quadruple registry — refuse permit:'auto' for unknown tokens; falls back to approve().
  • SUPPORTED_ABI_VERSIONS handshake (fail-closed on mismatch).
  • Exact-pinned runtime deps (i18next, react-i18next, zod) — supply-chain hardening.
  • TRON estimateGas dynamically fetches sun-per-energy from TronGrid (5min cache, hardcoded fallback).
  • sdk-supplychain.yml workflow + Dependabot (no auto-merge for runtime deps).

Test plan

  • npm test — 14 files / 171 tests pass (new: 7 verifier, 5 permit-allowlist, 3 telemetry-salt, 3 TRON dynamic-fee)
  • npm run lint + typecheck clean
  • Manual: tamper with a Mitmproxy-staged payment-config response and verify SDK rejects

⚠️ Pre-publish required

WEB3SETTLE_PAYMENT_CONFIG_PUBKEY_PRIMARY ships as all-zero placeholder. Replace with the real public key whose private half lives in Vault before publishing 0.6.0.

- Ed25519 PaymentConfig verifier (@noble/curves) - rejects tampered config, replay >5min, bad signatures
- WEB3SETTLE_PAYMENT_CONFIG_PUBKEY_PRIMARY/SECONDARY constants for rotation overlap (placeholder zero pubkey - replace before publish)
- KNOWN_CONTRACT_ADDRESSES per-chain allowlist; signed config can elevate per-storefront
- Salted walletDigest: hashWalletAddress(address, storefrontId, dayUtc) - no longer reversible cross-storefront
- KNOWN_PERMIT_TOKENS: refuse permit:'auto' for unknown (name,version,chainId,verifyingContract); falls back to approve()
- SUPPORTED_ABI_VERSIONS handshake (fail-closed on mismatch)
- Exact-pinned runtime deps (i18next, react-i18next, zod) - removes ^ ranges
- TRON estimateGas dynamically fetches sun-per-energy from TronGrid (5min cache, hardcoded fallback)
- sdk-supplychain workflow + dependabot config (no auto-merge for runtime deps)
- 14 files / 171 tests pass (new: 7 verifier, 5 permit-allowlist, 3 telemetry-salt, 3 TRON dynamic-fee)
…into develop

# Conflicts:
#	src/core/telemetry.ts
#	src/evm/permit.ts
#	src/index.ts
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.

1 participant