Repository navigation
Harden contract authorization, address invariants, payment ID derivation, and slippage validation - #187
Merged
Conversation
…rationsAdmin Closes terngunan#93
…tters omit a Closes terngunan#94
…amount custo Closes terngunan#95
… validate ma Closes terngunan#96
|
@sundayjob996 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Harden contract authorization, address invariants, payment ID derivation, and slippage validation
What was solved
#93 — rbac_access: Hierarchical rank ordering permits OperationsAdmin to execute ComplianceAdmin restricted tasks
Fix rbac_access role authorization so ComplianceAdmin and OperationsAdmin are distinct functional roles instead of a linear rank hierarchy. Replace rank-based comparison with explicit role matching (or permission sets) so compliance tasks require ComplianceAdmin or SuperAdmin, and operations tasks require OperationsAdmin or SuperAdmin. Add unit tests verifying cross-role rejections and SuperAdmin access to both task types.
Addressed:
#94 — fee_distributor: set_treasury and set_lp_address setters omit address distinction and contract self-address invariants
Add constructor-equivalent address invariants to fee_distributor's set_treasury and set_lp_address setters so they reject setting treasury/lp_address to each other, to the admin, or to the contract's own address, and add unit tests covering the invalid permutations plus valid updates.
Addressed:
#95 — batch_payments: Payment ID seed hash omits payment amount customer and memo despite documentation claims
Update batch_payments create_batch so the payment ID SHA-256 seed commits to the payment payload (amount, memo XDR, customer XDR) in addition to ledger sequence, counter, and merchant, matching the PaymentRecord documentation. Add a unit test in test.rs verifying that identical counter items with differing amounts/memos produce distinct payment IDs.
Addressed:
#96 — slippage_protection: set_pair_max_slippage does not validate maximum basis points ceiling
Add the missing upper-bound validation to
set_pair_max_slippagein the slippage_protection contract so per-pair overrides cannot exceed 10,000 bps, mirroringset_max_slippage, and add a unit test asserting rejection ofbps = 10_001.Addressed:
settliq_contracts/contracts/slippage_protection/src/lib.rs, addif bps > 10_000 { panic!("bps must be <= 10000"); }insideset_pair_max_slippagebefore storing the value, matching the existing check inset_max_slippage.bps <= 10_000continues to succeed and is stored underDataKey::PairMaxSlippageBps(asset_a, asset_b).settliq_contracts/contracts/slippage_protection/src/test.rsthat assertsset_pair_max_slippagewithbps = 10_001panics (e.g. via#[should_panic]).Changes
settliq_contracts/contracts/rbac_access/src/lib.rs(modify)settliq_contracts/contracts/fee_distributor/src/lib.rs(modify)settliq_contracts/contracts/batch_payments/src/lib.rs(modify)settliq_contracts/contracts/rbac_access/src/test.rs(modify)settliq_contracts/contracts/fee_distributor/src/test.rs(modify)settliq_contracts/contracts/slippage_protection/src/lib.rs(modify)Approach
Issues
Closes #93
Closes #94
Closes #95
Closes #96