Skip to content

api-gateway merchant suspension check is checked too late - #645

Merged
therealjhay merged 4 commits into
Betta-Pay:mainfrom
0xBernny:main
Sep 4, 2026
Merged

api-gateway merchant suspension check is checked too late#645
therealjhay merged 4 commits into
Betta-Pay:mainfrom
0xBernny:main

Conversation

@0xBernny

@0xBernny 0xBernny commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request addresses a structural lifecycle vulnerability where merchant suspension validation logic executed too late in the request processing pipeline (occurring after body data parsing and rate-limit evaluation). This allowed suspended identities to consume gateway computation resources and leaked underlying account existence flags.

Key Changes

  1. Early Lifecycle Hook: Engineered an upfront preHandler execution hook (checkMerchantSuspension) processing requests before body schemas enter heavy stream parsing.
  2. Unified Response Model: Standardized a consistent 403 Forbidden (MERCHANT_SUSPENDED) error payload surface across all integrated routing domains.
  3. Validation Isolation: Adjusted merchant-suspension.test.ts to assertively guarantee execution terminates cleanly at the threshold layer before deep functional processing begins.

Lifecycle Interception Verification

When an inbound request targeting a restricted endpoint is intercepted, the route lifecycle timeline verifies premature termination:

# Executing request with an explicit suspended signature header
curl -i -H "x-merchant-id: merch_suspended_99" https://api-gateway.local

HTTP/1.1 403 Forbidden
Content-Type: application/json

{"error":"Forbidden","message":"Merchant account is suspended.","code":"MERCHANT_SUSPENDED"}
# Request terminated cleanly in 2ms without hitting rate-limiters or body stream buffers

Related Issues

Checklist

  • I have read the CONTRIBUTING.md guidelines.
  • I have updated the documentation accordingly.
  • I have added/updated tests for my changes.
  • All CI validations pass.

Implement middleware to check for suspended merchants before request processing.
Added middleware to check merchant suspension before handling routes.
Add unit tests for merchant suspension checks in API.
@drips-wave

drips-wave Bot commented Sep 3, 2026

Copy link
Copy Markdown

@0xBernny 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

@therealjhay
therealjhay merged commit 2868284 into Betta-Pay:main Sep 4, 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.

api-gateway merchant suspension check is checked too late

2 participants