start	end	text
780	2460	Hello, everyone.
4880	9660	Hi, everyone. Thank you for attending our talk, 0000 Day.
9900	14100	I don't know if you've heard or saw the news. It got a little bit of coverage,
14100	18020	but this is the first time that we're actually disclosing the technical details.
18160	22240	It's going to be fun. It's going to be risky. And let's start.
22240	26160	So, I'm Gal. I'm the co-founder and CTO of Oligo Security.
26160	29220	With me is Avi, our number one ninja.
29220	34160	And really quickly about ourselves before we start and begin.
36040	41480	Hi, I'm Avi. I'm an AI security researcher in the city office of Oligo.
41480	45280	I have around 10 years of experience in research and development,
45280	48040	mostly researching AI these days.
48140	53520	And I love to climb mountains, so if you want to join me on the trip, let me know.
53880	56560	And with me is my awesome CTO.
56560	62940	Thank you, Avi. I'm paying you to say good things about me, so keep up with that.
62940	66620	So, I'm the founder and CTO of Oligo. I have 10 years of experience,
66620	69820	checkpoint hacking, breaking stuff since I remember myself.
69940	75120	And not like Avi, I'm famous for being handsome or thinking like that.
75120	79120	And I'm really good at looking at mountains in my Windows computer.
79260	82780	So, a quick agenda, what we're going to discuss today.
82780	88180	What is the concept of port scanning and how it all started from 18 years ago?
88180	92660	A very old issue that just keeps on recurring and recurring along the years.
92660	95060	And we're going to deep dive into the history.
95420	98360	What is the actual private network access?
98360	105640	This try to do a standout when all of the browsers should be using,
105640	108900	but we'll see along the years what actually happened.
108900	115820	And then we're going to deep dive into the actual details of the 000 day internals itself.
115820	118840	And then we're going to demonstrate how we're leveraging that
118840	125800	in order to RCE private internal applications that today are considered private.
125800	130720	And in the end, we're going to really deep dive into how each and every browser
130720	134360	actually was dealing with that and the responsible disclosure
134660	137680	and where we are right now with that.
137680	142520	So in order to really start, I'm going to pass it on to Awesome Avi,
142520	145800	because he's the actual smart guy that did all of that.
145840	147840	And let's start.
149480	151680	Amazing. So thank you.
152420	157620	So client port scanning, who remembers this headline on Hacker News?
158220	161260	So why is this website port scanning me?
161580	163480	Very good question.
163480	167540	Apparently eBay, not some script kiddie, but a real company,
167540	171400	tried to port scan their visitors as soon as they visit the website.
171700	175060	So how did they do it exactly?
175080	179220	And by the way, you will get this recording and we will share the presentation with you,
179220	182880	so please try to be concentrated on the presentation.
184100	190780	Basically what they did is they used localhost and they checked many types of ports.
190780	195840	I don't know if it's for monetization, for fingerprinting, or for security reasons,
195840	199480	but we really don't care because it should never happen, right?
199480	204080	Browsers should not communicate with localhost if they're under a .com domain.
204140	206480	It's that simple, in my opinion at least.
207060	212540	So this is exactly what private network access, and I'll simply use PNA,
212540	216380	and this is what it tries to solve at the end of the day.
216380	223680	So we have this notion of differentiating three distinctive networks.
223780	230080	The public network, which is the internet as we refer to the internet,
230080	235100	which is a top-level domain like a .com, everything that's on the public internet.
235200	242080	Then there is the private network, which is the office, home network that we're connected to.
242140	245600	And finally there is the local device, so it is localhost.
245600	250320	This figure is taken from Google's blog about PNA. You should go read about it.
250320	256460	It's a really great initiative, and we'll understand why we need it these days more than ever.
257460	261020	Now, there are many ways to run a server, right?
261020	269160	We have the default, we have 0.0.0.0, or we simply have the localhost bind address.
269320	274520	So they actually result in different behaviors, but I'm going to focus on the last two.
274520	280420	So whenever I'm referring to a local service, I'm referring to the last two figures,
280420	285540	which are the 100.7.0.0.1, or literally the localhost string.
285540	293660	So we have a service that listens on the machine's local network, the Lubec interface, and that's it.
293660	295790	Basically we have many ways of running a server.
296700	301820	And to understand how we found everything, so let's jump back 18 years ago
301820	308320	to understand why PNA is needed and why it was so hard to solve to this day.
309060	312200	So it all begins with a lack of standardization.
312200	316660	There is no real standard to follow, at least 18 years ago.
316720	320040	There was no HTTPS, like simply HTTP.
320800	327980	And this guy posted on Mozilla's forum on their security program the following headline
327980	332420	that says that websites are trying to attack my router.
332740	337520	It's really weird, like as soon as I'm visiting the website, they try to attack my router.
337940	341320	And it's been happening for the last 18 years.
341440	344580	It's still open, as you can see, the issue is still open.
344580	348760	It is being updated, but without the ability to comment or anything, it's still there.
350340	356660	The idea is that the RFC should not, like, it claims that it should not behave this way.
356660	363100	And for some reason, browsers are being able to pass and dispatch HTTP requests to the local network.
363560	367580	And after a while, it says that it's being actively exploited in the wild.
367580	370120	Some of you might also remember that.
370740	375760	Real attacks, like targeting home routers, this is how they did it.
375760	379620	It's called drive-by-farming, great publication, by Synopsys.
379620	383660	And the ability to load the script as soon as the website loads.
383660	388140	So this might sound really odd to you, like, this should never work today, right?
388140	393400	But 18 years ago, routers did not have HTTPS or self-signed certificates.
393940	401240	And the first figure, actually, would alter the DNS server of your home network using a simple HTTP request.
401540	403160	And it simply worked.
403600	411900	And not only it worked, it affected hundreds of thousands of home and office routers in large-scale attacks.
412860	414800	That targeted localhost.
414800	423000	And at the end of the day, you can see that all of those are using localhost or internal interfaces.
424900	432040	And then Firefox tried to come up with a list of IPs.
432400	437560	IP segments and address spaces that are considered private.
437740	439480	It makes a lot of sense, right?
439480	441960	Now, do you notice something weird on this list?
443840	446180	So, we'll get to that in a second.
446180	450440	But someone mentioned that it's not a Firefox-specific bug.
450440	451700	And he's probably right.
451700	454860	But he mentioned that it's not a vulnerability or an issue.
454860	457980	It's maybe a security enhancement and nothing more than that.
458760	462980	And then they understood that they also forgot 0.0.0.0.
463680	470260	And sadly, they added it, but nothing happened since that day.
470260	476700	So, we're jumping back to eight years ago when Google started with the course, cross-origin resource sharing.
476700	485260	It's actually defining how websites should behave and how browsers should act when requesting resources from other domains.
486100	499040	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.
499520	503500	So, PNA is a standard that is still under ideation.
503540	505440	It's not finalized yet.
506020	507900	It's being led by Google.
507900	510660	And as you can see, it's a draft community report.
510660	520640	And therefore, Firefox is waiting for this standard and target it as depends on private network access, which is still not implemented in Firefox.
521560	528320	And basically, they wait for Chrome and the Chrome team to define the standard, make it stable in Chrome.
528320	532500	And only then they will adopt it to Firefox following a certain standard.
532500	537400	But they don't want to do it randomly or trusting on some gut feeling.
537400	539280	They want to implement a real standard.
540280	544080	Now, let's understand what is still allowed.
545140	547080	So, they started PNA.
547080	548820	It took a long time to roll.
548820	552240	It's still not a mainstream component in Chrome.
552340	558620	It should have been available until Chrome 126.
558680	561660	But it got delayed several times.
562600	568200	And they even had to revert it at some point because they broke a lot of websites.
568200	570160	But their aim is very clear.
570160	575920	They want to mitigate CSRF attacks and DNS rebinding attacks to local addresses.
577700	581800	Now, they still have not decided how to treat 000.
582460	585800	This is the standard, by the way. It's on GitHub. You can look it up.
586880	591420	And they had to roll back some changes, as I said.
591420	597720	You can see that between some Chrome versions they had to revert and then apply it back
597720	601280	because many websites simply break within a night.
601280	607840	So, the next time they did it, Google, they did it gradually and very carefully.
609120	613680	And as I said, they had to make some exceptions to 000.
614180	619300	So, even though it was in defiance of specs, it was not a part of the RFC,
619300	623140	developers must have wanted it and requesting this behavior.
623580	627960	So, as you can see, it's in defiance of specs, but seemingly common.
628820	632020	But what is this weird IP address anyway?
632020	637040	So, if I'll ask two different people in this room, I'll probably hear two different answers.
637180	639680	And as you can see, it can have multiple uses.
641180	645840	So, typically, it simply means this host on this network.
647340	651540	It should never be used as a destination IP address, according to the RFC.
651700	658740	You'll see it in a bit, but a real use case of 000 is when we're doing a DHCP handshake
658740	661180	and when we still don't have an IP address.
661700	665540	And before the dynamic allocation, we want to identify ourselves somehow,
665540	667260	so we have to use some IP.
667380	672460	But this is really the only use as an IP address during handshakes and stuff like this
672460	675180	before you have a dynamically allocated IP.
676920	681780	And as I said, it should not be used as a target IP anywhere.
682040	685880	And by the way, Windows, I know we all have given them a hard time,
685880	689060	but they were actually blocking it at the operating system level.
689060	692500	This is why it affects only macOS and Linux.
693020	700240	But this is basically a misunderstanding of the RFC or some non-correlative behavior.
701020	704700	So Chromium decided to add counters to Chrome
704700	708160	to understand how many websites use this IP address.
708480	714400	So it was relatively small at first place, but we've seen it increasing with time.
715440	723000	This is the percent of pages that use 000 in AJAX or other mechanisms.
723100	726440	And basically, you can see that it's on the rise,
726440	732800	maybe ten times, double itself ten times in under two years,
732800	734600	or slightly more than two years.
734600	738000	But it is on the rise and it should concern us all.
738560	743820	So this is the really interesting part of the presentation.
744260	746320	All of these are blocks, right?
746320	750680	Private network access tries to prevent us from accessing these domains
750680	753820	when we are under a .com domain.
754780	759280	But when we use 000, we manage to bypass all of those restrictions
760080	763120	and access localhost and lubec.
763120	765240	So it's that simple.
765240	768360	It should be hard.
768360	773180	It should be terminated in the request level before it is being dispatched.
773180	777780	But we can access localhost and 107.0.0.1.
778700	783260	Now, everything that is HTTP that runs on these services,
783260	787820	including port forwarding to Kubernetes, like some of us are developers, including myself,
787820	793220	we all use HTTP port forwarding when working with remote pods and stuff like that,
793220	796020	including operating system services,
796020	799740	so everything that runs on localhost on your machine is accessible.
800000	804740	There are plenty of default or non-default developer tools that use localhost.
804740	808940	And it also enables us to use the VPN,
808940	812460	literally every network interface that is connected to the machine,
812460	815480	which was used in the past for DNS rebinding to localhost,
815480	820980	so you can use 000 instead of localhost and DNS rebinding would still work.
820980	822180	We'll see it in a bit.
823120	828540	So to target it, we wanted to see how it behaves and whether it's really possible,
828540	832400	so we've built a port scanner written in WebAssembly,
832400	835180	but it uses JavaScript API, so it doesn't really matter.
835440	840440	And the idea is that it was able to see the open ports on my machine
840440	846080	just by the error code that the browser returns to the JavaScript context.
846080	848980	So if it's a connection refused, you know nothing is there.
848980	851900	If there is an error, you know something is listening.
851960	853320	It's very simple.
854480	859000	And we use 000, but you can see in the sniffing with the wire shark
859000	863380	that it's being redirected to loopback, to localhost.
864180	867600	And here's the DNS rebinding notion.
867600	873860	So you have a subdomain that is being mapped to 000.
873980	881080	So we've seen a lot of attacks in the history that used 127.0.0.1,
881080	885700	but it is possible once again using 000.
888240	890940	Now, this gets me to ShadowRay.
890940	894260	This is the real reason we started with this research.
894260	900300	So after we've published ShadowRay, which was an attack campaign in the wild
900300	904860	targeting AI workloads in a lot of big companies,
904860	911080	it leverages a default behavior in Ray, if any of you know it.
911360	913580	Ray is like Kubernetes for AI.
913580	917620	So it enables you to scale and run Python applications.
917620	920240	I'm an early developer and a doctor myself.
920240	922440	I really love it.
922500	927720	And even OpenAI say out loud that they use it to train CGPT and their biggest models.
929160	935840	So in late 2023, we've seen this report by AnyScale, the developers and maintainers of Ray.
935840	940620	And we've seen four CVEs that were taken care of and one disputed CVE,
940620	942600	which is very, very interesting.
942600	948400	It simply discusses the ability of Ray to run arbitrary code
948400	953280	because it's like an inherited part of Ray.
953280	955220	It is a desired capability.
955220	960820	It must have this capability to function because it's a job running library.
961780	965460	And therefore they disputed the vulnerability that enables remote code execution
965460	971860	because it's necessary and it's kind of by design, the way Ray is designed.
971860	978160	And Attacker leveraged it to run arbitrary code on clusters that are exposed to the internet.
979120	981500	It got amazing coverage as well.
981500	983440	It was on Forbes.
983500	986120	And we asked ourselves the following question.
986120	989580	We know that Ray lacks authorization and authentication.
989880	994600	We know that it is usually running on local hosts when developers use it.
994880	1001520	And we try to understand whether our browser can load an external public website,
1001520	1009300	which then can communicate with this local Ray cluster or service that is running locally on local host.
1010300	1015020	So we need to install Ray and have it running in the default constellation.
1015020	1017240	No special flags or anything.
1017280	1023260	Then we have to visit the website and the website will invoke a post HTTP request to the API
1023260	1025720	triggering remote code execution.
1026240	1030700	And get this, you only need to dispatch the request.
1030700	1036140	And this is the whole idea of private network access.
1036420	1043720	So of course the cross-origin resource sharing was dealing mostly with which headers the response has
1043720	1049880	and whether should I propagate it to the current context of JavaScript and load it under the current domain.
1049880	1053560	But we are really emphasizing the ability to dispatch requests
1053560	1058120	and a single HTTP request is enough to trigger remote code execution.
1059100	1062700	Also important to mention that it's not limited to Ray.
1062700	1063780	It's only one use case.
1063780	1067820	We've seen many remote code execution vulnerabilities on local host.
1067820	1072140	But for the sake of time, we're only showing this on the presentation.
1072400	1074420	But there is the full blog at the end.
1074580	1078800	So I have a phishing email, not the most successful one.
1078800	1082800	But I'm clicking here and being redirected to this website.
1083480	1087820	Now this is the JavaScript that targets the remote code execution.
1087820	1094280	You can see that there's a netcat, a socket that is being opened to a remote server,
1094280	1096220	which is the attacker-controlled server.
1096500	1104100	It is being used with mode no calls, which sends a request and will simply return an opaque response.
1104100	1106080	So I cannot see the response.
1106120	1107740	But as we said, we don't really care.
1107740	1110940	We just want to send it and trigger remote code execution.
1111980	1114440	And finally, we get a response.
1114480	1117800	It looks like an error, but you can see that it's 200 OK.
1117800	1121380	So apparently the job really ran.
1121380	1124280	And you'll see it in a second.
1124280	1125980	But this is all it takes.
1126300	1129660	Just one HTTP request to reach the server.
1129660	1131180	We don't care about the response.
1131180	1133040	And it's more than enough.
1134220	1138840	So every time you visit the page, it will trigger this specific payload,
1138840	1143960	which just prints the environment variables and prints exploited to the screen.
1144060	1146460	But here is a reverse shell that is being opened.
1146460	1148720	As soon as I'm clicking on an email.
1149380	1151460	So on the right, I have Ray running.
1151460	1156020	I'm importing it and running Ray.init without any special parameters.
1156020	1158600	This is how developers usually use Ray.
1159120	1161680	And you can see that it binds on localhost.
1163740	1169000	There is a Ray's dashboard, and it should reflect the jobs that are currently running.
1169760	1173800	Now, on the left, I'll open a socket.
1174920	1181720	And listen for connection on the certain port that matches the payload of the attack.
1182820	1188620	Now, as soon as I'm clicking on this link, you can see that a reverse shell is opened to the left terminal.
1189640	1195240	Which gives me access to the local machine from VPS somewhere on the Internet.
1195820	1199040	You can see that the Netcat is really running in Ray.
1199060	1205020	And I use it to run arbitrary commands on my personal computer.
1206760	1209820	And that's it, basically. It got a lot of coverage.
1209820	1212620	So remote code execution with a single click.
1212700	1216520	And as I said, it's not limited to Ray, so therefore all the buzz.
1216520	1220700	But it got a lot of coverage and for a reason.
1221280	1225180	Now, we did a responsible disclosure with the browsers.
1225880	1228680	And they had to introduce breaking changes.
1228680	1230680	Some of them are doing it more gradually.
1230920	1237020	But the idea is that we've actually managed to coordinate all the browsers together.
1237020	1242260	So they will not zero-day each other by releasing a fix ahead of others.
1243160	1245580	Here is the proof on each of the browsers.
1245680	1250120	So the same payload can be used in each and every one of them.
1253620	1255420	And let's begin with Safari.
1255420	1259320	So Safari did an amazing job. All of them did an amazing job.
1259320	1266200	But Safari simply mitigated it in the browser level before PNA is actually implemented in Safari.
1267140	1269320	You all know WebKit, I guess.
1269320	1272440	So WebKit is open source that Safari is based on.
1272440	1275920	And they changed 23 files. They added a lot of tests.
1275920	1280120	And they did an amazing job on blocking it in Safari's level.
1280120	1281760	But not limited to Safari.
1281760	1286640	But actually, every web view on watchOS or iPad, it doesn't matter.
1286640	1287860	It's all WebKit-based.
1287860	1290260	So they did a really amazing patch here.
1290260	1291420	And great job.
1292240	1297700	And you can see that they literally checked that the address contains only zeros.
1297700	1299000	They have this property.
1299200	1304480	Sorry, but we added an if clause on every HTTP request in the world.
1304780	1307540	Not proud of it, but it's the way it is.
1308040	1310200	And there's Chromium.
1310200	1314600	Chromium, as I said, they are the leaders of private network access.
1315820	1322500	So they proposed a long time ago, even when it only started, to add these headers to the backend services.
1323740	1329380	And later on, these headers can be used in the server level to mitigate those attacks.
1329380	1338100	But they decided to deprecate 000 before private network access completely rolls out to the browser.
1338100	1339640	And there's even our report here.
1339640	1343220	And they literally say that it can be used for DNS rebinding attacks.
1343400	1348900	And PNA protection can be bypassed using this special IP address on macOS and Linux.
1349040	1351080	And it should never be used in practice.
1351560	1353160	It should never be used.
1354460	1357160	And as I said, they added the counters.
1357160	1364060	And they say out loud that malware leverages this attack to specific developer toolkits.
1364340	1366140	And again, our bug.
1368100	1369500	And there's Firefox.
1369500	1371800	Firefox also did an amazing job.
1372200	1376600	They don't add PNA right away because it's not standardized yet.
1376600	1377600	It's not ready.
1377600	1381740	But when it will be, they are definitely positive towards adding PNA.
1381820	1385320	And they did block it in fetch level.
1385320	1387200	Like, who knows fetch in JavaScript?
1387200	1389600	It's the way to do HTTP requests.
1389820	1392060	They literally changed the RFC.
1392060	1398460	And they propose to block 000 whenever a target IP is 000.
1398460	1402800	Simply drop the HTTP request.
1402880	1406040	And then browsers will have to comply with a new fetch standard.
1406040	1407340	This is the way things work.
1408900	1410920	Now, what can we expect?
1411360	1418580	So, I expect that many open source maintainers and developers will add PNA headers to their services.
1418580	1421720	So they won't be attacked from this attack vector.
1422280	1425460	Eventually, this IP address will be blocked in all browsers.
1426360	1432380	And I think that now people, at least I hope, will treat localhost as not really local anymore.
1432480	1436840	We can make these assumptions of being executed in a trusted environment.
1436840	1444040	Because as we've seen, a browser can have routing capabilities and can reach our localhost interfaces.
1444400	1450280	So HTTPS, core, CSRF tokens, authorization, all of those are a must also in local projects.
1450280	1452220	So please don't make those assumptions.
1453520	1456560	Now, we're almost done, but a cool thing I wanted to share.
1456560	1460280	So you know these port scanners online that scan certain websites?
1460560	1464920	So if you use, like, loopback or localhost, it will fail.
1464920	1468480	But you can make them port scan themselves using 000.
1471160	1474340	Yeah, many people forget about this special IP, as we said.
1474340	1476760	A lot of different use cases.
1478060	1480000	And that's it, basically.
1480280	1485280	And it gets me to the conclusion, which I'll hand back to Gal, and thank you so far.
1489100	1490840	He deserves it.
1493870	1495630	So let's conclude what we've seen.
1495630	1498390	First of all, Avi is awesome, right?
1498570	1504630	He's breaking the browsers, making them actually talk to each other, and start to actually build a standard.
1504630	1517210	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.
1517210	1519990	I don't know if you saw this 100,000 website.
1520050	1524010	I can tell you, honestly, that probably 100% of them are malicious.
1524010	1541010	And this whole concept that we've been trying to do for years, 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.
1541010	1545830	And this is why we think this is a subject that needs to be called out.
1545830	1556490	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.
1556490	1562050	This is where we come and show, look, attackers are also looking for those type of things.
1562050	1567410	They are really enjoying the fact that there isn't one standard, and it can be abused.
1567410	1581530	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.
1582070	1593130	And, of course, we're going to have some Q&A, but, again, feel free to reach out on whatever, like, X, Twitter, whatever, Elon will call it tomorrow morning.
1593130	1598350	We would love to answer anything you might, like, have.
1598350	1600990	And, again, this is just one example.
1601050	1610870	And you've seen how big companies abused it for financial reason, or attacker been leveraging that to hack internal network.
1610870	1617670	But the whole concept of just one packet that can hack any internal application, it's a really risky thing.
1617670	1620850	And this is why we are here to really mention it out.
1620850	1624670	So, again, thank you very much, everyone, for attending this talk.
1624670	1629410	We will share everything online, and, again, happy DEF CON.
1629410	1630270	Thank you, everyone.
