Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(auth): validate organization ID in JWT against merchant account (#15095)

Gaurav Rawat51ddcd3f465f
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 065a4cd340..505d37888a 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -4909,6 +4909,11 @@ where
.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)
.attach_printable("Failed to fetch merchant account for the merchant id")?;
+ fp_utils::when(merchant.get_org_id() != &payload.org_id, || {
+ Err(report!(errors::ApiErrorResponse::InvalidJwtToken))
+ .attach_printable("JWT merchant does not belong to JWT organization")
+ })?;
+
fp_utils::when(payload.profile_id != self.profile_id, || {
Err(report!(errors::ApiErrorResponse::InvalidJwtToken))
.attach_printable("Profile id in JWT does not match profile id in route")