Repository navigation
feat(security): complete logger, Horizon env, Prisma timeout and helmet hardening (#379, #380, #381, #382) - #853
Merged
Conversation
…et hardening (mergepay#379, mergepay#380, mergepay#381, mergepay#382) - mergepay#379: route every service and worker logger through the shared createLogger factory so the request/response serializers and credential redaction apply to all log streams; fix createLogger throwing when level is omitted (Pino 9 rejects an explicit undefined level); add a source scan that fails any bare pino() construction outside src/lib/logger.ts. - mergepay#380: pin the Prisma connection pool/timeout defaults and the non-positive-value rejection rules with config tests; the datasource URL parameters and query-timeout middleware in src/db.ts were already wired. - mergepay#381: reject non-http(s) HORIZON_URL and HORIZON_URLS entries at startup and accept TESTNET/PUBLIC case-insensitively, normalizing to lowercase. - mergepay#382: extend the helmet integration suite to API and root responses and assert x-powered-by is removed.
|
@42natus 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! 🚀 |
Cjay-Cyber-2
approved these changes
Oct 19, 2026
Cjay-Cyber-2
left a comment
Collaborator
There was a problem hiding this comment.
Looks good — approving.
Cjay-Cyber-2
approved these changes
Oct 19, 2026
Cjay-Cyber-2
left a comment
Collaborator
There was a problem hiding this comment.
Looks good — approving.
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.
What does this PR do?
Completes and locks down the four security-hardening chores in the backend:
req/res/errserializers and credential redaction apply to all log streams — not just Fastify's. A source scan keeps it that way.HORIZON_URL/HORIZON_URLSmust be valid http(s) URLs at startup, andSTELLAR_NETWORKacceptsTESTNET/PUBLICcase-insensitively.x-powered-byremoval.#379 — Pino request logging serializer configuration
pino({ name })loggers (src/services/stellar.ts,horizonService.ts,exchange.ts,treasuryService.ts,settlement-reconciliation.ts,sep24-anchor-token.ts,src/worker/index.ts,reconciliation.ts,tasks/balance-sync.ts,tasks/tx-status-sync.ts) tocreateLogger()fromsrc/lib/logger.ts, which attachesLOGGER_SERIALIZERS(req,res,err, tx-hash) andREDACT_PATHS.createLogger: it passedlevel: undefined, which Pino 9 rejects (default level:undefined must be included in custom levels). The key is now omitted when no level is given, so Pino'sinfodefault applies.tests/logger-serializers.test.ts) that fails if any module outsidesrc/lib/logger.tsconstructs a barepino()logger. The existing wiring test already proves requests carryingAuthorization/Cookie(proxy-authorization,x-api-key,set-cookietoo) log[REDACTED]whilereq.id,method,url, and telemetry headers survive.Checklist:
authorizationandcookieheaders (src/lib/logger.ts,src/lib/serializers.ts)#380 — Prisma connection timeout configuration
src/db.tsalready appendsconnection_limit,connect_timeout, andpool_timeouttoDATABASE_URLand wraps every query inqueryTimeoutMiddleware(env.DATABASE_QUERY_TIMEOUT_MS). This PR adds the missing configuration-level proof intests/config.test.ts:DATABASE_QUERY_TIMEOUT_MS=10000,DATABASE_CONNECT_TIMEOUT_SECONDS=10,DATABASE_POOL_TIMEOUT_SECONDS=10,DATABASE_CONNECTION_LIMIT=50, negative, and non-numeric values rejected at startuptests/db-health.test.ts,tests/db-timeouts.test.ts)npm run prisma:generate/npm run prisma:validatesucceed#381 — Stellar network configuration validation
horizonUrlSchema: a well-formed URL andhttp:/https:only.ftp://,file://, andwss://Horizon endpoints are now rejected at startup instead of failing at the first request.HORIZON_URLS(failover list) holds every entry to the same rule, with an error naming the offending entry.STELLAR_NETWORKacceptstestnet/publicandTESTNET/PUBLIC, normalizing to lowercase before the existing Horizon/network consistency check runs.TypeError: Invalid URLinstead of a field-level Zod issue).Checklist:
HORIZON_URLis a valid HTTP/HTTPS URL andSTELLAR_NETWORKis testnet/publictests/config.test.ts)#382 — Helmet security headers
The helmet registration in
src/app.tswas already explicitly tuned; this PR extendstests/security.test.tsso the guarantees are tested where the issue asks for them:/api/v1/groups→ 401) and on the root 404x-content-type-options,x-frame-options, HSTS (max-age=31536000; includeSubDomains),referrer-policyverifiedx-powered-byis removed/docs) remains reachable with headers intactChecklist
npm run lintpasses (0 errors)npm run buildpassesnpm testpasses offline — 205 files, 4169 tests passed | 22 skippedmergepay-web(n/a — no contract changes)How was this verified?
Focused suites:
tests/config.test.ts,tests/logger-serializers.test.ts,tests/security.test.ts,tests/db-timeouts.test.ts,tests/db-health.test.ts.Related issues
Closes #379
Closes #380
Closes #381
Closes #382