Skip to content

feat(refund-vault): commit-reveal to prevent front-running (issue #128) - #255

Open
tecmalik wants to merge 2 commits into
accensa:mainfrom
tecmalik:security/128-prevent-front-running
Open

feat(refund-vault): commit-reveal to prevent front-running (issue #128)#255
tecmalik wants to merge 2 commits into
accensa:mainfrom
tecmalik:security/128-prevent-front-running

Conversation

@tecmalik

Copy link
Copy Markdown

closes #128

Summary

Contract Change Safety Checklist

Please verify that your changes adhere to contract stability requirements:

  • Event Shapes: Does this PR modify event topic tuples or data shapes? (Breaking change per docs/EVENTS.md)
  • Storage Layout: Does this PR change storage keys or layout? (Assessed for archival & migration risks)
  • Error Variants: Does this PR add or renumber contract error codes? (Client-visible breaking change)
  • Changelog: Has a corresponding entry been added to CHANGELOG.md?
  • Deployments: Has any impact on deployed contracts or DEPLOYMENTS.md been documented?
  • Verification: Has this change been tested locally (cargo test) and/or exercised on Soroban testnet?

Related Issues

Closes #

…ensa#128)

Add a commit-reveal scheme to RefundVault so a mempool observer cannot
front-run refunds/withdrawals. A merchant first commits an opaque
sha256(plaintext || salt) hash (merchant-auth only), then reveals the
plaintext + salt after COMMIT_REVEAL_DELAY (10) ledgers; the contract
re-hashes, verifies against the stored commitment, consumes it and runs
the identical refund/withdraw (shared do_refund/do_withdraw).

New public API: commit, reveal_refund, reveal_withdraw, get_commitment,
get_commit_reveal_delay. New Error codes 302-305 (CommitmentNotFound,
CommitmentMismatch, CommitmentNotDue, CommitmentAlreadyUsed).

Security audit tests in commit_reveal_tests.rs pin the min-delay boundary,
mismatch rejection, duplicate-commit rejection, merchant-only commit, and
commitment opacity. Docs (README, SECURITY_MODEL, CHANGELOG) updated; wasm
budget bumped to 49152. Also fixes pre-existing lib-test blockers (Events
import, self-transfer event-count assertions, fuzz nonminimal_bool).
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@tecmalik 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! 🚀

Learn more about application limits

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.

Threat Model Mitigation: Prevent RefundVault Front-Running via Commit-Reveal

2 participants