This talk is Escaping the Privacy Sandbox with Client-Side De-Anonymization Attacks. So if this is the wrong talk, this is your time to change. But otherwise, thank you for staying with me. And let's have a good 45 minutes. So a little bit about me. I'm Eugene Lim. I go by SpaceRaccoonOnline and I'm from Singapore. It took about 15-16 hours to get here. And it's currently, I think, 7.30am in Singapore. So let's see if I can make it. In my day job, I do application security for a small organization of about 200 people. So I focus on cybersecurity, application security. But outside of my day job, I love to do vulnerability research. I kind of touch everything from hardware to software to web technologies. One of my most recent pieces of research was smart weighing scales that connected to the Internet. And I think the question of why would you connect that to the Internet is a pretty common theme across a lot of the stuff that I've done. So that's really part of my interest. So before we begin, I thought I'd just give a bit of background on what this is all about and why the Privacy Sandbox, why the Google Privacy Sandbox exists. And you may be aware that third-party cookies are a piece of web technology that's on the way out. A lot of advertising platforms use third-party cookies in order to track users and analytics and perform all kinds of functions such as conversion tracking. For example, if you view an ad and you make a purchase because you saw the ad, third-party cookies kind of serve that function. But one of the big changes that's happened in recent years is that browsers are starting to phase out third-party cookies because, you know, it's not great for privacy. And you may have also noticed that there's a bunch of new legislation and regulations that are restricting the use of third-party cookies. So if you have ever seen a website and you had a pop-up that says, do you accept or allow cookies? That's all part of that going on behind the scenes. And obviously, I think consumers are getting a lot smarter as well. So you see now browser add-ons and extensions as well as network-level ad blocking that are blocking the use of these third-party cookies. So in recognition of that, Google came up with the Privacy Sandbox technologies which allow and replace these third-party cookies functions in advertising, but do it in a more privacy-preserving manner. And I think we're going to unpack that for the rest of this talk. Now, I want to address the elephant in the room. So for those of you who are kind of plugged into this, Google has been saying that they're going to phase out third-party cookies for about, I think, four years now, since 2022. And every year, they kind of say, OK, we'll do it next year. And what happened in April, very conveniently, right after I submitted my talk, they said, OK, we're giving up. So we're not going to use Privacy Sandbox to completely replace third-party cookies. We're going to keep third-party cookies. But I think all that being said, why do we still care about the Privacy Sandbox that Google has built? Well, number one, obviously, is that it's already live. It's still being served in Chrome and Chromium-based browsers, including Microsoft Edge, for example. And a lot of ad tech companies still use it. Google is one of the biggest advertising platforms out there, and they still rely heavily on Privacy Sandbox. And I think, most importantly, it's still interesting, right? Because one thing that stood out to me when I was doing this research is that ad tech companies really don't want you to know about ad tech. They don't have a lot of documentation. They don't really publish a lot. And part of the reason why is, obviously, they take a lot of information, right? And they don't really want you to know too much about that. But I think also because it is privacy, it may not often overlap with security in some senses. And not a lot of research has gone into this very interesting field of Internet technology. But the fact is that advertising takes up a large part of the Internet today. And if you actually uncover a little bit more about it, as I have, there's a lot to unpack. So we're going to dive right in. So what is the Privacy Sandbox? This is a piece of technology that Google has built up over the years that's meant to replace some of the features and functions of third-party cookies to perform stuff like tracking, conversions. And it consists of three parts. The first is a set of proprietary... well, I wouldn't say proprietary, but client-side browser and mobile APIs. These are JavaScript interfaces that allow you to then perform some of these functions. The second is a walled garden that Google operates that allows advertising platforms to register with Google and also call on these APIs. And the last is pretty interesting. It is an aggregation and decryption of some of these aggregated analytic data in trusted execution environments that Google allows you to deploy in your own cloud accounts. And this is pretty interesting because they use the term trusted execution environment, but you're really just executing it in your own cloud account. And so there's some question as to whether it is that trusted. But for today, I'm going to focus on client-side browsers and mobile APIs, the client side of this, and there's already a lot that you can do to subvert some of these protections that the Privacy Sandbox offers. So I'm going to go through, I think, three weaknesses that I've discovered as part of my deep dive into the Privacy Sandbox. The first is the Attribution Reporting API and how I was able to leak some information through what they call transitional debug reports. The second is browser history reconstruction or stealing via side channels. And the last is the Shared Storage API, where I was able to leak private data from the shared storage through insecure workload code. And if you have some time, I'm happy to just take questions from outside of this talk if you have any questions to have. So let's dive right in. What is the Attribution Reporting API? And what you see here is kind of a screenshot from the Chrome debug where you can see the source triggers and reports that make up the Attribution Reporting API. Essentially, I think the Privacy Sandbox provides the Attribution Report API to solve and address a very common advertiser's problem, which is, all right, I paid for someone to see an ad. Did that ad actually lead to a conversion? If someone viewed the ad on website A, did they click the ad and eventually make a purchase on website B? And this operates entirely on the client side. So I'm going to break it down into a few steps about how this Attribution Reporting API works. Well, step one is, obviously, you have to first view the ad, and that's registering a source. So, for example, you visit a website like the publisher's website, it may be a new site or some other site that's hosting the ad, and you interact with the ad in some way. You may click on it, you may view it, and this can be done and registered using the AttributionSource attribute or the JavaScript AttributionSource option to any kind of XML HTTP request. Once this is done, the browser automatically sends a request with the Attribution Reporting eligible header to your AdTags server, which will then respond with an AttributionReportingRegisterSource header, which includes a specific destination that that ad is linked to, so that source. So, for example, you viewed an ad to maybe buy tickets to Singapore, right? The destination might be SingaporeAirlines.com, and so on and so forth. And this is then stored by the browser on your client-side storage for future matching, which I'll go into in the next steps. So you've viewed the ad, and now your browser knows that you've viewed this ad and potentially may make a conversion. This is what the request looks like when you make a request to the Google Ads server. Again, you can see the headers that are being sent. What's interesting I want to draw your attention to is on the right side. In the response as well, you would see some information regarding your source, such as the aggregation keys, the destination, some debug information, and all of these metadata that's used to characterize the ad that you just viewed for future analytics. So what's step two? Step two is a trigger. So you may click on that ad, you may go back to the website that was advertised later and make a purchase, and regardless of that, this is counted as a conversion that they may want to register. In order to do so, it's going to send a request again by your browser with the attribution reporting eligible header, and the AdTag server is going to respond accordingly as well. And this will then trigger source trigger matching. So this is what the requests look like. On the left, you have some sort of trigger where you maybe bought a product, and the Google Ads server is going to respond with some of this header data. You may notice, for example, some filters that are used to, again, characterize what kind of purchase you made, that may then be used to calculate a conversion. And this is the last step. After you have registered the source and you perform a trigger, the browser is going to try to match that trigger with your source. So, for example, you made a purchase after viewing an ad for Apple products. It's going to confirm if that happened by comparing the stored source in your browser storage, and it's going to use several other filters to confirm this. And it will then send an event level or summary report to the AdTag server, telling them that, yes, a successful conversion had occurred. So that was a lot of talking to explain what seems like a pretty simple function, which is just to register a successful conversion. And you can probably imagine how this can be done already using third-party cookies. But I think one of the key things, if you look at the request that was sent, where it's an event report confirming a successful conversion, is that there's actually quite limited data that's being sent. It sends a destination where this attribution has occurred, it sends some metadata related to your conversion, but not a lot more than that, and that is by design. So there are some intended privacy protections for this very complex way of implementing a conversion. First is that Google Privacy Sandbox adds randomization. It randomizes the time when the report will be sent, so that you can't individually filter for a specific individual's behavior. It sends a limited set of data that is supported by the Privacy Sandbox API. And it's also pretty noisy, because it adds, I think, aggregate noise, so that while individual activity is somewhat obfuscated, you can't actually track a single person's browsing history because of this, on aggregate, you're still going to get fairly accurate data and analytics. So this seems like it solves all of the problems. You have privacy, but you also have analytics. So that sounds pretty good. So obviously we've got to break it. So one of the first things about the Privacy Sandbox API that you may notice is that it tries to solve many problems at once. It tries to make the marketers happy, it tries to make the advertising platforms happy, and it tries to satisfy privacy concerns. And one symptom of that is that you see a lot of escape hatches. And one of these escape hatches is debugging reports. So if you look at the documentation for the Privacy Sandbox API, it says that these are explicitly transitional debugging reports. They're not meant to last forever. They're only supposed to last up until third-party cookies are deprecated. Well, good luck with that, because they're not doing that anymore. So this is now a permanent feature. And what this is used for is essentially a way for advertising platforms to perform additional debugging requests with additional information about a particular conversion, or ad view, and so on. And ostensibly, this is a feature, not a bug. Now, if any of you have done source code review or static analysis, you'll know that one of the favorite things to look out for is to-dos, because it never gets done in the code. And this is one of the to-dos in the system design for Privacy Sandbox API, where they said, consider adding support for the top-level site to opt in to receiving debug reports without cross-site leak. And what this means is that it's supposed to prevent leaking of cross-site data. Let me illustrate this with a simple example. A website may be loading third-party resources from a different origin. And typically, browsers can send a referral header that tells the third-party origin where this resource was being loaded from. And in some cases, this might be sensitive information. For example, you may be loading a website or an ad that is owned by a third party, and you don't want to know where the ad was being viewed. In this case, you would send a referral policy header with the no-referral value. But if you had enabled the Attribution Reporting API on this page, it would actually send the referral site, despite the no-referral policy, via a debugging report. So this would actually subvert a mitigation that you would typically have to prevent leaking of the top-level site. So what this means is that previous mitigations or protections that were based on this assumption of using the referral header no longer work as intended. And one of these technologies is SafeFrame. So SafeFrame is a hardened iframe standard by the Interactive Advertising Bureau, which is a conglomeration of various advertising platforms, including Google, which uses them for double-click ads. What SafeFrame is supposed to do is because actually serving ads on your website can be pretty risky. What you're essentially doing is that you are running JavaScript or HTML that is created by the person purchasing the ad, and this may actually be a security risk for your website. So by putting all of these ads within a SafeFrame, what it's meant to do is that it's prevent and limit the amount of data that's leaked through the SafeFrame or the amount of control that's done through the SafeFrame to the publisher website. But what the Attribution Reporting API does is that it effectively subverts the protections of the SafeFrame. You can trigger header error debugging reports deliberately through malformed Attribution Reporting API response headers, and this would then leak the top-level site. So I'll just kind of walk through an example here. We start with visiting the website, for example, the publisher, or maybe diverge.com, which is a tech website. And you interact with an ad that is within a SafeFrame, and this is how some Google ads are sometimes served. And it would then trigger an Attribution Reporting-eligible header to your attacker-controlled attack server. And by sending a malformed response in your header, this would trigger a header error debugging report on the browser site, which includes the contact site, which is the top-level site. Essentially, this tells the person who bought the ad and served the ad which website your ad was viewed in. Now, this might not seem so serious, but this is actually information that is typically meant to be obscured. You're not supposed to know whether this individual IP address has visited X website or not. If you buy an ad on Google, this data is aggregated, but it's not broken down into specific IP addresses. So by purchasing an ad on Google Ads, for example, and if this weakness was available, you would then be able to kind of serve a Trojanized ad that would de-anonymize the browsing traffic of anyone who views your ads. So this effectively subverts some of the protections in older advertising technology that may not have accounted for this new API. So what was pretty interesting was seeing how various advertising platforms dealt with this. If you look at Facebook Ads, which doesn't use SafeFrame, but has its own sandbox domain, it essentially disabled the Attribution Reporting API completely using the permissions policy header. And I think that probably makes sense. It's kind of a cat-and-mouse game, but this kind of highlights how important it is that your iFrame or your SafeFrame, where you're serving an ad, needs to be kind of a hermetic environment because new technologies emerge all the time, such as Attribution Reporting API, and this may break certain assumptions that your protections have been built on. So this was kind of an interesting start to this research. But what was more interesting is the destination hijacking attack. Now, what Privacy Sandbox API allows through Attribution Reporting API is to register multiple destinations, up to three of them, per source registration. So say, for example, you saw an ad for buying tickets to Singapore, and you can register not just SingaporeAirlines.com, you can register several other destination websites where someone can perform the conversion of buying a ticket. But while I was checking the real-world implementations of this in various websites, in this case, I was on Diverge.com, I began to notice two strange domains that were appearing throughout all of the Google DoubleClick ads that were served. If you kind of look at it here, I was viewing an ad for Semrush.com, and so obviously one of the destinations linked to this ad was Semrush.com. But two other destinations were added to it. One was DebugConversionDomain1.com and DebugConversionDomain2.com. Do you kind of want to make a guess what's wrong with these domains? Yeah, you could buy them. So Google DoubleClick ads was basically injecting this into every single ad that they served across the Google ad network as one of the destinations, and they didn't buy it for some reason. So it was debugging, right? So I bought it for $10. Or $20, because I bought both of them. Now, the question is, what can you actually do with it, right? On the surface, if you understand and kind of look through the attribution reporting API, this isn't super serious. It seems like you can maybe perform ad click fraud. So if a user visits a website, and you interact with the ad, and we now know that Google DoubleClick ads injects these two additional destinations for every single ad out there, if they then visit my attacker-controlled site, which is now DebugConversionDomain1 or 2.com, I could then trigger an attribution, and this would be counted as a conversion. So, OK, cool, but not super crazy. What I wanted to do was really just figure out what you've done, right? What websites you've been visiting and where you've seen ads. So I began looking for ways to get around this, and one of the things I started looking into was rate limits. The attribution reporting API is really very intentionally designed to preserve privacy. I don't think that's really a question. And one of the ways they've done this is they have added rate limits for various actions, because, for example, they don't want an advertiser to track too much information about a particular individual. They also don't want to create resource exhaustion by triggering too many of these client-side storage. There is one undocumented storage limit for event-level reports per destination site to prevent excessive resource usage. And through testing, I found that this was actually a limit of 1,000, so not too much. And when this limit is hit, new conversion reports can no longer be sent, and it's going to send an error instead. So we can actually leverage this oracle to find out if a user had visited a particular website. So, for example, they visit a publisher website, and they viewed an ad, and now we know, again, DoubleClick injects these two additional domains on top of the intended destination domain. And if the user did visit that destination domain and perform a conversion event, then one event-level report would be sent. But later, if they were to visit the attacker-controlled website, because I control debugconversion1.com and 2.com, I'm able to then repeatedly trigger source and trigger registrations and perform that matching, and trigger the remaining 999 event-level reports. Conversely, if that user didn't actually visit the advertiser.com destination, I would be able to send 1,000 of these reports instead. So this effectively allows me to use a Boolean oracle to determine if that user had actually visited the advertised website or not. So this then allows me to achieve de-anonymization, because by understanding and leveraging the DoubleClick ad network, I can figure out exactly where the user has been through a combination of filters and also this rate-limit oracle. Now, again, this is pretty much the opposite of what the Privacy Sandbox is supposed to do, which is to not leak an individual's browsing history to anyone. More concerning is that this doesn't even require me to be serving a protogenized ad in any form. It just means that the user has to have visited a website that served a Google DoubleClick ad in the past. So this is all fairly interesting, but there's still more to find. As I began to look into the rest of the advertising platforms, I noticed, for example, sites like YouTube.com were serving Privacy Sandbox API, Attribution API registrations with interesting destinations. In this case, user 436576.site. And one of the conclusions I kind of draw from this is that advertising platforms are actually kind of piggybacking on this data field to inject user-identifying information or use it for other kind of debugging purposes. And this is actually a common pattern you see in schemas, in protocols, when people have to perform certain actions, but the schema doesn't support it, so they use the existing schema to kind of hijack and build their own features on top of that. So there's actually a lot more to find in this abuse of destination sites. So the next thing I want to talk about is the Shared Storage API. So what the Shared Storage API essentially is, is a privacy sandbox API for cross-site storage and access to data in a privacy -preserving way. This again serves an advertising outcome , which is to able to store a user's interest group or any other identifying information regarding that user and to use it to then customize the ads that the user views. So it may store items such as, this person's a cat lover, or a new home buyer , and then be able to use this to serve specific ads for that user. And how this works is, again, through a set of JavaScript APIs unique to the privacy sandbox. In this case, for example, it would first set this value. In this case, ABTestingGroup is zero. Once this is set, it essentially should never be accessed again. The privacy sandbox API for shared storage does not allow you to directly retrieve that value ever again. So no website should be able to understand which cohort you belong to, what your interests are, again, to preserve the privacy of the individual. Instead, what you have to do through the shared storage API is to use something called shared storage worklet modules. And what this module does is that it uses something called an output gate. So for those of you who are familiar with, I think, confidential compute or trusted execution environments, this pattern actually takes some inspiration from that, where there's some private data that you do not want to expose directly to the person using that data, but that person can call on that data through a function. In this case, select a URL for what app to serve to that user. And the output of that function is the only thing that comes out of it. You never really access that data directly. So this is called an output gate in privacy sandbox API terminology. And what this output gate is then fed to is another privacy sandbox API unique element, which is called fence frame, which is some variant of an iframe with even more opaqueness so that the top level site can't even query what content is being loaded in a fence frame. So again, all of this complexity, all of this design, the whole point of it is that it should be completely opaque to the publisher side or the advertiser what value is in the shared storage. And this also allows them to anonymize a certain user based on what ads they're seeing online. So as I mentioned when I first discussed debugging reports, one of the symptoms that you see with the privacy sandbox API is escape hatches. And these escape hatches then subvert some of the protections built into the privacy sandbox. And there are a number of discussions, and I was looking through the GitHub issues, the mailing lists, and the documentation where there was this discussion about allowing for cross-origin shared storage workloads. This means that the origin that set the shared storage and the module that is allowed to access it can be loaded by other origins. And it's an opt-in feature. And this means that you have to make sure that your script is secure. Unfortunately, as we know, this is a foot gun that means that there's a lot of insecure implementations out there. One example I have here is fledge.criteo.com workload code. Criteo is another big advertising platform. In this case, it seemed fairly experimental, so I wouldn't say that this is full production. But in this case, what they were using shared storage for, and this is simplified code, they were using to set the A-B testing population value of a user. And this would be put in shared storage. Later on, this would then be used to select a URL that would be the advertising URL that would be displayed to that user, simply by performing an ends-with string match with the list of URLs passed to this function. Now you can see why this is probably an issue, because you're not actually supposed to know, firstly, what population this person is supposed to do, but you can infer that based on the URL that was matched. So in this case, what we see here is a proof-of-concept way to exploit this implementation, where an attacker, because this is a cross-origin workload code, can load the workload code and pass to it a number of URLs, and essentially add a fragment at the end of these URLs for the entire range of possible values that Chrome A-B-T population could be in a shared storage. And by loading the selected URL, you would now then be able to infer and retrieve the value of this shared storage. So in this case, we see here that shared storage value for Chrome A-B-T population is 2, and simply by visiting this proof-of-concept website, you're now able to fetch this value and kind of infer that and leak this value. I emphasize again that this is something that you're not supposed to do with the shared storage API. You're not supposed to leak cohort data about a particular individual, but because of the way that this worklet has been designed, and the way that cross-origin worklets have been enabled, this is now possible. So just a brief summary of some of these attacks that I've gone through. There are still more I think that you can probably find, but the first is the ability to leak the top-level site of someone who has viewed an ad to bypass certain legacy implementations such as SafeFrame. The second is de-anonymization with destination hijacking, to understand whether someone has visited a particular website in the past as a complete third party. And the last is to leak shared storage value that is meant to be completely private, but is now available to insecure worklet code. So I think I kind of talked a lot about all of these attacks, and I want to step back and look at the bigger picture here. The first is that privacy-preserving ad tech is hard. It's really difficult. I've gone through all the documentations and discussions, and the Privacy Sandbox API team has really put in a lot of effort to design it in a way that is privacy-preserving. But I will put it to you that privacy-preserving ad tech is an oxymoron. It's kind of impossible. And in order to satisfy the needs of both advertising platforms and marketers and obviously ad buyers, something's got to give. And this emerges in the form of all the escape hatches that are built inside the Privacy Sandbox API, which then allow you to exploit it and subvert the protections of the Privacy Sandbox API. The second point I want to make is that this attack surface is still large and unexplored. I think the web has a long history of hardening new features over time and continuously iterating them. As new standards are put out, bypasses are discovered, and then the standard is then further hardened. In the case of the Privacy Sandbox API, I think I get the sense that not enough research interest has been put into the Privacy Sandbox API, and a lot of it has now kind of subverted the assumptions of existing protections and mitigations in advertising technology. So, my encouragement to everyone is look into advertising technology. It's a large field that I think takes up a large percentage of the internet today, but I think it's going to be a lot more interesting than you think. So, there's still a lot more to do with regards to the Privacy Sandbox. For example, the client-side APIs, what I presented today is only a small portion of all the browser-side APIs. There's a Topics API, a Protected Audience API, Private Aggregation API, and I haven't even kind of dealt with fuzzing any of these APIs, so you may want to look into the actual code that implemented this in the Chrome and Chromium-based projects. The second is the aggregation service. There's a whole additional set of infrastructure that the Privacy Sandbox offers that advertising platforms can run in their own environments that is ostensibly meant to be a trusted execution environment that fetches and decrypts information about aggregate analytics data, but not actually leak that data directly to the advertising platform. This is a big question mark. As I've seen with the client-side APIs, there may be escape hatches, there may be issues, so there's a lot to do here. And the last is enrollment. So, the Privacy Sandbox API and the Privacy Sandbox is a walled garden. You have to register as a company or an advertising platform in order to use the attribution API, and this is done through a set of attestations that rely on public keys, for example. And the question is, if this can be subverted, and you can bypass this enrollment to then manipulate and abuse the Privacy Sandbox APIs. So, there's a lot more to do and a lot more research to do, so I hope this kind of sparks your interest as well. So, with that, I think I bring the presentation to an end. I hope this has given you a kind of brief background on the Privacy Sandbox, given you a bit more interest in advertising technology that tends to be ignored by researchers, and hopefully gives you some ideas of creative ways that you can use to attack and bypass privacy-preserving technology. If you have more questions, I have a website. I'm going to post the white paper there. I also do have a Twitter account, and I also have a book signing tomorrow with Nostalgia Press at 1pm. So, I hope to see you there. Thank you.