chore(erc20-bridge): protect wallet balance read#1152
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughIntroduces runtime role checks for ERC20 bridge SQL actions. Normalizes caller to lowercase and verifies membership in system:erc20_bridge_writer before allowing wallet balance reads and admin actions (lock, unlock, issue) for Sepolia and Mainnet. On failure, raises specific error messages; on success, delegates to existing bridge procedures. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant A as ERC20 Bridge Action
participant AC as Permission Check
participant SB as Sepolia Bridge
participant MB as Mainnet Bridge
C->>A: invoke action (wallet_balance / lock / unlock / issue)
A->>AC: lower(caller) and are_members_of('system','erc20_bridge_writer', [caller])
alt Not a member
AC-->>A: deny
A-->>C: raise error (action-specific message)
else Is member
AC-->>A: allow
alt Network = SEPOLIA
A->>SB: call balance / lock_admin / unlock / issue
SB-->>A: result
else Network = MAINNET
A->>MB: call balance / lock_admin / unlock / issue
MB-->>A: result
end
A-->>C: return result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Time Submission Status
|
Related Problem
resolves: https://github.com/trufnetwork/truf-network/issues/1186
How Has This Been Tested?
Summary by CodeRabbit