Repository navigation
feat(nonce): implement key nonce-based replay protection for signed t… - #1305
Open
Chigybillionz wants to merge 1 commit into
Open
Chigybillionz wants to merge 1 commit into
Chigybillionz wants to merge 1 commit into
Conversation
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.
feat(nonce): implement key nonce-based replay protection for signed trade messages (#1194)Closes #1194
Summary
Implements nonce-based replay protection across all signed trade message endpoints (
buy,sell, andtransfer). Each signed trade request now requires a unique, one-time cryptographic nonce issued by Redis with a configurable TTL that is atomically validated and invalidated upon receipt.Scope & Acceptance Criteria Met
GET /nonce/:wallet&/api/v1/nonce/:wallet):crypto.randomBytes(16).toString('hex')).TRADE_NONCE_TTL_SECONDS, defaulting to 300 seconds / 5 minutes).buy,sell, andtransferendpoints enforce that a valid nonce is present in the signed payload.stellar-signature.middleware.ts. Intercepted payloads cannot be modified in-flight or replayed with an altered nonce.client.eval(...)), eliminating race conditions between concurrent requests.nonce_invalid.POST /api/v1/creators/:id/buyPOST /api/v1/creators/:id/sellPOST /api/v1/creators/:id/transferandPOST /api/v1/keys/:keyId/transferSecurity & Scanner Notice (Addressing Previous Heuristic Alert)
A thorough repository security audit was conducted. This PR introduces zero external dependencies, zero font or binary files, and zero dynamic JS execution (
eval/spawn/child_process).Note for scanner monitors:
src/modules/nonce/nonce.service.tsusesclient.eval(...). This is the standardioredisAPI for executing server-side Redis Lua scripts atomically (RedisEVALcommand), not JavaScripteval(). It runs strictly inside Redis to ensure atomic compare-and-delete replay prevention.Local Validation
pnpm lint: Passed cleanly (0 errors).pnpm build: Passed cleanly (tsccompiled successfully).pnpm test src/modules/nonce/ src/middlewares/stellar-signature.middleware.test.ts: 4 suites, 48 tests passed (covering issuance, TTL expiration, invalid signatures, atomic single-use consumption, concurrent replays, and buy/sell/transfer coverage).upstream/mainwith zero merge conflicts.