In short
Podcast Summary: The Changelog - Securing Ecommerce: "It's Complicated" (Interview with Ilya Grigorik)
Episode Overview In this episode of The Changelog, host Jared Palmer speaks with Ilya Grigorik, a distinguished engineer and technical advisor to the CEO at Shopify. The discussion centers around the complexities of securing e-commerce checkouts, particularly against sophisticated attacks like digital skimming. Ilya shares insights into the technical intricacies of these security measures and the implications for the broader e-commerce landscape.
Key Takeaways
- Introduction to Ilya Grigorik
- Ilya has been at Shopify for about four years, previously working at companies like Google and GitHub.
- His recent focus has been on enhancing the security of e-commerce checkouts, which he likens to an air traffic control system where various operations must synchronize seamlessly.
- Understanding PCI Compliance
- PCI (Payment Card Industry) compliance involves a set of security requirements for anyone processing sensitive payment information.
- Ilya describes the evolution from PCI version 3 to PCI version 4, highlighting that while v3 focused on protecting the payment input surface, PCI v4 aims to protect the entire parent page to combat skimming attacks.
- Digital Skimming and Magecart Attacks
- These attacks involve injecting malicious scripts onto e-commerce sites to capture payment information.
- Ilya discusses how the industry has traditionally isolated payment forms using iFrames to protect sensitive data.
- Developments in PCI v4 Compliance
- PCI v4 introduces three key requirements for page security:
- Maintain an inventory of all scripts running on the page.
- Ensure only authorized scripts run on the page.
- Guarantee the integrity of these scripts through measures like sub-resource integrity (SRI).
- The practical implementation of these guidelines poses challenges, especially concerning third-party scripts.
- Shopify's Solutions
- Shopify has opted to eliminate third-party scripts from their top-level pages to enhance security.
- They have developed the Remote DOM framework, which allows third-party content to operate in a controlled sandbox environment, separating it from the main thread and ensuring safer interactions.
- This sandboxing approach helps mitigate risks while allowing for flexibility and extensibility for merchants.
- Impact on Development and Merchant Experience
- The transition has been significant, requiring developers to adapt their practices to fit within the new security framework.
- Despite some initial limitations, the new system is designed to provide greater reliability, performance, and security, ultimately enhancing the checkout experience for consumers.
- The Future of E-Commerce Security
- Ilya emphasizes the importance of developing better standards and API contracts for isolated environments.
- He acknowledges the complexity of these challenges and the need for the industry to innovate further in this space.
- Broader Implications of Secure E-Commerce
- The discussions touch on how the increasing sophistication of attacks necessitates a rethink of how compliance and security are approached across the web, not just in e-commerce.
Final Thoughts The episode underlines the fragility and importance of secure e-commerce, with Ilya Grigorik providing a comprehensive view of both challenges and solutions. As e-commerce evolves and grows, so too does the necessity for robust security measures, making the conversation around PCI compliance and digital security ever more critical.
Acknowledgments
- Special thanks to the sponsors of this episode: Retool, Augment Code, and Fly.io.
- Music credits to Breakmaster Cylinder.
Conclusion The podcast concludes with an emphasis on the continuous evolution of security practices and the dynamic nature of e-commerce, encouraging listeners to stay informed and proactive in implementing robust security measures.
Written by AI. May contain mistakes. Listen to the episode to check what was said.
Transcript
Automatic transcript. May contain errors.0:05Welcome to the Change Log, where each and every week we sit down with the hackers, the leaders, and the innovators of the software world to pick their brain, to learn from their mistakes, to get inspired by their accomplishments, and to have a lot of fun along the way. On this episode, I'm joined by Ilya Gregorik, distinguished engineer and technical advisor to the CEO at Shopify. Ilya has been hard at work securing e-commerce checkouts from sophisticated new attacks such as digital skimming, and he's here to share all the technical intricacies and far-reaching implications of this work. But first, a mention of our partners at Fly.io, the public cloud built for developers who ship.
0:52You know we love Fly, and you might too. Check them out at Fly.io. Okay, Ilya Gregoric on the changelog. Here we go.
1:07Well, friends, I'm here with a good friend of mine, David Hsu, the founder and CEO of Retool. So David, I know so many developers who use Retool to solve problems, but I'm curious, help me to understand the specific user, the particular developer who is just loving Retool. Who's your ideal user? Yeah, so for us, the ideal user of Retool is someone whose goal, first and foremost, is to either deliver value to the business or to be effective. Where we candidly have a little bit less success is with people that are extremely opinionated about their tools. If, for example, you're like, hey, I need to go use WebAssembly.
1:49And if I'm not using WebAssembly, I'm quitting my job. You're probably not the best Retool user, honestly. However, if you're like, hey, I see problems in the business and I want to have an impact and I want to solve those problems, Retool is right up your alley. And the reason for that is Retool allows you to have an impact so quickly. You could go from an idea, you go from a meeting like, hey, you know, this is an app that we need to literally having the app built in 30 minutes, which is super, super impactful on the business. So I think that's the kind of partnership or that's the kind of impact that we'd like to see with our customers.
2:19You know, from my perspective, my thought is that, well, Retool is well known. Retool is somewhat even saturated. I know a lot of people who know Retool, but you've said this before. What makes you think that Retool is not that well-known? Retool today is really quite well-known amongst a certain crowd. Like I think if you had a poll like engineers in San Francisco or engineers in Silicon Valley even, I think you'd probably get like a 50, 60, 70 % recognition of Retool. I think where you're less likely to have heard of Retool is if you're a random developer at a random company in a random location like the Midwest, for example, or like a developer in Argentina, for example, you're probably less likely.
2:59And the reason is I think we have a lot of really strong word of mouth from a lot of Silicon Valley companies like the Brex's, Coinbase's, DoorDash's, Stripes, et cetera, of the world. There's a lot of chat. Airbnb is another customer. NVIDIA is another customer. So there's a lot of chatter about Retool in the Valley. But I think outside of the Valley, I think we're not as well known. And that's one goal of ours to go change that. Well, friends, now you know what Retool is. You know who they are. You're aware that Retool exists. And if you're trying to solve problems for your company, you're in a meeting, as David mentioned, and someone mentions something where a problem exists.
3:33And you can easily go and solve that problem in 30 minutes, an hour, or some margin of time that is basically a nominal amount of time. And you go and use Retool to solve that problem. That's amazing. Go to retool.com and get started for free or book a demo. It is too easy to use Retool and now you know. So go and try it. Once again, retool.com.
4:12so i'm here with ilia gregorick from shopify back on the show after years and years you've been on the show i think four or five times ilia welcome back thank you i'm glad to be back What have you been up to, man? I think it was 2021, last time you were on the show, we were talking to Hydrogen. You're still at Shopify, so you've been there a very long time. What have you been up to? So I think, yeah, last time we talked about custom storefronts and a big mission we had at Shopify to enable developers to build customized storefronts using their own application stack. Since then, I've spent a lot of time diving into our APIs and infrastructure, and then also kind of in a roundabout way, ended up spending a lot of time in checkout, which at the end of the day is kind of the engine of the entire e-commerce operation.
4:58Perhaps an apt analogy is kind of like air traffic controller within your commerce operation because all the planes have to land there. You can think in different pieces in isolation. You have taxes, you have shipping, you have fulfillment concerns, you have inventory, but all of that has to come together during checkout where you have all the different policies, all the different negotiations, all the UI that needs to be in place. And that has been a really interesting and complex domain to kind of wrap your head around and navigate through. And of course, I think today we're going to dive into one particular aspect of it, which is the compliance aspect, which I admit is not something that I thought I'd be working on, but it turned out to be a really interesting technical challenge.
5:43So you've been at Shopify for how long now? In dog years, it feels like forever. In chronological time, I think it's been four years, but it's been a pressure cooker. Yeah, and you before that, I think, was it GitHub and Google or PostRank? You started PostRank. Can you tell us just briefly your travels? Sure, let's see how far do we want to rewind. I started my professional career as a founder of a startup. This was back in the 2011 era and our insight at the time was on the heels of Web2 and all of the social things that are happening, blogs at their heyday and all the rest, we figured that we could create a better search algorithm.
6:28So if you think of PageRank as the original PageRank of treating links to perform the ranking, effectively, that's a thumbs up, right? Except that when we approached this problem, and actually it was not, it wasn't 2011, it was 2008, we observed that there was a lot of extra signals available. There was literal thumbs up from different social platforms. You could leave comments. You can share them on different surfaces. So if we could aggregate all of those signals, we could build a better kind of human-driven algorithm for identifying what are the interesting topics. So that was kind of the technical underpinning.
7:02And then we went on to build a number of products around it, which were analytics for publishers to help them understand where their audience is, where the content is being discussed, where people are engaging. There was a product for marketing agencies, which kind of worked in reverse, which is, hey, if I have a thing that I'd like to seed, who are the folks that I should be engaging? What are the communities and all the rest? And through that work, that led us to Google, which acquired the company. And I ended up working on Google Analytics at the time, integrating a lot of this kind of social analytics know-how that we acquired into the product.
7:37and later took a hard pivot into infrastructure, technical infrastructure within Google, where we did a lot of fun things, like building radio towers to figure out if we could build a faster and better radio network and then learning that that's a hard problem. But then later that actually became Google Fi, which is an overlay network. And in the process, I picked up the kind of ambiguous problem of, hey, we keep talking about performance and measuring performance. and it's like we want to make it better, but how do you objectively quantify it? It's one of those things where you kind of know it when you see it, right?
8:13It's like that felt slow. But if I just asked you to put a technical metric on it, how do you actually measure that? So we spent a lot of time with browser developers in a W3C. I was the co-chair of the W3C World Performance Working Group just wrestling with that problem of how do you measure fast? Like, is it the onload time? No, not really. Okay, if it's like, when did pixels paint on the screen? but how do you measure that and which pixels are most important? So this leads you down to this kind of interesting cascade of questions. So that took a while. That was a good five or six years of my life of working on standards and working with browser developers, which was a lot of fun.
8:53And later I decided to join Shopify because commerce was clearly an interesting area and a deep domain area. And that's been the last four years of my life here where I got to work on building custom storefronts, which I think we covered in our last show. Yep. Like what is the Shopify opinionated toolkit for building custom experiences? So today, this is actually Hydrogen. That has evolved quite a bit since we last talked. It is a remix-based stack with a lot of built-ins for building beautiful, customized experiences powered by Shopify APIs. From there, that work also led me into API infrastructure.
9:38So looking at our GraphQL APIs and trying to understand, first of all, do we expose the right capabilities there? but second also once again performance capabilities and all the rest we have buyers all around the world we want to deliver great user experience to all the buyers so like how do you deploy a global cart and how do you deliver the right experience reliably and then finally that led me into the guts of like technical infrastructure like how do we actually stand up app servers in our like ruby stack shopify is a ruby primarily company right so rebooting our application stack and also working on checkouts, which kind of brings us back to the earlier part of the conversation.
10:19Yeah, full circle. So we're definitely going to talk checkouts. Since you somewhat moved on from your at least web performance years, I'm curious to get your take on recent work, specifically Core Web Vitals. Is that something you've been tracking and do you have a hot take? Do you like that? Do you think it hits the mark, misses the mark? What are your thoughts on that as a metric? Core Vitals was one of my key projects when I worked at Google. So it's, at least to me, this is definitely yeah well it wasn't purely me but it was one of the key things that we incubated and part of it was it's actually the same question like it what is the definition of a vital right like a vital is like a vital then the incentive behind the vital was like a vital signal just like you have a heartbeat in a human body like what are those things that you measure about a website that tells you that it's a good experience and the key problem that we wanted to solve was first come up with some shared agreement across browsers of how we can measure that reliably and not just in a lab environment because the thing that we keep learning time and time again is that the outside world is just so unpredictable that you have to measure what happens in the real world like you can you can bake in all kinds of assumptions into your model and then you get consistently surprised when you release your application or website into the public and you're like wow you know i never expected this amount of traffic to come from this particular region which happens to have this routing topology and my cdn just doesn't account for it or like my api is located north america but i have this tidal wave of users coming from i don't know europe or somewhere else right and for them the experience is just that much worse so rom or real user measurement metrics are critical and web vitals was our attempt to first of all define what the are like what does that subset and second what are the recommended thresholds right because everyone has a different definition like is fast 100 milliseconds is fast one second we try to align on that so i'm really glad to see that the web idles has continued to evolve like the initial set when we first published i believe was back in 2020 or so it focused on loading metrics but we knew even when we were walking into that announcement that we really need to also talk about interactivity like it's not just that the pixels rendered fast right it's also right hey is it responsive use the thing um is the is the page right is the page locking up when i'm trying to interact with it how about scrolling like how smooth is that so web vitals continues to evolve and add those add those metrics and i think that's great and it's really important for us as an industry to have that shared definition of what good looks like.
13:02Shows how fast the internet moves, because I thought Core Web Vitals was still relatively new, and it turns out it's like five years ago, and you're the one working on it. So, crazy. I think it highlights the complexity of the problem. It takes a long time to propagate those practices and metrics. But yes, it's been a long journey, and it was a great capstone of all the work that I did at Google and web performance. what shipping with vitals felt like a good milestone and that allowed me to kind of give myself permission to shift attention to other things right well let's do that let's shift attention to checkouts compliance security pci some of these things that honestly scare away or maybe lull to sleep many of us we start talking about compliance matters pci version 4 is burgeoning or maybe it's out now.
13:55I don't know. Tell us the skinny. What is PCI? Why does it matter? And then we'll get to what's new in the latest versions. Sounds good. So first, let's unpack the acronyms because those are always not helpful. PCI stands for Payment Card Industry. And it provides us, it defines a set of security requirements that you have to comply with as someone who processes sensitive credentials. So an example would be your personal access number or your credit card number, plus the CVV and all the other data, right? There's a set of protections put in place around that for if you're handling that data, then how you should be treated, what kind of security precautions those services must comply by and all the rest.
14:40And it is a fairly burdensome set of requirements to comply with. Then you have to get periodically audited and show that you're in good standing and all the rest. so as a consumer this is great because um fraud on the intranet is definitely a big thing isn't still very much an unsolved problem right like it is entirely entering a a credit card number into a web a random web form is not a secure undertaking right but we've managed to build a relatively reliable experience for consumers thankfully now what's different about PCI v4. In PCI v3, a key requirement was that you had to protect the service or the surface area where you're entering your credentials.
15:29So technically how we've solved that as an industry is we said, okay, well, if I want to accept payments on the web, I'm not going to do the obvious thing, which is going to put a random form on my page and start accepting credit cards, because then I'm accepting that data. Like my service will get a post request and I'm going to have the unencrypted payment credentials and now I'm liable for all of the compliance. Instead, why don't we outsource this problem? And hey, we actually have a great tool in the web platform. It's called iFrames. iFrames can provide us to, can give us an ability to embed an external service that can basically do this.
16:07And we can skin it in a way that it looks seamless, right? Like most pages that you visit on the internet, the payment form, if you actually open up your dev tools, you'll see that it's iframed for the specific reason, but it doesn't look janky. It looks integrated into the website. And the nice property of this solution is you can then just basically all of the inputs, all of the mouse events are obfuscated from the parent page. So that means you can wholly delegate the responsibility for PCI v3 at least to your provider a common example of that would be someone like stripe if you want to accept payments on your website they provide a like stripe elements you import a web component pass out a few props and boom you have a checkout form under the hood it'll inject a knife frame and do all the things on your behalf so that's great and that's been effectively where we've settled you know i think pci v3 came into existence around 23 or sorry 2013 or 2014 so the last let's say 10 years or so, that's how we've solved that problem as an industry.
17:16Now, that is really good, but it's not sufficient. So in the interim, what we've observed is, hey, sure, you've isolated this particular input into a secure sandbox. But what happens if your top level page gets compromised? Let's say you have a supply chain attack, or you have an XSS hole in your checkout page and someone injects a malicious script what could they do with that well what stops them from removing your secure input form and replacing it with a fake one or maybe providing an overlay and then tricking the user effectively into entering information into an insecure form that then exfiltrates the data and then swaps in the the original right This class of attack is called skimming attacks, also known as mage card attacks, which is a nod to Magento.
18:10Not to cast shade on Magento, but I think one of the first published large-scale instances of this attack was against Magento, which had some flaw. Magento is an e-commerce platform, open source. And for better or for worse, that mage card attack name has stuck. Now, to be clear, this is a problem that spans all platforms regardless, as long as you have some sort of vector for attack. So PCIeB4 tries to solve for this particular problem. It tries to tighten the perimeter to say, it's no longer sufficient to protect the payment page. You also have to protect or provide some guarantees around the parent page, the thing that is embedding this payment form.
18:52Okay. And specifically, there's a set of provisions. I think that in the spec itself, which is very long, like we'll zoom in on one particular aspect of this whole conversation, which is section 643. It's one of these random numbers that you just remember once you've been long enough in the PCI game. Yep. 643 defines in high-level terms three requirements. It says, hey, for the parent page, you have to maintain an inventory of all scripts that are being executed on the page. And also please document why they're necessary and how they're being used. Right. So just like, give me an inventory one.
19:33Two, once you have that inventory, have some mechanism to ensure that only those scripts, the authorized scripts are being loaded. And then finally, have some way to guarantee or check the integrity of each loaded script. Right. Because you could say, hey, this is my inventory. These are the scripts I've authorized, but what if that thing got compromised, as an example? Somebody replaced it with a malicious script because of a supply chain attack or otherwise. So those three things combined give you strong assurances about what's executing a top-level page, which is great. Now, the practical reality of how you go about implementing that, as you can imagine, is complicated.
20:12Sounds like a lot of work. Yeah, exactly. And it's complicated for two reasons. Like first we should partition this problem into, like if the two of us had a checkout page and we were to sit down and try to think through like, okay, we need to meet these compliance requirements. I would partition the problem into first party and third party scripts, first of all, right? Like, okay, for the first party content, yes, like we can define a process for, we audit which scripts we include, we audit their dependency, we have some security review, we have release process, we have CI checks. sure, I can give you inventory of those scripts, right?
20:48Also, because they're first party, I can put a content security policy and maybe even put a sub-resource integrity, which are hashes that effectively fingerprint the specific version of that page. So maybe during my build, I could just enforce a CSP, snapshot the hashes, put those on the thing, and like, great. Now I have strong assurances that the scripts that are being executed on the page are mine and tied to a specific version. So far, so good. Now, what about the third parties? One of the challenges with checkout is they're one of the most important pages for the entire e-commerce operation.
21:29Like this is where instrumentation is critical, right? You want to know performance telemetry. You want to know which elements user is interacting with because that affects conversion. you are likely running a b tests so you have either first party or set of third party vendors doing that of course you have all the conversion pixels that need to be executed because all the ad campaigns and all the analytics that you need to drive that entire up funnel down funnel loop and what about all of the other marketing pixels that you may need it's not uncommon if you just if you take an average checkout page and you open up the network tab, you'll probably find hundreds of scripts on many of them, right?
22:16And oftentimes it'll be, hey, we load a tag manager that then allows our marketing and other teams to inject whatever they need to drive the whole process. But now we're staring at that problem and we're saying, so how exactly do I apply an inventory and all these things because first of all like my partner asked me to put a tag manager so they can load things well i need to unwind that decision right because now i need to know exactly what everything that's being executed and i need to have kind of a full transit of chain of all dependencies i need to be able to account for that second uh you need to provide how do i know what the what csp policy should i define can i just say only load from partner.com or is the partner also loading from some other CDNs?
23:06Well, I need to go ask the partner for what those assurances are. And then lastly, if I want to ensure integrity, that's not my content. How do I obtain the hash of the thing? And then if that partner wants to rev the version of their script, how do I get the hash so I can put the thing inside? And then also I'm not the one injecting the content into the page. So it becomes this like a really complicated rigmarole of like, actually, I just cannot do this. Yeah, it sounds not possible. precisely which is one of those things where the the standard was written with good intent right and and they in passing mentioned hey you have these tools you have content security policy you have sub research integrity in principle in theory you have the right things to do this job in practice if you unpack your average checkout page on the web it's like i don't know how i would achieve this i could guarantee maybe a slice of it for first party but how do i solve this for third parties.
24:01All right. So it turns out it's complicated, right? So I thought you might say that.
24:34Well, friends, I'm here with Scott Dietzen, CEO of Augment Code. Augment is the first AI coding assistant that is built for professional software engineers and large code bases. That means context aware, not novice, but senior level engineering abilities. Scott Flex for me, who are you working with? Who's getting real value from using Augment Code? So we've had the opportunity to go into hundreds of customers over the course of the past year and show them how much more AI could do for them. Companies like Lemonade, companies like Kodem, companies like Lineage and Webflow, all of these companies have complex code bases.
25:12If I take Kodem, for example, they help their customers modernize their e-commerce infrastructure. They're showing up and having to digest code they've never seen before in order to go through and make these essential changes to it. We cut their migration time in half because they're able to much more rapidly ramp, find the areas of the code base, the customer code base that they need to perfect and update in order to take advantage of their new features. And that work gets done dramatically more quickly and predictably as a result. Okay. That sounds like not novice, right? Sounds like senior level engineering abilities.
25:46Sounds like serious coding ability required from this type of AI to be that effective. 100 percent. You know, these large code bases, when you've got tens of millions of lines in a code base, you're not going to pass that along as context to a model, right? That is would be so horrifically inefficient. Being able to mine the correct subsets of that code base in order to deliver AI insight to help tackle the problems at hand. How much better can we make software? How much wealth can we release and productivity can we improve if we can deliver on the promise of all these feature gaps and tech debt?
26:22AIs love to add code into existing software. You know, our dream is an AI that wants to delete code, make the software more reliable rather than bigger. I think we can improve software quality, liberate ourselves from tech debt and security gaps and software being hacked and software being fragile and brittle. There's a huge opportunity to make software dramatically better, but it's going to take an AI that understands your software, not one that's a novice. Well, friends, Augment taps into your team's collective knowledge, your code base, your documentation, dependencies, the full context. You don't have to prompt it with context.
26:58It just knows. Ask it the unknown unknowns and be surprised. It is the most context aware developer AI that you can even tap into today. So you won't just write code faster. or you'll build smarter. It is truly an ask me anything for your code. It's your deep thinking buddy. It is your stay in flow antidote. And the first step is to go to augmentcode.com. That's A-U-G-M-E-N-T-C-O-D-E.com. Create your account today. Start your free 30-day trial. No credit card required. Once again, augmentcode.com.
27:38so how do we approach this at shopify i think there's let me take first a branch into shopify and then we can talk about kind of the broader broader landscape sure we've been on a mission to provide stronger control and behavior over checkout not just because of compliance but because we want upgrade safety reliability performance and security in checkup and our Our observation is, first of all, for those not familiar, Shopify provides a hosted checkout experience where you don't get access to the underlying HTML. We provide the base UI and we allow you to configure it. And it's a very flexible system.
28:17You can customize the branding. You can introduce custom components. You can install apps that introduce components. You can do a lot of customizations to make it feel like your own. But a key principle that we've been operating on is that we want a set of predefined, first of all, we're going to define the UI elements because we want to preserve consistency and experience. And we want to optimize for performance, security, and all the rest. What that allows us to do is to say, actually, we're not going to allow any third-party scripts in our top-level page. and that is a very consequential and big decision this has been uh work that we've been on an arc for about three years if not more to achieve and we're finally there and now we're reaping the benefits of that so then the question is wait a second so you excluded all third party scripts but what about all those shiny things that you just mentioned earlier right the analytics the customizations the everything else and this is where sandboxing comes in so our our decision was to say only effectively the moment you introduce a third-party script into top-level page you have untrusted content and you've compromised all integrity of the top-level page like we cannot provide any assurances on integrity of the top-level page right because in the past when we did allow folks to or merchants to bring their own javascript into top-level page they're just doing and end up doing things that break compatibility like they'll they'll hook on a specific selector, right, to inject an element, knowing full well that we've never defined a contract for it.
29:58And then if we change that, we will break them. And then security is compromised as well because they're introducing their own scripts and we can't provide any assurance. So we took away that capability and said, instead, we're going to give you a sandbox. So we're going to spin up a set of web workers and give you a bridge. So for example, we've We built a library and open source called the remote DOM, which allows you to construct an element tree in an isolated worker that operates off the main thread. And then that UI is reflected back for you in the parent page. So it feels like ergonomically, DX-wise, it feels still very straightforward because you're just manipulating elements.
Read the full transcript
30:41And we provide a predefined set of UI elements that fit into the checkout UI and work with all the branding primitives. But we do that work on your behalf. And the critical part is, because we control the bridge between the web worker and the top-level page, we have tight control over what kind of mutations can be pushed between the parent and the isolator worker. So you can't just arbitrarily inject JavaScript or perform unsafe operations on the parent page. So in that way, we can take any third-party script, put it into a sandbox and say, you know what? You can do whatever the heck you want in that environment because you can load a transit of chain of other dependencies.
31:25We don't particularly care because all we know that the operations that you can pass back to the parent page are safe and approved set that we will allow. And we also control what data is exposed to you. So for example, if you have an extension that wants access to some sensitive buyer data, first that application and then the worker itself needs to have the right consent. So a worker that has not been granted the right consent by the merchant or the buyer will just not have access to that data. So that is our solution for extensibility and allows us to partition the problem of first-party and third-party content.
32:07It's based on remote DOM. And then we use the same technology for our pixels or analytics as well, where we define an event bus, we emit all the events, analytics providers are executed in the sandbox as well. Is that a compromise in terms of functionality? Do you get 100 % of what you could do before in terms of what you all are providing? Or is it like a, are you constraining people through and losing features along the way? Yeah, you asked exactly the right question. So So the answer is we've had to rebuild a lot of stuff because a web worker, if you're familiar, is not the same thing as working in the top level page.
32:44It doesn't give you access to the DOM. It doesn't expose all the same events. So the reason it took us as long as it did to layer all of this infrastructure is because we had to work with partners and replicate. So what do you actually need? Instead of raw access to the DOM tree, what are you looking for? For example, if you were building a heat map solution, as an example. Some of our merchants are really keen on having very visual, clear understanding of how users are behaving on their checkout page. You need access to a lot of different events and elements. Okay, well, let's work through that and figure out what is the right subset that we can expose via this bridge.
33:21So over time, we've built up a collection of these APIs and primitives, some of which effectively replicate what is available on the parent page. one of the challenges here by the way is like if you ever work with web workers is they use asynchronous communication right so you have to post message between a web worker and the top level page whereas a lot of the dom apis are synchronous apis so if you're just naively writing code expecting to be executed on top level page you would use synchronous apis so we've had to shim some of that and like in places we try to keep it as close as we can to what you would expect as a developer because we don't want to impose additional friction.
34:01But in certain places, we had to provide replacement APIs where we said, look, you're building for Shopify. It will operate across scale of millions of merchants if you're building an application. It is worth for you to do this extra step because then you have all these insurances in place. So a lot of handholding with partners and getting the developers to adopt all of those APIs. But the benefit of all of that work today is, I'm not going to say we're done because there's still more things to build, but we're in a really good place because now all of our merchants are running on the sandboxed primitive that I've described.
34:37And what we can provide is, first of all, upgrade safety. We can safely roll forward our capabilities in checkout, knowing that customizations that you've deployed will not break as you move forward, right? Because we control the bridge, we control the API interface. So if we change the underlying API on our site, we can still provide guarantees about that. We have reliability. We know that, for example, we saw examples where merchants would inject scripts, where a partner would just time out. So they would have some logic and for some reason their service goes down and then the checkout is broken because, well, it's just waiting to render, right?
35:16Like Shopify, you've broken the checkout. It's like, actually, it's your part. It's your script that you injected of a partner that failed to scale to your flash sale. Right? So now we have assurances about that. And then finally, performance and security. Another benefit of putting work into the sandbox is it moves all the work off the main thread. So you can't have code that monopolizes the main thread and renders the UI unresponsive, which gets back to our web vitals conversation, right? Like we can make better performance guarantees about how the page is loaded, how responsive it is, and the rest.
35:51And finally, there's a security bit, which is we know that you can't inject arbitrary content in top-level page and exfiltrate data. And then finally you have PCI compliance, because now we have a clean partition where we say, as Shopify, as a platform, we will provide all of the inventory, authorization, and integrity checks for the first-party scripts that are executed on top-level page. And, oh, by the way, you can totally bring third-party content, but we will execute it in this isolated context that allows us to punt that problem and not have to worry about all of the integrity problems that happen when you just include it on top-level page.
36:32so did you did i hear you right that you said all your merchants are already using this you're able to to deploy that without or did you not say all yes yeah yeah yes all yeah so this has been a long journey to move all of our merchants onto this new platform but as of earlier this year like 99.9 percent of our merchants are on this platform there may be like one or two exceptions but effectively any shopify checkout that you shopify power checkout that you visit today as consumer is running on this infrastructure. Hmm. And that was something that they had to opt into or that you just did on it.
37:07Like, how did you all roll that out? You said it took a long time, but what was, what did it look like? Well, it took a long time because of the right question that you asked, which is, Hey, did you, what, what did you have to take away? Right. And the answer is we had to rebuild a lot of the capabilities because we've created this isolated environment. We've had to recreate a lot of APIs. So a lot of our work was working with other developers, partners who provide capabilities that merchants want in checkout to make sure that they can bring the same capabilities into this new world of sandbox execution.
37:41That was the long haul. And then for some merchants that had ability to manipulate content in the top level page, it was a combination of documentation, handholding, consulting, and just getting them to move to the new world so they can benefit from all of these capabilities. But we're there and the time is right because now you have PCI v4 compliance effectively taking care for you. And do you think that PCI v4 compliance means you cannot be skimmed in the way that you could prior? Or do you think it could still happen in new and exciting ways? Right, right. So I think this actually is another layer that we should add here.
38:29What I've described is runtime compliance or runtime guarantees. So the thing that we've built actually allows us to provide assurance or extend some guarantees over, we just know that it's not possible to inject third-party content. So if you have a supply chain attack on that, it's isolated into a thing that doesn't matter. In practice, I think what a lot of other players and e-commerce providers will end up using or how they will provide compliance is retroactive monitoring. So PCI does not enforce a requirement that you have to have runtime guarantees. What it says is, hey, you should have a process that provides an inventory, make sure that scripts are authorized and you have the integrity.
39:18It doesn't specify that it needs to be guaranteed. So practically, how could you implement this? and how to most, like if you go and search for PCI compliance security products, you will find plenty that will basically say, hey, I know a great solution for your PCI problem. You know what it is? Deploy my JavaScript into your page. Right. Because more JavaScript is always a solution, right? And I will instrument the page and listen for all the things that are happening. I will observe all the other scripts. I will build an inventory. I will monitor if it changes. I will try to provide hashes and effectively I'll like, you can delegate this problem to me.
39:59Now you can see a flaw in that reasoning, right? It's like, how do you know that your script is not going to get compromised either? Who watches the watchers? Well, there's that. And how do you know that the malicious thing doesn't come up with a clever way to obfuscate itself from you, right? It's the antivirus problem, like virus hiding. Exactly. Virus hiding from the antivirus problem. But that is likely a solution that many will adopt as a retroactive solution. So effectively, you observe if anything has changed. It's like, oh, well, that's odd. I'm seeing a set of reports for a script that I did not expect relative to my inventory as I defined.
40:42Does that indicate that I have a problem on my site? Probably, right? So there's some guardrails that PCI sets for how long that period can be and how you need to react to it. but it is strictly lesser and less secure experience, which gets back to your question. If you have these assurances, does it mean that the class of attacks is eliminated? The answer is it depends on how you implement it. So in our case as Shopify, I would feel pretty strongly about extending a promise of like, yeah, unless our content, first party content is compromised, it would be very hard to compromise this page. Now, what we can control as Shopify is the buyer has installed a browser extension that injects arbitrary scripts into the page.
41:30That is outside of our control because that operates at a higher layer. Or maybe you even have malware on your computer that does things and injects content into the page or otherwise intercepts what you're typing. Those things are still possible. It is not a completely eliminated this type of attack. but it certainly makes it a heck of a lot harder because now it means that at least there at a minimum there's a way the merchants are required to detect these changes or these attacks and remediate so they can't just go unnoticed so this all sounds like a lot of really good work you all have done at shopify for shopify and Shopify's customers, thinking bigger, it would be great if your hard work and years of rethinking this runtime and sandboxing and actually providing the security that PCI v4 wants everybody to have, whether or not they do or not to be compliant, can't some of that get into the browser?
42:37Like, couldn't we just build it? Could your work extend beyond Shopify's borders? and help other people too. Yeah, absolutely. And I think this is key. This is not just about Shopify. It's about improving the buyer experience on the web holistically. So two things to answer that. First of all, the remote DOM library that I mentioned, it's an open source project that we've built and have open source. So if you go to github.com slash Shopify slash remote DOM, you'll find that there. Take a look at it, use it. That's the technology that powers Shopify checkout. Other large companies have already adopted it.
43:12I believe Stripe is using it for their apps. Actually, fun story. When we built the project, I think Stripe beat us to using it in a production product. Really? Even though we were the ones developing it for checkout. Good for them. But it is used at Shopify and by other big players to provide this form of isolation. And the general pattern is, hey, I have a trusted first-party surface into which I want to bring in third-party content. And I don't want to compromise integrity of my first party top level service. Well, remote DOM is one of the technical solutions for that. So please take a look at that.
43:51That's answer number one. Second, though, and coming back to the browser conversation, absolutely. The primitives that we have in browsers today, content security policy and SRI, we can make better. And we've actually done a bunch of work on exactly that at Shopify. We don't want to do work in JavaScript that we could push into the browser because the browser is just much more efficient and it has capabilities that otherwise would be very hard for us to replicate. So first, let's enumerate some trivial examples of gaps. Script integrity. So sub-resource integrity. For those not familiar, on your script tag, you can pass in effectively a hash.
44:31So when you inject the tag into your HTML, you can pass in a hash that is a fingerprint. And when the browser loads the script before it executes it, it can compare the hash of the thing that it fetched versus what you've defined and say, hey, if those two things match, great, I will execute the script. Otherwise, I'm going to raise a violation and not report this. That's a big capability that exists in browsers today. It's not simple to deploy, but it is doable, right? Because you need to figure out how do I get these hashes and how do I inject them at the right place? but then one of the gaps that existed for a long time was module imports so sri worked for top level scripts but if you're building a javascript application and you're using an you know import you just could not pass in an integrity hash why well because module imports came after sub-resource integrity was designed so it was just never it was never a thing that was a pain point for us because we use module imports at shopify so we worked with Chrome and Safari to upstream some patches to get that supported for module imports.
45:38So the good news is that's now baked in, I believe, as of May of 2024, I think when Safari shipped it in their release, both Chrome and Safari support SRI for module imports. So that's one. Another thing that came up in our thinking when we were exploring CSP compliance and how do we make our own life simpler is this idea of require SRI for. So what if you could express a content security policy that says, hey, all scripts must have an SRI or integrity hash. Gotcha. Right. And why is that useful? Well, then you can make a strong claim that if you have that policy being enforced by the browser, then if for some reason you sneak through by accident or malicious act, a script that doesn't have it, they would just be rejected, right?
46:32Which today it would just execute normally without any questions. And even though that might be hard to deploy in an enforcement mode, it could totally work and be really useful in a report-only mode. So for those not familiar with content security policy, you have an enforcement mode and a report-only mode where you can get violations, which is incredibly useful because you could say, hey, this is a policy I would like to enforce. What are the violations? So with the require SRI 4, you could deploy this in report-only mode and say, great, now I'm going to get reliable reports from the browser, from the wild, for any time a browser detects that a script is missing an SRI capability, right?
47:17This is great because sophisticated attackers would not emit these scripts on every single page load. They might target specific users or a class of user, or maybe they target a specific browser, or maybe if it's an extension, it'll apply some sort of other heuristic, right? It's very hard to, this kind of mirrors our conversation on why ROM is important, real user measurement. Gathering violation reports from real users gives you a much better and reliable signal for where the problems are. so require sri 4 is another capability that we've shipped into chrome and that allows you to get violations on missing sri attributes which allows you to build an inventory of like this is the list for me to burn down and figure out why right and if anything changed how should i react to it yeah another example is okay great now we have these reports coming in wouldn't it be nice if we could also get the hash of the content right it's today you would just get a report saying hey i detected script from example.com slash xyz.js but what was the content of that you don't know right wouldn't it be nice if you could also get a hash in the report such that you could audit it and say oh well maybe that's totally okay because the partner revved their version and it just happens to be the v2 i just put that i put that into my approved list and everything's fine versus i have no idea if that was a compromised version or a legitimate version of the script interesting so pardon my ignorance for a moment but where does the reporting take place or post to the browsers doing the reporting is it correct who gets the report and how is it the browser sends it off somewhere or yep so on the wire um you would when you emit a page uh you can define a content security policy or csp policy in a header and you would define you know for script source list for example a list of origins from which you're allowed to fetch for images and all the rest you also have a report to target gotcha and a separate report to header that provides a specification for you specify the endpoint to where you want the report violation report to be reported and you know it's good hygiene that reporting endpoint should ideally be like a distinct origin um in all the rest but you provide a destination so you can find services that will do this for you right they'll just say point your report to to us and we will provide a dashboard which you can drill down reports we will aggregate we'll give metrics and all the rest.
50:04That's something that we do in-house at Shopify. And I think many other large providers will do on their own, but you could outsource that problem. But just having the ability to even get the report with, Hey, a report has been admitted because the script is missing an integrity hash is by itself a really useful capability because otherwise you'd probably have to set up some sort of a crawling infrastructure that periodically checks your page and says you know i i accessed this page from five different points on the globe right every 24 hours and i observed that nothing has changed well that's good but we could do much better by just actually observing what the real users are seeing and getting the actual reports of violations gotcha so this new one require sri 4 would work in like manner as the csv violations in terms of reporting.
50:59The CSP policy is require SRI for scripts, right? So you're saying all of my script resources must have a hash. And then you can configure that to be a report-only policy such that it would still execute if the script is missing the hash, but you would get the violation fired in the background. And the browser has its own logic for prioritizing batching delivery and doing all of that to get you the report. Now, do you deploy this one in Shopify? Yep. And do you use it in report mode or do you let lockdown mode or how do you use it? So for this one, it would be report mode, but it depends on the shape of your checkout and how much control you have for your first party or third party content.
51:50Just to double back on that, for Shopify, for our checkout, but we enforce a CSP policy. Actually, let me run through the whole list. For our first-party content, we have a well-defined process for vetting all the dependencies and a process for updates, auditing, to make sure that we provide some guarantees over if the library that we depend on has been compromised, how can we detect that? We have change management process for it. So this is the reviews, testing, CI, all the things that you would expect. that allows us to create the inventory we know from where it's served which means that we can define a strict csp policy that says you should only fetch from these sub origins that we trust in our build step we can inject the hashes the sri hashes for known content and we can also emit the require sri 4 policy to ensure that if anything else for some reason if we omit a missed some script that we would get a violation on that because we don't want to break checkout but we want to be notified immediately if those things are detected then we can react to it and we have our own reporting endpoint which we aggregate we look at the reports this is a thing that merchants don't have to worry about because we do this work on their behalf right and we can provide this guarantee over overall integrity and then finally we've protected the parent page but the payment credentials page or the payment form itself is also isolated into its own iframe just as it was before so this is a defense in depth right we protected the parent but we also have our own implementation of the iframe and like the full pci compliance behind that particular form well that's a lot of stuff for pci compliance ilia what happens with v5 how many years are you going to put into that one i don't know that that's a great question i'm pretty sure that v4 will keep us busy for a long while yeah because this is only section 6.4.3 right that's all we're talking about right here that's right there's there's all the others okay so interesting stuff it sounds like you've solved some really difficult technical challenges in order to to do this in a way that's uh not just compliant but actually in the spirit of the compliance as well, like trying to actually make it more secure.
54:18What are some takeaways for listeners out there? You know, maybe they're doing their own checkout, maybe they have compliance they need to do, maybe they just want some more secure websites. Like, what do you think they could be thinking walking away from this if they're not in the actual situation that Shopify is in and having to implement this stuff? What could they learn from this conversation? Yeah, I think the meta pattern and message takeaway here is broadly the integrity and security of first party versus third party content. We mix first party and third party in most contexts, but even outside of checkout, there are many surfaces.
54:59Let's say you have an admin surface or a privileged surface that you only want certain users to access. And you want some sort of extensibility in there. So you want to bring in third-party content or customization in all the rest. The pattern that we're describing with isolating third-party content is a generic pattern that you can deploy there. So we use the same sandboxing technology in checkout. We use the same technology in our admin. So for merchants, we allow customizations and third-party developers to bring in their custom UI and other aspects. As you can imagine, that's a very sensitive surface.
55:38Order data is there. Customer data is there. You don't want to just open up a Pandora's box of injector arbitrary JavaScript because who knows where the data might travel. So the isolation primitive, it may be a remote DOM. It may be something else. But this way of thinking of isolating into either an iframe or a worker, I think, is a pattern that we should be adopting more widely. And it has these additional benefits. You have better assurances about security. Yes. Performance as well, because you're isolating content and moving it off the main thread. You get to define the API contract. So you have better upgradability if you need to maintain that.
56:24And I think that's just something that we need to get better at on the web. Now, the challenge, I think, for all of us and kind of as industry practitioners is to think through. boy the worker is kind of this like naked environment we can probably figure out we should think about how do we figure out some better set of apis that where we don't have to reinvent the entire wheel just as we did with you know at shopify for great now i want to build a heat map thing what does that mean how do i mirror the the entire stream of events from top level page into this isolated environment i think we can do some thinking and innovation there.
57:04Very cool. Anything else that's on your mind that we haven't discussed in this context or honestly in any developer context? I always love to hear your opinions on stuff. Anything else on your mind? I think one really interesting topic coming back to the world of checkout and commerce is of course agents and how agents will interact or how they might affect any of these behaviors. Oh yes. MCP, are you done with MCP? That's the newest acronym, Model Context Protocol. It's burgeoning. Yep, yep. MCP is definitely top of mind, and we're looking at it intently. We're using it for a number of tools and internal services at Shopify.
57:41We're also considering if and how we should be exposing MCP as a protocol and endpoint as a service on behalf of merchants. So imagine you could have a merchant storefront as a remote MCP endpoint. but more broadly like if you think of let's imagine you interacting with an agent asking it hey i'd like a pair of white sneakers size 10 15 to or 50 to 100 range please go find me a pair and check out under the hood the agent might crawl the web find the storefront add to cart head to checkout and what does it do then as it's looking at a payment form is it responsibility of the agent to hold on to your payment credentials?
58:23And what are the implications of that for entering? How does it enter those credentials? Are there any security and compliance problems or challenges in that? I think that's a wide open question that we as an industry are yet to figure out an answer. Is the human required in that loop? What if it's an accelerated checkout where maybe information is vaulted, right? I think there's a range of questions and answers that we need to figure out in the space. What's your personal thought on is the human required in the loop? How do you feel confidence-wise on removing the human from that loop? I think it's context-dependent.
59:03I think there's definitely a class of commerce in certain types of transactions where I know exactly what I want. There's very low risk and it's kind of a predefined flow where I just say, look, I need another carton of milk. you know exactly what i'm looking for you know where to shop and please go finish it and i just want it my front door and then there is other types of experiences where maybe you're this is your first time engaging with a merchant maybe a merchant has a set of rules where they actually require you or require the agent to decelerate because hey for compliance reasons i may need to verify your age or i need you to read this disclaimer on this product before you purchase it You can't just have the agent blindly ignore that context or click approve and then proceed with the transaction.
59:55So I think we'll need to define some protocol or shared mechanism to signal to agents that like, hey, in this particular case, I need you to pause and ask for human to either confirm or take over control and complete the transaction. There's so many questions there. I just don't feel like I even have the brain right now to analyze all the things that have to be considered. I'm glad that you're, are you going to be working on this for Shopify? Are you going to stay in the NPCI land? What's next for you inside? Is this an active thing that you're thinking about for Shopify? It is definitely an active area of exploration for us.
1:00:39It is one of the things I'm looking with our team and many of our partners who are building these agents. we're trying to figure out what is the future of checkout where agents drive some meaningful portion of that experience. What does a good experience even look like in that context? So I think those are all very interesting and pertinent questions given where we are today. Well, I'll have to have you come back in a year or two and let us know what you end up building as you've figured it all out. You seem to have figured it out. At least this hairy technical problem has come with this new PCI stuff.
1:01:13so I'm sure you'll figure out something. Yeah, we'd love to be back. And at the rate that we're moving in AI world in a year or two for now, who knows what will be there? Yes, I'm trying to think of the most recent person who said six to nine months and LLM will be writing 100 % of code. So, I mean, who knows, man? Maybe you and I will be out on the street corner talking about this stuff. I doubt that is the case, but who knows? Yeah, me too. But not a week goes by that somebody doesn't declare software engineering is dead or dying. How to squeeze that one in there. I think what we're actually saying is the definition of what software engineering is is changing.
1:01:58I am constantly amazed by what AI is capable of doing in terms of software development, but I'm also constantly surprised by the silly and stupid mistakes that it makes. And oftentimes those mistakes are actually due to
1:02:15misunderstanding or lack of poor definition of the problem that's being solved. It's kind of putting the mirror back to yourself, right? Because oftentimes I'll find that like, actually, you know what, you did exactly the right thing, the way I expressed it, but that's not what I meant. And I didn't even know what I meant when I typed it, because now that I've seen the mistake, I understand what I was actually trying to get to. So it is this like art of defining the problem and rubber deck programming. And I think we're heading more and more towards a world where we're actively collaborating instead of hands-on keyboard typing if statements.
1:02:46Yeah, the best rubber duck programmers might be the best programmers of the future. The ones who can just talk it out the best, you know, figure it out as you go. All right, Ilya, appreciate you coming on the show and chatting with us and looking forward to having you back soon. Thank you, Jared.
1:03:04Okay, so it turns out securing e-commerce checkouts has never been more complicated. But thankfully, brilliant engineers like Ilya and his team at Shopify are putting in the work, and some of that work is making its way back into the web platform. I love when that happens. And when you think about it, the complicated nature of it all makes sense. The stakes have never been higher. I read the other day that last year, e-commerce sales soared to a record$1.2 trillion. That's a lot of moolah being transferred. And if you can hack it, well, you can jack it. so yeah it's complicated for a good reason let's give one more thanks to our sponsors of this episode retool augment code and of course fly.io check out their wares to support their work which supports our work which we appreciate thanks also to our beat master in residence break master cylinder did you know our next full-length album is almost ready and i'll tell you right now it's called after party and i'll also tell you right now that i've been bumping all week.
1:04:09I dig it. Hopefully you will too. Soon. So soon. All right, that's all from me, but we'll talk to you again on ChangeLoginFriends on Friday. Bye, y 'all.
1:04:53Game on.
From the publisher
Ilya Grigorik and his team at Shopify has been hard at work securing ecommerce checkouts from sophisticated news attacks (such as digital skimming) and he's here to share all the technical intricacies and far-reaching implications of this work.
