Skip to content

Add wallet nonce tracking and replay protection for action execution - #1201

Closed
flare-999 wants to merge 2 commits into
accesslayerorg:mainfrom
flare-999:feat/forwarder-consume-nonce
Closed

flare-999 wants to merge 2 commits into
accesslayerorg:mainfrom
flare-999:feat/forwarder-consume-nonce

Conversation

@flare-999

Copy link
Copy Markdown
Contributor

Summary
This change adds wallet-scoped nonce tracking to ensure actions can only be executed once per nonce value and that the current nonce state is auditable.

It introduces a nonce getter and a consume path that validates and increments the nonce atomically, preventing replay attacks and preserving proper audit data in action execution events.

Scope

  • get_nonce(wallet) — returns current nonce for wallet
  • consume_nonce(wallet, nonce) — validates and increments nonce, called by action handlers
  • Nonce invalidated immediately on consumption
  • Replay attempt returns NonceAlreadyUsed error
  • Nonce emitted in ActionExecuted events for auditability

Changes

  • Add wallet-specific nonce retrieval via get_nonce(wallet)
  • Add consume_nonce(wallet, nonce) to validate the provided nonce and increment the stored value
  • Immediately invalidate a nonce after successful consumption
  • Return NonceAlreadyUsed when a replayed nonce is attempted
  • Include the nonce in ActionExecuted event payloads for auditability
  • Ensure concurrent nonce consumption is safe and race-free

Acceptance Criteria

  • get_nonce returns correct current nonce per wallet
  • consume_nonce increments correctly after use
  • Replay of consumed nonce returns NonceAlreadyUsed error
  • Nonce included correctly in ActionExecuted events
  • Concurrent nonce consumption handled without race condition

Testing

Chucks1093 and others added 2 commits October 16, 2026 00:19
…ed buys

The trusted forwarder checked the nonce and then incremented it in two
separate statements, so nonce consumption was not a single reusable gate
and the consumed value never reached event consumers. Extract the
check-and-increment into `consume_nonce`, which rejects replayed and
future nonces with NonceAlreadyUsed before any work happens, and carry
the consumed nonce in ForwardedBuyEvent so indexers can audit each action
against `get_nonce`.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Chucks1093

Copy link
Copy Markdown
Member

🚨 Automated Security Alert

This PR has been automatically closed by the PR monitor because it contains code patterns associated with the PolinRider malware campaign.

Detected indicators may include:

  • Obfuscated payloads hidden after long whitespace in config files
  • eval() or spawn() calls in config files
  • VS Code auto-task on folder open (runOn: folderOpen)
  • Suspicious font files or dist/setup.js loader
  • Known PolinRider marker strings

Please do not reopen this PR or run the code locally. If you believe this is a false positive, contact a maintainer directly.

@Chucks1093 Chucks1093 closed this Oct 23, 2026
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.

Add session nonce contract for replay attack prevention on signed actions

3 participants