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(connector): [cybersource] validate redirect messages against exact origins (#15149)

Vani Gupta5c0803d48288
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index af47009cac..1964605fb4 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -1165,9 +1165,18 @@ pub fn build_redirection_form(
(PreEscaped(format!("<script>
{logging_template}
window.addEventListener(\"message\", function(event) {{
- if (event.origin.endsWith(\"cardinaltrusted.com\") || event.origin.endsWith(\"cardinalcommerce.com\")) {{
- window.location.href = window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/cybersource?referenceId={reference_id}\");
+ const allowedOrigins = [
+ \"https://centinelapistag.cardinalcommerce.com\",
+ \"https://centinelapi.cardinalcommerce.com\",
+ \"https://cas.client.cardinaltrusted.com\",
+ \"https://client.cardinaltrusted.com\"
+ ];
+
+ if (!allowedOrigins.includes(event.origin)) {{
+ return;
}}
+
+ window.location.href = window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/cybersource?referenceId={reference_id}\");
}}, false);
</script>
")))