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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(worldpayxml): validate DDC postMessage origin (#14992)
Vani Gupta7f69124ea98d
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex 33868975ca..bb5572963f 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -1726,52 +1726,55 @@ pub fn build_redirection_form(form.submit();}}+ var allowedHost = new URL("{base_url}").origin;window.addEventListener("message", function(event) {{- try {{- var data = JSON.parse(event.data);- var responseForm = document.createElement('form');- responseForm.action=window.location.pathname.replace(- new RegExp("payments/redirect/([^/]+)/([^/]+)/[^/]+"),- "payments/$1/$2/redirect/complete/worldpayxml"- );- responseForm.method='POST';-- var item1=document.createElement('input');- item1.type='hidden';- item1.name='SessionId';- item1.value=data.Payload.SessionId;- responseForm.appendChild(item1);-- var item2=document.createElement('input');- item2.type='hidden';- item2.name='ActionCode';- item2.value=data.Payload.ActionCode;- responseForm.appendChild(item2);-- document.body.appendChild(responseForm);- responseForm.submit();- }} catch (e) {{- var responseForm = document.createElement('form');- responseForm.action=window.location.pathname.replace(- new RegExp("payments/redirect/([^/]+)/([^/]+)/[^/]+"),- "payments/$1/$2/redirect/complete/worldpayxml"- );- responseForm.method='POST';-- var item1=document.createElement('input');- item1.type='hidden';- item1.name='SessionId';- item1.value=null;- responseForm.appendChild(item1);-- var item2=document.createElement('input');- item2.type='hidden';- item2.name='ActionCode';- item2.value="FAILURE";- responseForm.appendChild(item2);-- document.body.appendChild(responseForm);- responseForm.submit();+ if (event.origin === allowedHost) {{+ try {{+ var data = JSON.parse(event.data);+ var responseForm = document.createElement('form');+ responseForm.action=window.location.pathname.replace(+ new RegExp("payments/redirect/([^/]+)/([^/]+)/[^/]+"),+ "payments/$1/$2/redirect/complete/worldpayxml"+ );+ responseForm.method='POST';++ var item1=document.createElement('input');+ item1.type='hidden';+ item1.name='SessionId';+ item1.value=data.Payload.SessionId;+ responseForm.appendChild(item1);++ var item2=document.createElement('input');+ item2.type='hidden';+ item2.name='ActionCode';+ item2.value=data.Payload.ActionCode;+ responseForm.appendChild(item2);++ document.body.appendChild(responseForm);+ responseForm.submit();+ }} catch (e) {{+ var responseForm = document.createElement('form');+ responseForm.action=window.location.pathname.replace(+ new RegExp("payments/redirect/([^/]+)/([^/]+)/[^/]+"),+ "payments/$1/$2/redirect/complete/worldpayxml"+ );+ responseForm.method='POST';++ var item1=document.createElement('input');+ item1.type='hidden';+ item1.name='SessionId';+ item1.value=null;+ responseForm.appendChild(item1);++ var item2=document.createElement('input');+ item2.type='hidden';+ item2.name='ActionCode';+ item2.value="FAILURE";+ responseForm.appendChild(item2);++ document.body.appendChild(responseForm);+ responseForm.submit();+ }}}}}}, false);</script>"#)))