Repository navigation
feat(backend): harden and instrument SEP-0001 generator, add relay integration/stress suite, retry idempotency Redis calls with backoff - #1603
Conversation
|
@noevidence1017 is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Y33t-dev 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! 🚀 |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic High Entropy Secret | bdb6388 | backend/src/lib/sep0001-generator.sanitization.test.js | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
…tegration/stress suite, retry idempotency Redis calls with backoff
81c412f to
bdb6388
Compare
Summary
#1457 - Payload sanitization and strict validation for the SEP-0001 Stellar Info Generator
\r,\t,\b,\f, plus\uXXXXfor the rest). Before, only\nwas escaped, so a raw\ror other control character in a merchant field could break the document. Tests try quote, CRLF, table-header, NUL and backslash breakouts and assert that the key set never changes.business_name: bidi override characters (used for visual spoofing) are stripped, the value is trimmed, and it is capped at 256 code points. Non-string or empty values fall back to the default name.ACCOUNTSandSIGNING_KEYmust be valid Stellar public keys, including the StrKey checksum.SIGNING_KEYis never published. Before, the generator would put anS...seed into a public file. It is now refused and logged without its value, and an alert fires.TRANSFER_SERVER/ network passphrase raises a typedSep0001ConfigError, and the route turns that into a generic 500 without exposing configuration.validateStellarToml: required keys must start a line, raw control characters are rejected, and the document is capped at the 100 KB SEP-0001 limit.merchant_idmust be a single UUID, otherwise 400 without a database query. Repeated params and object injection are covered.console.errorreplaced with the structured logger.Access-Control-Allow-Origin: *(required by SEP-0001 for browser wallets) andX-Content-Type-Options: nosniff.generateStellarTomlReport()returns{ toml, rejections }.generateStellarToml()keeps its signature and return type.#1458 - Prometheus alert metrics and health telemetry for the SEP-0001 generator
src/lib/sep0001-telemetry.jswith its own registry, merged intoGET /metrics:sep0001_requests_total{outcome}sep0001_generation_duration_seconds{outcome}sep0001_document_size_bytessep0001_rejected_fields_total{field,reason}sep0001_health_statesep0001_error_ratiosep0001_last_success_timestamp_secondsother/generation_error.SIGNING_KEYwas refused. 400/404 do not count. Thresholds are configurable throughSEP0001_*env vars.GET /health/sep0001endpoint (503 only when unhealthy)./healthalso reportsservices.sep0001_generator, informational only.backend/docs/alerts/sep0001-generator.rules.yml(unhealthy, degraded, secret signing key refused, invalid configuration, merchant data rejected).#1456 - Integration and stress test suite for the WebSocket Relay Service
websocket-relay.integration.test.jswires the real security, query, recovery and metrics modules into a relay worker. It covers:alg: none, HS512, expired and wrong-secret tokens__proto__fieldswebsocket-relay.stress.test.js:tests/helpers/fake-relay-db.jsinterprets the exact SQL fromwebsocket-relay-queries.js, applying each statement atomically to mirrorFOR UPDATE SKIP LOCKED.auditRelayEvent()spread caller metadata afteraudit/ts/event, so metadata could forge those fields. Metadata is now spread first.backend/docs/WEBSOCKET_RELAY_TESTING.md.#1464 - Automated retry with exponential backoff in the Idempotency Key Manager
src/lib/idempotency-retry.js:withIdempotencyRetry()with capped exponential backoff and +/-20% jitter, a total latency budget, and env-configurable bounds (IDEMPOTENCY_REDIS_MAX_RETRIES2,_RETRY_BASE_MS25,_RETRY_MAX_MS250,_RETRY_BUDGET_MS500, all clamped).get), the background cache write (set, which never delays the response) andlookupIdempotentResponse(lookup).idempotency_redis_operations_total{operation,outcome},idempotency_redis_retries_total{operation},idempotency_redis_retry_delay_seconds{operation}, merged intoGET /metrics.backend/docs/IDEMPOTENCY_KEY_MANAGER.md.Notes
sep0001-generator.test.jsandsep0001-generator.integration.test.jsused the example accountsGBUQWP3B...andGCEZWKCA..., which fail the StrKey checksum. With strict validation they would be omitted fromACCOUNTS, so they were replaced with valid deterministic keys.SCZANGBA...) is published asSIGNING_KEYwas replaced with two tests: a public key is published, and a secret seed is not.merchant_idreturns 400 instead of reaching the database.TRANSFER_SERVER_URL/API_BASE_URLreturns 500 (http still works for localhost).IDEMPOTENCY_REDIS_RETRY_BUDGET_MS(default 500 ms) of latency before failing open.[ORG]keys (name,contact,support,homepage,logo) do not match the SEP-0001 spec (ORG_NAME,ORG_OFFICIAL_EMAIL,ORG_SUPPORT_EMAIL,ORG_URL,ORG_LOGO). They were kept for backwards compatibility.closes #1458
closes #1457
closes #1456
closes #1464