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(payments): validate client_secret in external authentication and eligibility flows (#15031)

Sai Harsha Vardhan068e5566e6d1
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index fb198a0474..6ec763d108 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -10828,6 +10828,14 @@ impl PaymentEligibilityData {
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
+ helpers::authenticate_client_secret(
+ payments_eligibility_request
+ .client_secret
+ .as_ref()
+ .map(|cs| cs.peek()),
+ &payment_intent,
+ )?;
+
let payment_method_data = match &payments_eligibility_request.payment_token {
Some(payment_token) => {
let profile_id = payment_intent
@@ -13797,6 +13805,10 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
+ helpers::authenticate_client_secret(
+ req.client_secret.as_ref().map(|cs| cs.peek()),
+ &payment_intent,
+ )?;
let attempt_id = payment_intent.active_attempt.get_id().clone();
let payment_attempt = db
.find_payment_attempt_by_payment_id_processor_merchant_id_attempt_id(