Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Where's my dough? A look at web skimming attack...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Where's my dough? A look at web skimming attacks on e-commerce websites.

Avatar for theClumsyCoder

theClumsyCoder

March 20, 2020

Other Decks in Technology

Transcript

  1. About me Senior Product Security Engineer @ Application security pentesting,

    threat modelling, secure code review @ Aspect Security and EY @theClumsyCoder /siddharthcoontoor
  2. Origins of Web skimming Magento Open Source eCommerce Platform Admin

    console exposure Arbitrary file upload through CSRF Hackers targeted the following pages involved in Payment checkout : app/code/core/Mage/XmlConnect/Block/Checkout/Payment/Method/Ccsave.php app/code/core/Mage/Customer/controllers/AccountController.php app/code/core/Mage/Payment/Model/Method/Cc.php app/code/core/Mage/Checkout/Model/Type/Onepage.php Magecart!
  3. So how do the hackers get in??? • Underlying vulns

    in OS • Exposed services FTP, SSH, application’s admin console • Vulnerabilities in web application code (SQLi, file upload, XSS etc) • 3rd party libraries hosted on site’s infrastructure • 3rd party libraries hosted on CDNs • 3rd party plugins or extensions
  4. Fast forward 2020! Ticketmaster - Supply chain attack, compromise of

    third party service Inbenta British Airways - Compromised server, served malicious script : modernizr.js NewEgg - Malicious javascript code directly injected into checkout page Macy’s - Malicious Javascript code added to payment and account profile pages
  5. Magecart Profiling 7 Magecart groups based on : Targets Volume

    of credit cards Skimmer characteristics Infrastructure setup Group 1 & 2 Group 3 Group 4 Group 5 Group 6 Group 7
  6. Web skimmer obfuscation “the action of making something less clear

    and less easy to understand, especially intentionally” - Cambridge dictionary Name obfuscation Code flow obfuscation Dead-code insertions String encryption Minification & compression
  7. What can we do to protect? E-commerce Platform Storefront :

    www.myshop.com Extension/Plugins Order management Checkout Partners Merchants
  8. E-commerce platform mitigations Enforce 2FA across all merchant’s site administrators

    and developers Harden server operating systems Reduce attack surface by minimizing exposure of service like SFTP, SSH Provide secure by default configurations Update developer documentation to reflect security best practices for your reference architectures Perform secure code reviews of partner code/extension as part of the marketplace publishing process
  9. SRI Considerations Trust but verify approach(well known CDNs) Update subresource

    integrity attribute when scripts are updated Integrity attribute can also be applied to CSS Partners that develop extensions for e-commerce platform must include SRI Partners must also maintain and make available extension versions and corresponding hashes
  10. Content-Security-Policy Response header traditionally used to mitigate cross-site scripting attacks

    by whitelisting allowed sources of script, style, and other resources. Content-Security-Policy: default-src 'self'; script-src *.somecdn.com; font-src fonts.googleapi.com; style-src https://*/; connect-src https://p.analytics.com/ www.myshop.com
  11. Good enough for E-commerce? E-commerce platforms manage 100-1000s of storefronts

    Each storefront relies on several third-party domains to load resources Third-party server names change without notice Detection of sub-resource compromise Difficult to gain intel on compromised domains Difficult to alert merchants of sub-resource compromise
  12. Evaluating the current resource dependencies Collect, aggregate & analyse reports

    for known good resources for storefront Based on known good resources, craft CSP policy for your storefront Content-Security-Policy-Report-Only: default-src 'self'; report-uri /report-violations Content-Security-Policy: default-src 'self'; script-src *.somecdn.com; font-src fonts.googleapi.com; style-src https://*/; connect-src https://p.analytics.com/
  13. Policy enforcement and alerting fonts.googleapis.com skimmer.magecart.com p.analytics.com www.somecdn.com www.myshop.com checkout.html

    web skimmer Content-Security-Policy: default-src 'self'; script-src *.somecdn.com; font-src fonts.googleapi.com; style-src https://*/; connect-src https://p.analytics.com/; report-uri /csp-violation /csp-violation { "csp-report": { "document-uri": "https://www.myshop.com/checkout.html", "referrer": "https://skimmer.magecart.com“, "blocked-uri": "https://skimmer.magecart.com/evil.js", "violated-directive": "script-src ‘https://*.somecdn.com”, "original-policy": "<complete csp policy of page>” } }
  14. CSP enforcement and alerting approach Allows e-commerce platform to build

    intelligence of known good/bad domains Allows deployment at scale across all storefronts Zero customizations needed, configuration only All pages on browser can be monitored including payment pages Alert merchants about compromised domains across the platform
  15. iFrame sandboxing <iframe sandbox src="http://example.com"></iframe> Access to parent DOM or

    IndexedDB Access to same origin Access to render forms Access to pointer Access to execute any JS event-handlers javascript: URL <noscript> Access to run plugins
  16. Granular control flags using sandboxes <iframe sandbox src="http://example.com"></iframe> allow-forms allows

    form submission. allow-popups (window.open(), showModalDialog(), target=”_blank”, etc.). allow-pointer-lock allows (mouse movements) pointer lock. allow-same-origin allows the document to maintain its origin; pages loaded from https://example.com/ will retain access to that origin’s data. allow-scripts allows JavaScript execution, and also allows features to trigger automatically (as they’d be trivial to implement via JavaScript). allow-top-navigation allows the document to break out of the frame by navigating the top-level window.