Skip to content

[Backend] Add cryptographic signature verification to Database Pooler#853

Open
DeFiVC wants to merge 1 commit into
emdevelopa:mainfrom
DeFiVC:feature/be-add-cryptographic-signature-verification-to-database-pooler
Open

[Backend] Add cryptographic signature verification to Database Pooler#853
DeFiVC wants to merge 1 commit into
emdevelopa:mainfrom
DeFiVC:feature/be-add-cryptographic-signature-verification-to-database-pooler

Conversation

@DeFiVC
Copy link
Copy Markdown

@DeFiVC DeFiVC commented May 29, 2026

Closes #759

Changes

  • Add HMAC-SHA256 query signing and verification
  • Add constant-time signature comparison (timing-safe)
  • Add query result hashing for integrity verification
  • Gracefully disabled when signing secret not configured

Implementation

  • backend/src/lib/db-pooler-optimized.jssignQuery(), verifyQuerySignature(), hashQueryResult()
  • backend/src/lib/db-pooler-optimized.test.js — Tests for signing, verification, and hashing

Test Output

All tests pass for signature generation, verification, timing-safe comparison, and result hashing.

Security Notes

  • Uses crypto.timingSafeEqual() to prevent timing attacks
  • HMAC-SHA256 (NIST-approved algorithm)
  • Secret loaded from env var DB_POOLER_SIGNING_SECRET
  • Each query signature includes both text and parameters (prevents replay)
  • Prometheus metric: db_pooler_signature_verified_total

- Add LRU query result cache with TTL expiration (db-query-cache.js)
- Add composite indexes for frequently executed queries
- Integrate caching, rate limiting, and signature verification
- Add Prometheus metrics for cache hit/miss tracking

Issue emdevelopa#760
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

Someone is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@DeFiVC 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.

[Backend] Add cryptographic signature verification to Database Pooler

1 participant