start	end	text
8360	13140	Hi everyone, thank you for attending our talk, 000 Day.
13180	21520	I don't know if you've heard or saw the news, it got a little bit of coverage, but this is the first time that we're actually disclosing the technical details.
21620	25680	It's going to be fun, it's going to be risky, and let's start.
25680	29660	So, I'm Gal, I'm the co-founder and CTO of Oligo Security.
29660	32860	With me is Avi, our number one ninja.
32860	37660	And really quickly about ourselves, before we start and begin.
39580	44940	Hi, I'm Avi, I'm an AI security researcher in the city office of Oligo.
44980	51760	I have around 10 years of experience in research and development, mostly researching AI these days.
51760	57020	And I love to climb mountains, so if you want to join me on the trip, let me know.
57500	60040	And with me is my awesome CTO.
60560	66440	Thank you, Avi, I'm paying you to say good things about me, so keep up with that.
66440	73320	So, I'm the founder and CTO of Oligo, I have 10 years of experience, checkpoint, hacking, breaking stuff, since I remember myself.
73460	82620	And not like Avi, I'm famous for being handsome or thinking like that, and I'm really good at looking at mountains in my Windows computer.
82820	98860	So, a quick agenda, what we're going to discuss today, what is the concept of port scanning and how it all started from 18 years ago, a very old issue that just keeps on recurring and recurring along the years, and we're going to deep dive into the history.
98860	112460	What is the actual private network access, this try to do a standout when all of the browsers should be using, but we'll see along the years what actually happened.
112460	129360	And then we're going to deep dive into the actual details of the 0000 day internals itself, and then we're going to demonstrate how we're leveraging that in order to RCE private internal applications that today are considered private.
129360	141280	And in the end, we're going to really deep dive into how each and every browser actually was dealing with that and the responsible disclosure and where we are right now with that.
141280	149360	So in order to really start, I'm going to pass it on to Awesome Avi, because he's the actual smart guy that did all of that.
149440	151420	And let's start.
153140	155240	Amazing, so thank you.
156100	158180	So client port scanning.
158240	161200	Who remembers this headline on Hacker News?
161840	164840	Yeah, so why is this website port scanning me?
165260	167080	Very good question.
167080	175040	Apparently eBay, not some script kiddie but a real company, tried to port scan their visitors as soon as they visit the website.
175300	178700	So how did they do it exactly?
178720	186560	And by the way, you will get this recording and we will share the presentation with you, so please try to be concentrated on the presentation.
187740	194460	Basically what they did is they used Glocalhost and they checked many types of ports.
194460	203160	I don't know if it's for monetization, for fingerprinting or for security reasons, but we really don't care because it should never happen, right?
203160	207780	Browsers should not communicate with Glocalhost if they're under a .com domain.
207820	210180	It's that simple, in my opinion at least.
210720	220100	So this is exactly what private network access, and I'll simply use PNA, and this is what it tries to solve at the end of the day.
220100	227360	So we have this notion of differentiating three distinctive networks.
227480	238800	The public network, which is the internet as we refer to the internet, which is a top-level domain like a .com, everything that's on the public internet.
238900	245800	Then there is the private network, which is the office, home network that we're connected to.
245860	249600	And finally there is the local device, so it is Glocalhost.
249600	252440	This figure is taken from Google's blog about PNA.
252440	254020	You should go read about it.
254020	260220	It's a really great initiative, and we'll understand why we need it these days more than ever.
261140	264740	Now, there are many ways to run a server, right?
264740	272940	We have the default, we have 0.0.0.0, or we simply have the Glocalhost bind address.
273020	278340	So they actually result in different behaviors, but I'm going to focus on the last two.
278340	289300	So whenever I'm referring to a local service, I'm referring to the last two figures, which are the 100.7.0.0.1, or literally the Glocalhost string.
289300	297420	So we have a service that listens on the machine's local network, the Lubec interface, and that's it.
297420	299840	Basically, we have many ways of running a server.
300400	312100	And to understand how we found everything, so let's jump back 18 years ago to understand why PNA is needed and why it was so hard to solve to this day.
312900	315980	So it all begins with a lack of standardization.
315980	320460	There is no real standard to follow, at least 18 years ago.
320500	323840	There was no HTTPS, like simply HTTP.
324520	336180	And this guy posted on Mozilla's forum on their security program the following headline that says that websites are trying to attack my router.
336500	341280	It's really weird, like as soon as I'm visiting the website, they try to attack my router.
341560	345080	And it's been happening for the last 18 years.
345260	348400	It's still open, as you can see, the issue is still open.
348400	352540	It is being updated, but without the ability to comment or anything, it's still there.
353760	360520	The idea is that the RFC should not, like, it claims that it should not behave this way.
360560	366900	And for some reason, browsers are being able to pass and dispatch HTTP requests to the local network.
367320	371400	And after a while, it says that it's being actively exploited in the wild.
371400	373940	Some of you might also remember that.
374600	379600	Real attacks, like targeting home routers, this is how they did it.
379600	383460	It's called drive-by-farming, great publication by Synopsys.
383460	387560	And the ability to load the script as soon as the website loads.
387880	391980	So this might sound really odd to you, like, this should never work today, right?
391980	397240	But 18 years ago, routers did not have HTTPS or self-signed certificates.
397760	404840	And the first figure, actually, would alter the DNS server of your home network using a simple HTTP request.
405400	407040	And it simply worked.
407040	418620	And not only it worked, it affected, like, thousands of, hundreds of thousands of home and office routers in large-scale attacks that targeted localhost.
418620	426640	And at the end of the day, you can see that all of those are using localhost or, like, internal interfaces.
428860	435880	And then Firefox tried to come up with a list of IPs.
435880	441460	IP segments and address spaces that are considered private.
441620	443360	It makes a lot of sense, right?
443360	445800	Now, do you notice something weird on this list?
448060	454320	So we'll get to that in a second, but someone mentioned that it's not Firefox-specific bug.
454320	455520	And he's probably right.
455520	458780	But he mentioned that it's not a vulnerability or an issue.
458780	461860	It's maybe a security enhancement and nothing more than that.
461860	466740	And then they understood that they also forgot 0.0.0.0.
467260	474160	And sadly, they added it, but nothing happened since that day.
474160	480560	So we're jumping back to eight years ago when Google started with a course, cross-origin resource sharing.
480560	489200	It's actually defining how websites should behave and how browsers should act when requesting resources from other domains.
489940	503100	And Google started this initiative to try to define the behavior of how browsers should or should not dispatch requests to these private network addresses.
503500	507460	So PNA is a standard that is still under ideation.
507460	509500	It's not finalized yet.
510040	514700	It's being led by Google, and as you can see, it's a draft community report.
514700	524660	And therefore, Firefox is waiting for this standard and targets it as depends-on-private-network-access, which is still not implemented in Firefox.
525340	532380	And basically, they wait for Chrome and the Chromium team to define the standard, make it stable in Chrome.
532380	536500	And only then they will adopt it to Firefox following a certain standard.
536500	541400	But they don't want to do it randomly or trusting on some gut feeling.
541400	543340	They want to implement a real standard.
544220	548100	Now, let's understand what is still allowed.
549100	551120	So they started PNA.
551120	552840	It took a long time to roll.
552840	556280	It's still not a mainstream component in Chrome.
556400	562740	It should have been available until Chrome 126.
562740	565700	But it got delayed several times.
566520	572180	And they even had to revert it at some point because they broke a lot of websites.
572180	574180	But their aim is very clear.
574180	579880	They want to mitigate CSRF attacks and DNS rebinding attacks to local addresses.
581660	586260	Now, they still have not decided how to treat 0.0.0.0.
586560	588180	This is the standard, by the way.
588180	588620	It's on GitHub.
588620	589780	You can look it up.
591060	595460	And they had to roll back some changes, as I said.
595460	605260	You can see that between some Chrome versions, they had to revert and then apply it back because many websites simply break within a night.
605260	611860	So the next time they did it, Google, they did it gradually and very carefully.
613200	618300	And as I said, they had to make some exceptions to 0.0.0.0.
618320	627240	So even although it was in defiance of specs, it was not a part of the RFC, developers must have wanted it and requested this behavior.
627680	632060	So as you can see, it's in defiance of specs, but seemingly common.
632940	636120	But what is this weird IP address anyway?
636120	641140	So if I'll ask two different people in this room, I'll probably hear two different answers.
641280	643780	And as you can see, it can have multiple uses.
645200	649940	So typically, it simply means this host on this network.
651200	655720	It should never be used as a destination IP address, according to the RFC.
655820	656880	You'll see it in a bit.
656880	665360	But a real use case of 0.0.0.0 is when we're doing a DHCP handshake and we still don't have an IP address.
665720	671420	And before the dynamic allocation, we want to identify ourselves somehow, so we have to use some IP.
671500	678980	But this is really the only use as an IP address, like handshakes and stuff like this, before you have a dynamically allocated IP.
680640	685840	And as I said, it should not be used as a target IP anywhere.
686180	693220	And by the way, Windows, I know we all have given them a hard time, but they were actually blocking it at the operating system level.
693220	696600	This is why it affects only macOS and Linux.
697220	704360	But this is basically a misunderstanding of the RFC or some non-correlative behavior.
705180	712320	So Chromium decided to add counters to Chrome to understand how many websites use this IP address.
712720	718560	So it was relatively small at first place, but we've seen it increasing with time.
719680	727140	This is the percent of pages that use 0.0.0.0 in AJAX or other mechanisms.
727340	738780	And basically, you can see that it's on the rise, maybe ten times, doubled itself ten times in under two years, or slightly more than two years.
738780	742240	But it is on the rise, and it should concern us all.
742680	748080	So this is the really interesting part of the presentation.
748420	750260	All of these are blocked.
750260	758080	Private network access tries to prevent us from accessing these domains where we have a .com domain.
758760	767340	But when we use 0.0.0.0, we manage to bypass all of those restrictions and access localhost and lubec.
767340	769480	So it's that simple.
769480	772600	It should be hard.
772600	777420	It should be terminated in the request level before it is being dispatched.
777420	781940	But we can access localhost and 107.0.0.1.
782860	800220	Now, everything that is HTTP that runs on these services, including port forwarding to Kubernetes, like some of us are developers, including myself, we all use HTTP port forwarding when working with remote pods and stuff like that, including operating system services,
800220	804040	so everything that runs on localhost on your machine is accessible.
804220	809000	There are plenty of default or non-default developer tools that use localhost.
809000	825240	And it also enables us to use the VPN, literally every network interface that is connected to the machine, which was used in the past for DNS rebinding to localhost, so you can use 0.0.0.0 instead of localhost, and DNS rebinding would still work.
825240	826480	We'll see it in a bit.
827420	839480	So to target it, we wanted to see how it behaves and whether it's really possible, so we've built a port scanner written in WebAssembly, but it uses JavaScript API, so it doesn't really matter.
839640	850280	And the idea is that it was able to see the open ports on my machine just by the error code that the browser returns to the JavaScript context.
850280	853280	So if it's a connection refused, you know nothing is there.
853280	856220	If there's an error, you know something is listening.
856240	857620	It's very simple.
858780	867640	And we use 0.0.0.0, but you can see in the sniffing with the wire shark that it's being redirected to localhost.
868220	871940	And here's the DNS rebinding notion.
871940	890300	So you have a subdomain that is being mapped to 0.0.0.0, so we've seen a lot of attacks in the history that used 127.0.0.1, but it is possible once again using 0.0.0.0.
892560	895280	Now, this gets me to ShadowRay.
895280	898620	This is the real reason we started with this research.
898620	915440	So after we've published ShadowRay, which was an attack campaign in the wild targeting AI workloads in a lot of big companies, it leverages a default behavior in Ray, if any of you know it.
915740	917960	Ray is like Kubernetes for AI.
917960	921980	So it enables you to scale and run Python applications.
921980	924620	I'm an early developer and a doctor myself.
924620	926800	I really love it.
926840	932080	And even OpenAI say out loud that they use it to train CGPT and their biggest models.
933540	946780	So in late 2023, we've seen this report by AnyScale, the developers and maintainers of Ray, and we've seen four CVEs that were taken care of and one disputed CVE, which is very, very interesting.
946780	957700	It simply discusses the ability of Ray to run arbitrary code because it's like an inherited part of Ray.
957700	959640	It is a desired capability.
959640	965220	It must have this capability to function because it's a job running library.
966060	975940	And therefore, they disputed the vulnerability that enables remote code execution because it's necessary and it's kind of by design, the way Ray is designed.
975940	982600	And Attacker leveraged it to run arbitrary code on clusters that are exposed to the Internet.
983240	986260	It got amazing coverage as well.
986260	987820	It was on Forbes.
987820	990560	And we asked ourselves the following question.
990560	994020	We know that Ray lacks authorization and authentication.
994300	999080	We know that it is usually running on local hosts when developers use it.
999080	1013860	And we try to understand whether our browser can load an external public website, which then can communicate with this local Ray cluster or service that is running locally on local host.
1015020	1021720	So we need to install Ray and have it running in the default constellation, no special flags or anything.
1021720	1030360	Then we have to visit the website and the website will invoke a post HTTP request to the API, triggering remote code execution.
1030760	1032980	And get this.
1032980	1034700	You only need to dispatch the request.
1034700	1035980	We don't care about the response.
1035980	1040480	And this is the whole idea of private network access.
1040720	1054320	So, of course, the cross-origin resource sharing was dealing mostly with which headers the response has and whether should I propagate it to the current context of JavaScript and load it under the current domain.
1054320	1058460	But we're really emphasizing the ability to dispatch requests.
1058460	1062540	And a single HTTP request is enough to trigger remote code execution.
1063640	1067180	Also important to mention that it's not limited to Ray.
1067180	1068280	It's only one use case.
1068280	1072320	We've seen many remote code execution vulnerabilities on local host.
1072320	1076660	But for the sake of time, we're only showing this on the presentation.
1076880	1078960	But there is the full blog at the end.
1079080	1081320	So I have a phishing email.
1081320	1083400	Not the most successful one.
1083400	1087320	But I'm clicking here and being redirected to this website.
1087980	1092460	Now, this is the JavaScript that targets the remote code execution.
1092460	1094560	You can see that there's a net cut.
1095800	1100840	Socket that is being opened to a remote server, which is the attacker-controlled server.
1101060	1108560	It is being used with mode no calls, which sends the request and will simply return an opaque response.
1108560	1110620	So I cannot see the response.
1110620	1112280	But as we said, we don't really care.
1112280	1115580	We just want to send it and trigger remote code execution.
1116500	1119080	And finally, we get a response.
1119080	1120320	It looks like an error.
1120320	1122600	But you can see that it's 200 okay.
1123220	1125880	So apparently the job really ran.
1125980	1128840	And you'll see it in a second.
1128840	1130560	But this is all it takes.
1130960	1134140	Just one HTTP request to reach the server.
1134140	1135740	We don't care about the response.
1135740	1137840	And it's more than enough.
1138460	1148580	So every time you visit the page, it will trigger this specific payload, which just prints the environment variables and prints exploited to the screen.
1148660	1153380	But here is a reverse shell that is being opened as soon as I'm clicking on an email.
1153820	1156040	So on the right, I have Ray running.
1156040	1160640	I'm importing it and running Ray.init without any special parameters.
1160640	1163360	This is how developers usually use Ray.
1163360	1166300	And you can see that it binds on localhost.
1168260	1170360	There is a Ray's dashboard.
1170380	1173660	And it should reflect the jobs that are currently running.
1174360	1178380	Now, on the left, I'll open a socket.
1179400	1186340	And listen for connection on the certain port that matches the payload of the attack.
1187520	1199880	Now, as soon as I'm clicking on this link, you can see that a reverse shell is opened to the left terminal, which gives me access to the local machine from VPS somewhere on the Internet.
1200880	1203660	You can see that the Netcat is really running in Ray.
1203760	1209640	And I use it to run arbitrary commands on my personal computer.
1211460	1212920	And that's it, basically.
1212920	1214700	It got a lot of coverage.
1214700	1217240	So remote execution with a single click.
1217400	1219260	And as I said, it's not limited to Ray.
1220580	1224000	But it got a lot of coverage.
1224120	1225460	And for a reason.
1226120	1229860	Now, we did a responsible disclosure with the browsers.
1230200	1233360	And they had to introduce breaking changes.
1233360	1235460	Some of them are doing it more gradually.
1235560	1241680	But the idea is that we've actually managed to coordinate all the browsers together.
1241680	1247020	So they will not zero day each other by releasing a fix ahead of others.
1247920	1250260	Here's the proof on each of the browsers.
1250520	1254880	So the same payload can be used in each and every one of them.
1258540	1260120	And let's begin with Safari.
1260120	1262500	So Safari did an amazing job.
1262500	1263980	All of them did an amazing job.
1263980	1270900	But Safari simply mitigated it in the browser level before PNA is actually implemented in Safari.
1271900	1273980	You all know WebKit, I guess.
1273980	1277140	So WebKit is open source that Safari is based on.
1277140	1279120	And they changed 23 files.
1279120	1280780	They added a lot of tests.
1280780	1285020	And they did an amazing job on blocking it in Safari's level.
1285020	1286580	But not limited to Safari.
1286580	1291360	But actually every WebView on watchOS or iPad, it doesn't matter.
1291360	1292700	It's all WebKit based.
1292700	1294880	So they did a really amazing patch here.
1294880	1296160	And great job.
1296920	1302440	And you can see that they literally checked that the address contains only zeros.
1302440	1303760	They have this property.
1303760	1309040	So sorry, but we added like an if clause on every HTTP request in the world.
1309280	1312320	Not proud of it, but it's the way it is.
1312820	1314960	And there's Chromium.
1315160	1319220	Chromium, as I said, they are the leaders of private network access.
1320320	1327440	So they proposed a long time ago, even when it's only started, to add these headers to the backend services.
1328300	1334320	And later on, these headers can be used in the server level to mitigate those attacks.
1334320	1342880	But they decided to deprecate 000 before private network access completely rolls out to the browser.
1342920	1344460	And there's even our report here.
1344460	1348100	And they literally say that it can be used for DNS rebinding attacks.
1348200	1353820	And PNA protection can be bypassed using this special IP address on macOS and Linux.
1353860	1356040	And it should never be used in practice.
1356040	1358160	It should never be used.
1359160	1369320	And as I said, they added the counters and they say out loud that malware leverages this attack to specific developer toolkits.
1369460	1371120	And again, our bug.
1373060	1374300	And there's Firefox.
1374300	1376660	Firefox also did an amazing job.
1377040	1381440	They don't add PNA right away because it's not standardized yet.
1381440	1382440	It's not ready.
1382440	1386600	But when it will be, they're definitely positive towards adding PNA.
1386620	1390100	And they did block it in fetch level.
1390100	1392020	Like, who knows fetch in JavaScript?
1392020	1394500	It's the way to do HTTP requests.
1394640	1396960	They literally changed the RFC.
1397460	1403300	And they proposed to block 000 whenever a target IP is 000.
1403300	1407640	Simply drop the HTTP request.
1407660	1410920	And then browsers will have to comply with a new fetch standard.
1410920	1412400	And this is the way things work.
1413700	1415660	Now, what can we expect?
1416240	1423520	So, I expect that many open source maintainers and developers will add PNA headers to their services.
1423520	1426740	So, they won't be attacked from this attack vector.
1427140	1430400	Eventually, this IP address will be blocked in all browsers.
1431040	1437320	And I think that now people, at least I hope, will treat localhost as not really local anymore.
1437320	1441840	We can make these assumptions of being executed in a trusted environment.
1441840	1449000	Because as we've seen, a browser can have routing capabilities and can reach our localhost interfaces.
1449280	1455320	So, HTTPS, core, CSRF tokens, authorization, all of those are a must also in local projects.
1455320	1457080	So, please don't make those assumptions.
1458340	1459720	Now, we're almost done.
1459720	1461480	But a cool thing I wanted to share.
1461480	1465240	So, you know these port scanners online that scan certain websites?
1465240	1469920	So, if you use, like, loopback or localhost, it will fail.
1469920	1473960	But you can make them port scan themselves using 0.0.0.0.
1476040	1476840	Yeah.
1476840	1479300	Many people forget about this special IP, as we said.
1479300	1481760	A lot of different use cases.
1482920	1484980	And that's it, basically.
1485640	1488980	And it gets me to the conclusion, which I'll hand back to Gal.
1488980	1490660	And thank you so far.
1494050	1495630	He deserves it.
1498830	1500590	So, let's conclude what we see.
1500590	1503510	First of all, Avi is awesome, right?
1503690	1509610	He's breaking the browsers, making them actually talk to each other, and start to actually build the standard.
1509610	1522170	We saw how an 18-year-old bug that people thought is actually already over, DNS rebinding, stuff that we all thought are actually, like, dead already, are actually being actively used.
1522170	1525010	I don't know if you saw this 100,000 website.
1525010	1528990	I can tell you, honestly, that probably 100% of them are malicious.
1529370	1546010	And this whole concept that we've been trying to do for years, and, like, calls and all of those mitigations, in the end, by a simple, super logical bug that just enables everything once again, we can see that those attacks will keep on occurring.
1546010	1550830	And this is why we think this is a subject that needs to be called out.
1550830	1561470	People should be aware that no matter if they do have a WAF or a firewall of a false sense of safety, that our application is actually secured behind a private network.
1561470	1567070	This is where we come and show, look, attackers are also looking for those type of things.
1567070	1572430	They are really enjoying from the fact that there isn't one standard, and it can be abused.
1572510	1586570	And this is why we will keep seeing those stuff again, and why we should all, as a community, really look for other ways and other mitigations on the application itself, not trusting the old ways that we saw.
1587110	1598210	And, of course, we're going to have some Q&A, but, again, feel free to reach out on whatever, like, Twitter, whatever, Elon will call it tomorrow morning.
1598250	1603070	We would love to answer anything you might have.
1603070	1606010	And, again, this is just one example.
1606070	1615830	And you've seen how big companies abused it for financial reasons, or attackers have been leveraging that to hack internal networks.
1615830	1625890	But the whole concept of just one packet that can hack any internal application, it's a really risky thing, and this is why we are here to really mention it out.
1625890	1629710	So, again, thank you very much, everyone, for attending this talk.
1629710	1631790	We will share everything online.
1631790	1634490	And, again, happy DEF CON.
1634490	1635390	Thank you, everyone.
