[00:02.040 --> 00:08.100] Hello, my name is Aaron. And I guess I have to apologize. The resemblance is a little hard to [00:08.100 --> 00:12.340] see in that picture, because my hair is not nearly as luscious as it is in that photo. [00:12.380 --> 00:17.800] But I'm sorry, your mineral content in the water, as you've all found out, really awful here. [00:18.700 --> 00:25.040] But yeah, like Jen, I work at Google. We do web security on hundreds and thousands of different [00:25.040 --> 00:29.760] web apps. I've been at Google for a little under seven years. And before my stint in security, [00:29.760 --> 00:34.780] I came from the developer side. I've worked on products like Google Docs and GCP on customer [00:34.780 --> 00:40.780] facing stuff. So when we approach this work of trying to make our web apps as secure as possible, [00:40.780 --> 00:45.400] we approach it with a special empathy for the developer, where we want to ship the most secure [00:45.400 --> 00:50.160] products, but also we don't want to get in the way of delivering really dynamic and new user [00:50.160 --> 00:57.720] features. Cool. Thanks, Aaron. Here's a quick look at our agenda for today. So we'll start with a [00:57.720 --> 01:01.500] quick intro to XSS. I assume most of you are familiar with it, but we'll still go over some [01:01.500 --> 01:05.660] examples. And then we'll talk about runtime mitigation, specifically those that come with [01:05.660 --> 01:10.400] content security policy and its different flavors. Then we'll talk about how we use those to secure [01:10.400 --> 01:16.180] applications at scale. And we'll move on to how we imagine the post-XSS world and end with a call [01:16.180 --> 01:23.100] to action. Cool. So cross-site scripting. It's just some data to motivate that this is a big [01:23.100 --> 01:27.980] problem. Google runs a vulnerability reward program where we pay out security researchers [01:27.980 --> 01:34.980] when they report their bugs to us. As you can see here, over 50% of the bugs reported are web-related. [01:34.980 --> 01:43.080] That makes sense. Google is a web company. And then the rest, out of those 50%, almost 35% are XSS. [01:43.080 --> 01:47.400] So this was a really big problem, and that's why we've developed techniques to remediate the stats [01:47.400 --> 01:53.520] at scale. So let's talk about what XSS really is. The root cause is user input gets mixed up with [01:53.520 --> 01:59.600] code and then gets interpreted as code. Because HTML is dynamic and mixes static data with logic [01:59.600 --> 02:04.480] that should execute, as you see here, this is very prevalent. And this leads to malicious scripts [02:04.480 --> 02:10.740] getting injected into a trusted site. In this example, you see a very simple example, there's a [02:10.740 --> 02:14.720] description that's supposed to be dynamic, but if this is user-controlled, we can inject the following [02:14.720 --> 02:21.360] script and get it to execute. And there you have an XSS. An XSS, when exploited, lets the attacker [02:21.360 --> 02:25.960] take control of the account of a logged-in user. This means the attacker can do anything the victim [02:25.960 --> 02:30.840] can, so it's pretty powerful, and that's why we try really hard to avoid it. We also call this the [02:30.840 --> 02:36.240] client-side version of remote code execution, as they share a similar concept of arbitrary code [02:36.240 --> 02:42.180] execution. And here's another format you might be used to seeing XSS. We usually pop an alert [02:42.180 --> 02:49.020] with the document domain as a proof of concept when we find an XSS record. So a quick example of [02:49.020 --> 02:55.560] DOM XSS, the client-side variant of cross-site scripting. The root cause here is DOM APIs are [02:55.560 --> 03:00.680] not secure by default. We all love JavaScript, and JavaScript loves turning strings into code [03:01.320 --> 03:07.340] through APIs like innerHTML or script.innerText. Here's a very simple example of how this might [03:07.340 --> 03:11.840] happen. In this code snippet, locationHash is a user-controlled string. We take that and [03:11.840 --> 03:18.080] happily insert it into innerHTML. In this case, with the example here, the onError alert statement [03:18.080 --> 03:23.000] will execute, and then we have XSS. But no one codes like this anymore, right? Thanks to modern [03:23.000 --> 03:27.200] frameworks like React that abstract away file manipulations, nobody has to do this. [03:29.580 --> 03:35.960] Except... not. As you can see in this fresh bit of internet outrage, an enterprising developer has [03:35.960 --> 03:41.980] managed to work in a innerHTML assignment inside a very functional React component. It's supposed [03:41.980 --> 03:46.320] to be a really advanced system that takes care of the virtual DOM dipping, all of the different [03:46.320 --> 03:50.020] re-rendering things, so that you don't have to do this yourself, but this developer didn't really [03:50.020 --> 03:55.180] want to take it into their own hands. And this is the crux of the problem. Just because a framework [03:55.180 --> 04:00.240] can abstract away the complex DOM operations doesn't mean that it can prevent a developer [04:00.240 --> 04:05.220] from using them. And these issues are really easy to introduce in your codebase. It really takes [04:05.500 --> 04:10.500] a developer, a code reviewer, having a bad day and once it sneaks into your product then [04:11.140 --> 04:15.740] it's really hard to eradicate. So do we stand a chance against this class of problems? [04:16.060 --> 04:20.780] And we think we do. We've all heard of content security policy and how it can solve all your [04:20.780 --> 04:26.620] process scripting, right? Well, we do admit that content security policy is a little bit difficult [04:26.620 --> 04:32.800] to understand and configure. It really is more like a meta feature than a feature. It has a lot [04:32.800 --> 04:37.220] of bells and whistles and knobs that you can change, a lot of directives. What do you have [04:37.220 --> 04:42.140] to set on these directives? And it is a little confusing because it tries to cover everything, [04:42.140 --> 04:46.700] any sort of resource that loads on your page. But hopefully when we go on this journey together, [04:46.700 --> 04:52.560] we can talk about some of the configurations that we found to work at scale and cover many [04:52.560 --> 04:59.780] classes of cross-site scripting and we'll see why they work together. And before we begin, [04:59.780 --> 05:06.960] since we are talking about cross-site scripting and CSP and protections that Google uses, [05:06.960 --> 05:12.040] maybe we'll take a look at what is actually working in the wild. So here we have an example [05:12.040 --> 05:16.520] of a particular Google web app that some of you may have used. You know it has a really complicated [05:16.520 --> 05:22.740] UI with a lot of interactive user features and a small call out to this team. They've been great [05:22.740 --> 05:29.200] partners in really shipping the best and greatest and the latest web protection mitigations and [05:29.200 --> 05:33.860] working really hard to keep their end users safe. So let's open up Chrome DevTools and see [05:33.860 --> 05:40.280] what we are actually shipping on a real life product. And as you can see here, we see a couple [05:40.280 --> 05:44.540] different content security policies, a lot of them as a matter of fact. But like we said before, [05:44.540 --> 05:50.120] not all of them are specifically for cross-site scripting defenses because it's a meta feature [05:50.120 --> 05:55.100] that can also turn off other potential dangerous vectors as well. We don't have time to get into [05:55.100 --> 05:59.120] the other protections, but if you have questions, we will be sticking around for a little bit after [05:59.120 --> 06:04.740] we can go into more detail after the talk. But for now, we'll focus on these two, the ones that [06:04.740 --> 06:10.660] we find to be really powerful protections against cross-site scripting, namely the nonce-only CSP [06:11.280 --> 06:18.720] and the trusted types header. Cool, and we'll go into some details. So nonce-only CSP, [06:18.720 --> 06:23.800] in the example we saw before, it's pretty self-explanatory. It's the one with the nonce [06:23.800 --> 06:30.000] directive. More specifically, a nonce-only policy takes a form that looks a bit like this. [06:30.000 --> 06:34.820] Internally, we recommend a nonce-only or a strict CSP for most of our modern web apps. [06:34.820 --> 06:39.960] What this does is only what's allow-listed under the script source directive can run on the page. [06:39.960 --> 06:43.900] Other scripts will be blocked. So in this case, any script with the right nonce, [06:43.900 --> 06:49.220] which is a random value that's generated per request, can run on the page. So the [06:49.220 --> 06:52.920] templating systems usually propagate the nonce for each script tag on the HTML, [06:52.920 --> 06:58.000] and the header has to send the right value for the nonce. So the header and the HTML work [06:58.000 --> 07:01.840] together to indicate which scripts are trusted, and the browser can act accordingly. [07:02.480 --> 07:07.680] Another CSP directive that's useful for a nonce-only policy is the strict dynamic directive. [07:07.680 --> 07:12.840] This directive enables a transitive trust for scripts. So if you have one script with the [07:12.840 --> 07:17.820] right nonce, it's allowed to load other scripts, and the trust is propagated. When we don't have [07:17.820 --> 07:21.640] this directive, only scripts with the right nonce can execute. If they load other scripts, [07:21.640 --> 07:27.320] they'll be blocked. So although this slightly relaxes the policy, we found that it's also [07:27.320 --> 07:32.540] made adoptions a lot easier for complex web apps. So that's the trade-off that we're working on. [07:33.820 --> 07:38.280] So thanks, Jen. So as Jen mentioned, a nonce-only CSP is great if you have the [07:38.280 --> 07:42.220] back-end or the server-side render content working in close conjunction with the front-end [07:42.220 --> 07:46.940] or client-side code, because you have to generate these nonces that are new for every single [07:46.940 --> 07:51.700] response. But what if you don't have control over the back-end? Then we have to use a close [07:51.700 --> 07:56.180] relative of the nonce-only CSP called the hash-based CSP. And the way it works is, [07:56.180 --> 08:00.800] it's very similar to a nonce-based policy, but as you've noticed, instead of the nonce value, [08:00.800 --> 08:05.980] we provide a hash value. And this is really powerful because we don't have to regenerate [08:05.980 --> 08:12.980] this CSP for every response load. The hash is fixed, presumably because on every response, [08:12.980 --> 08:19.480] your script is mostly the same. And this is really powerful when you don't have control [08:19.480 --> 08:26.600] over that back-end, so you can put in the logic to do this nonce generation. And this is also [08:26.600 --> 08:32.560] super useful for the SBA, single-page applications, because when you are doing the final bundling [08:32.560 --> 08:38.120] process for your final HTML, you know what script has are going to be there in your SBA bundle, [08:38.120 --> 08:44.000] and use that to generate your hash, and there you go, a fixed CSP policy that offers this [08:44.000 --> 08:51.420] protection that you can even drop into a meta tag at the top of the HTML file. And in more detail, [08:51.420 --> 08:55.060] so what you have on the left is sort of like what your bundle might look like for a particular [08:55.060 --> 08:59.960] single-page application. You've got a couple scripts loading to actually get the user interaction [08:59.960 --> 09:07.040] going. And we would actually rewrite this in this case into a dynamic loader inside an inline script [09:07.040 --> 09:11.580] block, because that is one of the characteristics of a hash-based CSP for now. You need to know [09:11.580 --> 09:17.160] exactly what's in the script content in order to make the hash. So usually you do this by actually [09:17.160 --> 09:23.220] inlining the block, and if you have resources that would load over the network, then you [09:23.220 --> 09:28.780] turn it into JavaScript that would dynamically add it to the page. And once we have that, [09:28.780 --> 09:34.480] we also added some preload tags so that we actually get the parallelization going for [09:34.480 --> 09:39.700] fetching these resources. You can take the script block, create the hash, and stick it in as a meta [09:39.700 --> 09:45.640] tag that carries a CSP, and there you go. The HTML is self-contained and offers this protection [09:45.640 --> 09:55.300] with a CSP baked in. The next CSP-delivered mitigation that we want to talk about is [09:55.300 --> 10:00.520] trusted types. Specifically, trusted types is geared towards protecting DOM-based XSS. So in [10:00.520 --> 10:05.480] the example that we saw before, it's the one that says require trusted types for, and that's the [10:05.480 --> 10:11.840] directive that you need to send. So we want to point out that the attack surface is large here [10:11.840 --> 10:17.000] for DOM XSS. There's over 60 JavaScript APIs that can turn strings into code and lead to arbitrary [10:17.000 --> 10:22.640] code execution, and DOM XSS is usually very easy to introduce and hard to detect. Calls to these [10:22.640 --> 10:26.660] APIs could be going through multiple levels of indirections, it could be in a transitive [10:26.660 --> 10:30.920] dependency, or it could exist in libraries that we don't have control over. So how can we make [10:30.920 --> 10:36.280] this better? And we need a run-time mitigation for this, and this is where trusted types comes in. [10:36.280 --> 10:40.680] The main idea behind trusted types is to make security decisions explicit and auditable. [10:40.680 --> 10:45.900] To do this, trusted types will restrict the access to the dangerous DOM APIs we mentioned previously, [10:45.900 --> 10:52.520] and it will require typed objects instead of plain strings to be passed into the over 60 APIs. [10:52.580 --> 10:56.900] So in this case, instead of strings that represent script URLs, HTML, or scripts, [10:56.900 --> 11:01.200] will require typed objects such as trusted script URL. And we'll discuss how to generate [11:01.200 --> 11:07.040] these typed objects, but this is the main idea. This is what the header looks like, again. [11:07.100 --> 11:11.160] This tells the browser to reject string assignments to injection syncs, and effectively [11:11.160 --> 11:16.340] it provides a run-time type checking mechanism on top of JavaScript. If you remember the example [11:16.340 --> 11:21.240] from our DOM XSS slide before, we're using a plain string here with innerHTML, and if trusted [11:21.240 --> 11:26.620] types were enforced, we would throw an error that looks like this. So the browser will tell you you [11:26.620 --> 11:32.640] need a trusted HTML, and it won't use a string. We want to highlight that most security guarantees [11:32.640 --> 11:38.480] of trusted types come from a policy, and the policy is what I mentioned of how we could generate a [11:38.480 --> 11:44.800] trusted object. So you can think of it as a wrapper that takes in a string and returns a trusted type. [11:44.800 --> 11:48.720] And we apply this policy to strings before inserting them into the DOM sync, and the [11:48.720 --> 11:53.280] processing you do within the policy should make sure the string won't lead to any unintended [11:53.280 --> 11:59.740] code execution, therefore preventing DOM XSS. So in this example, we use a sanitizer from DOM Purify. [11:59.740 --> 12:04.500] We check for the presence of trusted types in the JavaScript namespace for browser compatibility, [12:04.500 --> 12:08.740] and then use the correct factory if it exists. But if you don't want to keep writing this verbose [12:08.740 --> 12:14.340] if block, because it is a bit clunky, DOM Purify also works with trusted types off the shelf, so [12:14.340 --> 12:19.340] it will do the policy creation and the browser compatibility checking under the hood for you [12:19.340 --> 12:21.840] if you pass in the right config for trusted types. [12:25.280 --> 12:29.420] Thanks, Jen. So now that we've talked about our security features that we believe are powerful [12:29.420 --> 12:33.560] against cross-site scripting today, we'll touch a little bit on how to use them in your application [12:33.560 --> 12:38.060] and offer a bit of the lessons that we've learned from securing our apps at scale at Google. [12:38.060 --> 12:41.900] So before we begin, we'd like to make a quick plug for an article that presents many of the [12:41.900 --> 12:46.560] ideas that we'll discuss in the next section, but in written form. This approach is used widely in [12:46.560 --> 12:50.260] our team and our org, and this article goes into a little bit more detail than what we have time for [12:50.260 --> 12:55.700] in some of the ideas that we'll elaborate on next. It's on the Google Security Engineering blog [12:55.700 --> 13:01.880] at bughunters.google.com, along with other great content like this, and also similar to, I think, [13:01.880 --> 13:06.760] the theme of this village. So please check us out. So back to the main show. What are some of [13:06.760 --> 13:12.020] the tactics that we use to adopt these security features at scale on hundreds of different web [13:12.020 --> 13:15.960] apps? So some of the lessons that we've learned that we find most useful are, number one, [13:15.960 --> 13:21.020] use the frameworks that will help you in this journey. Number two, try to shift left to get [13:21.020 --> 13:26.180] developers an indication whether this feature is incompatible with code that they're writing as [13:26.180 --> 13:32.240] early as possible in the process. Number three, some tools that we've built and we also rely on [13:32.240 --> 13:37.040] throughout this process that we found useful. And number four, a quick note about third-party [13:37.040 --> 13:42.760] dependencies and how they might complicate your adoption process. So the first big idea is if [13:42.760 --> 13:47.460] you're starting a new code base from scratch, let's think about which frameworks we can use [13:47.460 --> 13:53.000] that will give us security superpowers. And the big idea behind that is that at our scale, [13:53.000 --> 13:57.640] at at-scale defense against cross-site scripting at Google, we rely on frameworks with, number one, [13:57.640 --> 14:02.880] context-aware templating, and number two, built-in compatibility with these security features that [14:02.880 --> 14:07.700] are secure by default. And as a quick aside, we haven't talked too much about context-aware [14:07.700 --> 14:12.420] templating right now, but we don't have too much time to get into that. But the gist of it is you [14:12.420 --> 14:17.200] want to have a templating system that does reasonable enough things to prevent a lot of [14:17.200 --> 14:21.340] server-side rendered cross-site scripting from happening. Catch us after the talk, [14:21.340 --> 14:24.920] and we are happy to chat about templating too, which is beyond the scope of this talk. [14:26.820 --> 14:31.380] So what we want to cover on this slide and for the rest of the talk is what we call the safe [14:31.380 --> 14:36.640] calling philosophy at Google. And this is the idea that we want to give tools to developers [14:36.640 --> 14:41.920] that take away a lot of the uncertainty from the developer on how to use and configure these [14:41.920 --> 14:46.340] security features correctly, because they are really easy to misconfigure in really subtle [14:46.340 --> 14:52.300] ways. And we want the security to not really get in the way of feature development and shipping [14:52.300 --> 14:56.540] great things to our users, so we want to abstract away some of these decisions in a clear and [14:56.540 --> 15:03.320] understandable manner. And the key to do this is through our frameworks and our APIs. And we'll [15:03.320 --> 15:08.540] say that this is possible at Google because you do have tight control over the internal frameworks [15:08.540 --> 15:12.900] that you use in-house, and also tight control over the guidance that we give to our developers [15:12.900 --> 15:17.840] on how to use these frameworks. But I imagine many of the web developers here aren't building [15:17.840 --> 15:23.140] internal web apps for Google, so how can you get some of these benefits? And thankfully, our, [15:23.140 --> 15:27.820] yeah, colleagues have worked hard to ensure compatibility with some of these security [15:27.820 --> 15:32.520] features and frameworks that are available outside of our internal ecosystem as well. [15:32.520 --> 15:37.740] For instance, some of the frameworks that are also available externally, like Angular and Lit, [15:37.740 --> 15:42.860] all the hurdling work that we do there translates to benefits for the ecosystem and for everyone in [15:42.860 --> 15:48.280] the world to use. But if you're also using frameworks that are not entirely within the [15:48.280 --> 15:54.720] Google ecosystem or very Google-inspired, we also have our colleagues at Meta who did a lot of work [15:54.720 --> 15:59.260] to make React compatible with CSV and Trusted Types, and some of the frameworks that are based [15:59.260 --> 16:04.940] on React, like Next.js, thanks to volunteers and other colleagues, have compatibility as well. [16:04.940 --> 16:10.320] Great, so on to the second idea, how to shift left and enforce early. And this is just the idea [16:10.320 --> 16:14.740] that you want to add these headers and protections as early as possible, maybe in your dev server, [16:14.740 --> 16:19.480] so that when things go wrong, your developers can see the error and act on it as soon as they've [16:19.480 --> 16:24.420] written the code, so that they can fix it while the context of what they're trying to do is fresh [16:24.420 --> 16:30.340] in their minds. And a quick, and more technically, a way to do this is, well, here in this example, [16:30.340 --> 16:35.780] we have a configuration for a Vite dev server. I hear that's what all the web developers are [16:35.780 --> 16:42.560] using nowadays. We are all on to Vite now. And here we see a Node.js express-style middleware [16:42.560 --> 16:46.960] inside this configuration for the dev server that just dumps in these headers. [16:48.220 --> 16:53.660] But if you don't have control over your dev server or your serving stack, as you mentioned before, [16:53.660 --> 16:59.340] meta tags at the top of an HTML file also can deliver these headers. And for the observant [16:59.340 --> 17:04.260] among you, you will see that here we have our hash-based CSP again, because if you are [17:04.260 --> 17:10.260] baking a CSP into a static HTML page, you really want it to be a hash-based CSP so that [17:10.260 --> 17:16.680] the nonce value isn't blown the first time you use it. And we saw an example of how to do the [17:16.680 --> 17:21.580] refactoring to make a hash-based CSP before, and it was a little cumbersome, so how can you do that [17:21.580 --> 17:27.340] more easily? And the answer is, we have an experimental tool available in GitHub and [17:27.340 --> 17:33.620] NPM that does a lot of this transformation for you. This is available as a Webpack plugin, [17:33.620 --> 17:39.320] but also as a utility library that takes in a string of the HTML and does a refactoring like [17:39.320 --> 17:43.800] this. I mean, I know there's a lot of code on the screen, but it just takes in a string and [17:43.800 --> 17:49.300] outputs a string and will shuffle around the notes, do the hashing, add the meta tags for you. [17:49.300 --> 17:54.160] And this is really powerful because this is a very framework-agnostic way that now has proven [17:54.160 --> 17:59.220] to have outlasted the popularity of Webpack plugins because they just keep changing the [17:59.220 --> 18:05.820] configurations. But this is really powerful because if we remember the example from before [18:05.820 --> 18:11.080] with the Vite middleware, it composes almost perfectly. This is just a copy-paste job of the [18:11.080 --> 18:16.460] last two slides. And I think one of the lessons we learned in building some of this tooling is [18:16.460 --> 18:22.160] if you keep it as agnostic as possible in terms of frameworks and just separate the logic from [18:22.160 --> 18:27.060] the framework, then you can just, yeah, snap the pieces together when a new framework comes along. [18:28.120 --> 18:30.340] So on to the next section. [18:31.560 --> 18:37.120] Thanks, Aaron. In addition to using the header to spot violations early, we really advocate [18:37.120 --> 18:41.480] for using some other tools to help you with adopting these defenses. We'll introduce a [18:41.480 --> 18:46.600] bunch of helpful tools, but they can be categorically be broken down into, first of all, [18:46.600 --> 18:51.520] tools for understanding features and violations. We mentioned that CSV is notoriously hard to [18:51.520 --> 18:56.500] configure and understand, and the CSV evaluator solves that problem. It's available as either [18:56.780 --> 19:00.640] a website or a Chrome extension, which will give you some high-level guidance on the configuration [19:00.640 --> 19:07.780] of your CSV. It can detect directives and then kind of explain them. We're also actively working [19:07.780 --> 19:13.600] on a tool called Trusted Types Helper. This isn't released yet, but it will be soon, for streamlining [19:13.600 --> 19:18.120] the Trusted Types adoption process. One of the most time-consuming and painful stages of Trusted [19:18.120 --> 19:22.240] Types enforcement is finding the source of violations and trying to fix them. So this Chrome [19:22.240 --> 19:27.220] extension will create a DevTools tab that helps you demystify Trusted Types violations and suggest [19:27.220 --> 19:33.100] some refactoring. So stay tuned. Another category of tools are those that help with refactoring [19:33.100 --> 19:39.040] using Static Analysis. We have a huge Static Analysis pipeline at Google, and we took the [19:39.040 --> 19:44.320] most effective checks that we run on our internal Static Analysis tooling and Linter and built it [19:44.320 --> 19:50.100] on top of ESLint, and that is Safety Web. This project is also in active development, but it is [19:50.100 --> 19:55.980] available on GitHub. As you can see in the example here, it will detect unsafe usages of risky APIs, [19:55.980 --> 20:00.900] and you can refactor these unsafe calls with another tool we provide called Safe Values. So [20:00.900 --> 20:07.060] Safe Values is a library designed to steer developers to make safer choices. It will prevent [20:07.060 --> 20:11.960] unsafe assignments using TypeScript type checking unless the value is trusted, either from a trusted [20:11.960 --> 20:17.980] source or by transformation that makes it trusted. For example, sanitizing an HTML makes it trusted. [20:19.000 --> 20:23.500] We mentioned we were going to add a quick note about third-party dependencies. This [20:23.500 --> 20:28.740] is the complicated part, and it's a big aspect of making your application compatible with these [20:28.740 --> 20:34.080] features. For both Trusted Types and CSP, all code running on your site needs to be free of [20:34.080 --> 20:39.160] violations of these policies, otherwise they will be blocked by the browser. This is a hard part [20:39.160 --> 20:44.000] because we won't always know which dependencies are incompatible until we've introduced them, [20:44.000 --> 20:48.080] and it's also hard to fix because the potential refactoring sites don't exist in our code, but [20:48.080 --> 20:52.800] code that others have written and others control. We're currently working on tooling that will make [20:52.800 --> 20:57.540] informed decisions about which dependencies might be compatible with which features in the ecosystem, [20:57.540 --> 21:02.600] but this is a part where we could use some help as well. As CSP and Trusted Types gain more widespread [21:02.600 --> 21:07.060] browser adoption, you can help us by making pull requests if you do end up patching third-party [21:07.060 --> 21:10.920] dependencies that you find along your journey of adopting these features. [21:12.900 --> 21:18.100] Thanks, Jen. So, I know we talked a lot about the mitigations and the tools that are used today to [21:18.100 --> 21:22.720] protect our apps, but let's talk a bit about where we want to go from here and the more secure world [21:22.720 --> 21:28.660] that we'd like to see in the future. And here are the key ideas we talked about today that form the [21:28.660 --> 21:36.200] basis of this protection, this pipeline of protection, if you will. So, the running theme is [21:36.200 --> 21:40.840] abstracting security decisions away from developers in a clear and secure by default way. [21:41.180 --> 21:44.900] When all of these elements work together, starting from the first stage when the code is written, [21:44.900 --> 21:48.780] all the way to the final point when the code is executed in the client's browser, [21:48.780 --> 21:53.600] we have protection at every stage of the development lifecycle. And this should make [21:53.600 --> 21:59.240] most cross-site scripting solvable, and we see this working at Google scale. On our most recent [21:59.240 --> 22:04.040] in-house frameworks that follow a lot of these guidelines from these pillars, we see so few [22:04.040 --> 22:10.020] cross-site scripting, and none of them are trivial attack chains, and all of them really have some [22:10.020 --> 22:15.220] weird logic bug or some legacy system involved. So, we are seeing the effects of this working [22:15.220 --> 22:20.180] at scale across billions of users and hundreds of different web apps. But how can we make this [22:20.180 --> 22:25.320] safer? Where do we go from here? What's the next logical step? And we believe that, remember how [22:25.320 --> 22:31.820] we talked about trusted types, and it blocks a lot of these inherently unsafe DOM APIs in the web [22:31.820 --> 22:37.280] platform, or at least makes it harder to use? What if we take that to the conclusion of the idea and [22:37.280 --> 22:43.180] actually like ban all of those usages at runtime of these legacy DOM APIs that are a little bit [22:43.180 --> 22:50.580] inherently unsafe as they've been designed? Can we build apps where we don't use any of those APIs? [22:51.060 --> 22:55.740] And that's our future vision of where we go from here. If we have new platform-level APIs [22:55.740 --> 23:01.720] for operations that we currently use DOM APIs for, such as maybe a browser-included sanitizer [23:01.720 --> 23:06.480] implementation for HTML, maybe a templating solution, then we've really come full circle [23:06.480 --> 23:12.020] and have our runtime enforcements influence a new suite of secure-by-default web platform APIs [23:12.020 --> 23:17.180] to bring decisions that nudge developers towards safer choices, maybe at the framework level, [23:17.180 --> 23:20.760] from the very beginning when the first line of code is written in a new code base [23:21.280 --> 23:27.960] all the way to the moment when it is executed on the client's browser. [23:28.520 --> 23:32.860] And this is the future we hope to get to, one where we can safely lock down all the accesses [23:32.860 --> 23:37.680] to many DOM APIs along with a new suite of platform APIs to replace those operations in [23:37.780 --> 23:41.860] a safe-by-default manner. And we call this approach, we've nicknamed it Perfect Types, [23:41.860 --> 23:46.940] it is the logical evolution of Trusted Types, and we see this as the next evolution of Trusted [23:46.940 --> 23:51.520] Types and a post-cross-site scripting world. This combined with the strict CSP configurations [23:51.520 --> 23:56.120] we talked about and our framework-based approaches, secure-by-design, safe-by-design, [23:56.120 --> 24:00.540] should guide us to a new post-cross-site scripting world. And taking a step back for a second, [24:00.540 --> 24:06.660] for an even bigger picture, and as a final plug, this safe coding philosophy and safe-by-design, [24:06.660 --> 24:11.260] trying to steer developers in the right direction is something that extends beyond just JavaScript, [24:11.260 --> 24:16.620] cross-site scripting, and is a core priority for all Google-scale security efforts. You can read [24:16.620 --> 24:21.760] more about our organization's work at these links, and Google is a signer of CISA's secure-by-design [24:21.760 --> 24:25.920] pledge along with other industry and government leaders in the space, and we've committed to [24:25.920 --> 24:31.940] sharing our knowledge on how to build a safer future together. All right, well, that is the [24:31.940 --> 24:35.460] end of our talk, so thank you everyone for listening. Hopefully this was a good guide [24:35.460 --> 24:38.160] on how to think about solving XSS. I'll leave you here.