PCI dss v4 - clause 6.43

Created on 25 July 2024, 2 months ago

Problem/Motivation

The upcoming changes within PCI v4 include clauses that mention how scripts that run on the checkout pages need to be managed.

When asking Stripe about this, I got a PDF document from them that says we have a shared responsibility to implement:

6.4.3 All payment page scripts that are loaded and executed in the consumer’s browser
are managed as follows:
• A method is implemented to confirm that each script is authorized.
• A method is implemented to assure the integrity of each script.
• An inventory of all scripts is maintained with written justification as to why each
is necessary.
//Best practice until 04/01/2025

How is the community planning to handle this? Shopify have sandboxed within iFrames all of their tracking tags - to push them out of scope presumably.

We have a handful of GTM driven scripts for GA4 tracking etc - which could be used for the inventory / justification part - unsure how to technically solve the other two...

📌 Task
Status

Active

Version

1.1

Component

Miscellaneous

Created by

🇬🇧United Kingdom newaytech

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @newaytech
  • 🇺🇸United States simonjoe

    Hello,

    I am assuming you are inquiring about need for SRI. Commerce_stripe doesn't employ the integrity parameter when it includes the JS library. This will get you flagged for PCI 4.0 compliance, as you are probably running into.

    I handled this today for my employer with a patch to commerce_stripe.module

    First, modify the build function slightly.

    function commerce_stripe_library_info_build() {
      $libraries = [];
    
      $stripe_src = 'https://js.stripe.com/v3/';
      $stripe_integrity = fetch_stripe_integrity($stripe_src);
    
      // @todo get this value from global or payment gateway settings.
      $use_fraud_detection = TRUE;
      if (!$use_fraud_detection) {
        $stripe_src .= '?advancedFraudSignals=false';
      }
    
      $libraries['stripe'] = [
        'version' => '3',
        'js' => [
          $stripe_src => [
            'type' => 'external',
            'minified' => TRUE,
            'attributes' => [
                'integrity' => $stripe_integrity,
                'crossorigin' => 'anonymous',
            ],
          ],
        ],
      ];
    
      return $libraries;
    }

    Then, add a new function to calculate the hash value at runtime.

    function fetch_stripe_integrity($url) {
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $response = curl_exec($ch);
      if ($response === false) {
        throw new Exception('Curl error: ' . curl_error($ch));
      }
      curl_close($ch);
    
      $hash = hash('sha384', $response, true);
      $base64_hash = base64_encode($hash);
    
      // Return the hash in the required format
      return 'sha384-' . $base64_hash;
    }

    You will need to track these changes and re-apply them after any update to commerce_stripe in the future.

    After these modifications, I pass PCI 4.0 as scanned by Tenable.

Production build 0.71.5 2024