start	end	text
0	2040	Good morning DEF CON.
2800	8900	I'm Vanish and I hope you are awake and you didn't party too much yesterday.
9620	22840	And I'm here just to ruin your fate in Linux, in a subsystem, in a Linux subsystem that usually you think it's secure.
24560	33700	When most people think about ABPF, they think observability, they think networking.
34360	37120	I think Ring Zero Playground.
37680	55080	Today we are going to systematically fuzz and analyze ABPF subsystems and I'm going to show you exactly how to turn the world's most trusted sandbox into your personal kernel backdoor.
55540	57120	That's the idea.
58620	64480	It is what we are going to accomplish in the next 45 minutes almost.
64500	71740	First I show you why ABPF's attack surface is absolutely massive.
72380	77020	And it's getting worse for every kernel update.
78260	82280	Second, we'll dive into state-of-the-art fuzzing.
82280	88360	The technique that actually work against modern ABPF subsystems.
88360	97860	Third, I work it through the Leviathan, the framework that I'm presenting today, that it's a systematic exploitation framework.
98320	107100	Fourth, and this is the fun part, we do live fuzzing and exploitation of ABPF subsystems.
107120	110080	And finally, we'll talk about defense.
110680	116060	Because someone has to clean up the mess that we are doing.
117240	123140	But before we jump into the actual technical meat, let me introduce myself.
124040	125580	I'm Agostino.
125580	127120	I'm from Italy.
127640	128940	This means two things.
128940	131680	Sorry for my English, first thing.
131680	135000	Second thing, I don't like pineapple on pizza.
136180	144220	So just to be clear, I'm a security researcher with over 15 years of experience.
144220	154820	I've done red teaming, instant response, reverse engineering and I'm currently working mostly on Windows and Linux kernel exploitation.
155680	160920	I'm the author and the maintainer of the framework that I'm presenting today that is Leviathan.
160920	163000	It is going to be open source.
163580	170200	The VM dragon's layer framework that is being presented yesterday for VM protect samples.
170200	177880	And I'm also maintaining a fork, actively maintaining a fork for the spider foot project.
178720	183140	My research focus is actually everything that is weaponizable.
183860	187120	And together with my three cats, we review code.
187400	195440	When I'm not doing that, I actually love scuba diving because I love the exploration part.
196800	205540	But let's talk why ABPF should terrify every security professional in this room.
206140	216160	We are diving deep into the attack surface that most people completely ignore or totally misunderstand.
217740	221620	ABPF started as a simple packet filter.
222040	224880	Basically a fancy way to drop packets.
225480	234600	Today it's a complete virtual machine running with ring zero privileges in every Linux kernel.
234720	243520	It can access arbitrary kernel memory, manipulate system calls and hook into any kernel subsystem.
244260	246700	And here is the beautiful part.
247020	251260	It's marked as safe and sandboxed.
251500	262520	Every major cloud provider, every container platform, every observability tool is built on top of ABPF nowadays.
263980	267120	The security implications of this are massive.
267520	274740	We are talking about ring zero execution with direct kernel memory access.
275480	285800	ABPF programs can establish persistence that survives reboots, system updates and most forensic analysis.
285800	287760	That's the worst part.
287800	295400	They operate below hypervisor, below security monitoring, below everything.
296160	303900	And the best part, this technology is shipped by default everywhere.
304040	306080	Ubuntu, Red Hat, AlmaLinux.
306080	310900	Every major Linux distribution is shipping ABPF and is enabling by default.
312700	317620	Understanding the exploitation pipeline in this case is critical.
318480	322500	Every ABPF program follow this path usually.
322760	334460	User program that goes to the ABPF bytecodes that goes to the verifier that goes just in time compiler and you have kernel execution.
334980	339800	Each stage is a potential attack vector.
340560	349860	At program construction we craft malicious bytecode designed to trigger the verifier edge case.
350400	359380	During verification we can exploit bound checking errors, type confusion bugs and state tracking failure.
360420	372680	JIT compilation gives us architecture specific vulnerabilities because we can run that on x86 R and RISC-V.
373060	380760	Finally kernel execution provides arbitrary memory access and privilege escalation.
380760	383440	That's the complete path that we can follow.
385240	387280	Let's start with the verifier.
387600	389920	The verifier is our primary target.
390920	397040	And I have to be honest, it's one of the most beautiful piece of code that I have ever seen.
397040	402860	It's almost 15,000 lines of C code that is really complex.
402900	407240	And I think that they spend a lot of time going through that because it's really amazing.
407240	410100	If you want to learn C that's the way to go.
413480	422520	The verifier is actually trying to prove that arbitrary user programs are safe to run in the kernel.
422880	424700	But there is the kicker.
425800	434600	Analyzing it, what I've done, I cataloged over 200 interesting patterns in this code.
435280	451440	We are talking about specific function that can lead to integer over four patterns, type confusion, state corruption vectors, loop bound verification bypass and stack base overflow.
453700	459780	I started doing this analyzing the history of the vulnerability on a BPF.
459880	462140	So I started from the past.
462140	468660	I analyzed different CVs from 2020, 2021, 2022 and later on.
469040	473840	Trying to find a way to have a pattern recognition.
474540	480140	So to systematically find similar bugs inside the verifier.
480460	484200	The pattern in this case is clear.
484360	491220	Verifier complexity equals explorability.
492220	497100	Every new BPF feature increased the attack surface.
499020	509600	Based on this I started generating a framework detection signature that is part of the Leviathan framework .
509800	513820	Let me show you some of the actual pattern that I'm using.
514360	524860	I'm sharing pattern 47 for instance that show bound confusion in range tracking using specific BPF instruction that trigger integer overflow.
525300	537700	The pattern 73 for instance demonstrate type confusion via other arguments where we can exploit the verifier failure to properly track the pointer type.
537700	539040	And then we have also other patterns.
539040	541300	There are more than 200 of them.
542640	544660	These are just usable.
547380	555880	JIT compilation vulnerabilities are particularly nasty because they are architecture specific.
556500	564160	The same BPF byte code can trigger different vulnerabilities on different architecture.
564820	577480	We are talking about specific functional level bugs, instruction encoding issue, optimization bugs, branch prediction problems, macro speculation bugs and so on.
577480	582820	These give us multiple attack vectors in this vulnerability class.
585780	592620	Our exploitation strategies leverage this architectural difference.
593920	601460	Translation bugs occur when the same BPF byte code generate vulnerable machine code on specific architecture.
601500	607660	Optimization error happens when performance improvement breaks security guarantee.
608200	613740	Platform specific attacks target architecture dependent speculation.
614620	617660	Branch prediction or instruction encoding.
617660	622500	Those are some of the things that we are working on.
623660	630160	The cross platform research help us find vulnerability pattern that works across multiple JIT.
630160	632480	So multiple just-in-time compilers.
633400	634860	It's not just one exploit.
634860	637140	It's an exploit family completely.
637380	640140	From one exploit, for instance, you can get four.
642280	645240	And then we get the ABPF maps.
645240	651300	The ABPF maps provide persistent storage and inter-program communication.
651640	657000	But they are also a massive attack vector.
657860	663200	Hash maps may suffer from collision attacks and time inside channels.
663940	668740	Arrays have bound checking issue sometimes.
668860	671540	And integer overflow vulnerabilities.
671540	679880	LRU maps can enable cache timing attacks and memory pressure exploitation.
679880	685140	And we have also other per CPU maps, stack trace maps and so on.
686760	690760	But the real fun starts with the shared state management.
691660	696740	ABPF maps enable race condition between programs.
696760	703000	Synchronization bypass, memory management attacks via map operations.
703120	711300	Information leakage through access patterns and performance versus security trade-off in which the performance always wins.
712340	717740	Modern kernels have hundreds of map operations.
718020	722560	And each one with a different security property.
723360	727520	It's a race condition gold mine if you look at it.
728960	731920	But let's now check the helpers.
731920	741140	The ABPF helper function are the interface between the ABPF program and the kernel functionality.
741280	749020	There are over 200 helper functions that have kernel privileges.
750000	754760	Network helper enable manipulation for instance.
754760	762800	File system helper provide the exploitation vector.
762800	770840	The crypto helpers can help you understand and manage the crypto operations.
772700	779460	Tracing helpers can give you some information that are leaked from the process itself.
779880	783460	Each helper function is a potential privilege escalation vector.
784260	789600	We are just setting up and understanding what's the attack surface of ABPF.
791890	796330	Helper function exploitation focuses on validation bypass technique.
796570	802330	Input sanitization failure allow malforming data to reach kernel APIs.
803610	806750	We can have parameter confusion.
807510	811210	We can have privilege boundary violation and so on.
811290	814790	We can have also side channel exploitation in this case.
817110	821850	The point is this is the attack surface.
822590	827430	Traditional fuzzing doesn't work against ABPF.
827930	833810	Because the verifier is smart and it's too smart for the traditional fuzzing.
834750	837230	Random mutation gets blocked immediately.
837230	849730	So I noticed that 99.99 percent of the request or the program generated with random mutation gets blocked.
852290	858190	All the valid programs get rejected before reaching the verifier box.
858870	865330	There is no coverage of complex state tracking vulnerabilities and we just waste the source.
867050	872050	Static analysis in this case is equally useless.
872890	878210	It cannot model the verifier complex state machine behavior.
878770	885830	We get path explosion in interprocedural analysis with ABPF semantics.
886490	892450	Just the existing tool lack the ABPF specific vulnerability patterns.
892450	894250	That's one of the issues.
894630	899870	The complexity is just why for the traditional approach.
901670	904650	Manual analysis doesn't scale either.
904850	913450	You need deep expertise across verifier, JIT, helper subsystems and it takes months per vulnerability.
913910	918670	And you simply cannot keep pace with the rapid ABPF subsystem evolution.
918670	923430	So we need something that is smarter and is faster.
925350	932530	Because the kernel developers are adding new features faster than the manual researcher can analyze them.
935220	944700	So the fundamental problem that I found during the analysis of ABPF is the missing state awareness.
945380	948920	Traditional tools don't understand verified internal state tracking.
948920	955660	They cannot target specific vulnerability class like bound calculation errors for instance.
955760	959920	And there is no systematic approach to JIT compiler.
959920	961580	I didn't find it.
962780	966200	That's why we need something else.
966860	981160	And this brings to the part two of the talk in which we describe a little bit the methodology and the framework that are developed to overcome this limitation.
984780	987600	This is the key innovation of the framework.
987600	997360	Instead of generating random programs, we generate programs that specifically target no vulnerability class in the verified state tracking.
998060	1001100	Bound calculation and type confusion logic.
1001100	1003780	So we specifically generate those.
1004360	1009880	This is a surgical precision against a complex state machine.
1011660	1014380	And let me introduce you to the Leviathan.
1015060	1028060	The Leviathan framework will be open source by the end of the month for some disclosure issues.
1029060	1038860	But so far it's something that I'm trying to share open source with the entire community.
1040100	1045500	We have a verified state tracking with advanced state machine analysis for bug discovery.
1045500	1047200	This is one of the features.
1047200	1057640	We have bound calculation and expectation covers verified errors into arbitrary primitives.
1057640	1064820	We have bypass technique that can leverage information leakage.
1064920	1073800	And we have chains completely built that go from memory corruption to full compromise.
1074620	1078760	Multi architecture just in time compiler.
1078760	1085320	Bugs checking across all the platform that are enabled in ABPF.
1086040	1092460	And helper function validation bypass that can provide API level security convention.
1094400	1101080	Let me give you some of the specific algorithm that has been implemented here.
1101580	1111760	We have a coverage guided fuzzing that can achieve almost 90 percent of basic block coverage potentially.
1112740	1119440	Differential fuzzing enables cross kernel version bug discovery.
1120040	1125580	We have a neural guided fuzzing that provide machine learning driven program generation.
1125580	1130020	So the entire program generator are machine learning generated.
1130020	1131560	Not LLM.
1133560	1135640	The old style machine learning.
1136200	1140080	Semantic aware fuzzing using target verifier.
1140080	1141820	Verified state model.
1142260	1146520	And edge guided fuzzing optimize control flow exploration.
1146520	1147860	That's the idea.
1150060	1155520	We convert the verified bypass into arbitrary primitives.
1156260	1162280	We use targeted information leaks for KSLR bypass and kernel based discovery.
1163060	1169240	We employ heap grooming and kernel object manipulation for memory corruption chains.
1169460	1177580	And we develop cross architecture reliability so our exploit techniques works across platform.
1179140	1181800	That's why we focus on reliability.
1181800	1190500	So the exploit can work consistently across kernel versions and are more stable.
1191580	1199960	We do multistage validation because we test or you can test using the framework across all the kernel version directly.
1202200	1203820	These are some metrics.
1204040	1206980	Here the real performance number.
1206980	1216960	In 24 hours we can generate roughly 2 million programs that are compilable.
1220040	1239260	We achieve over almost 70 percent of basic block coverage and edge coverage during the four weeks of the first run of the framework.
1241160	1255000	So we cover also the architecture but all the specific architecture from x86 to ARM to RISC-V and power PC with roughly a decent amount of percentage.
1257100	1262840	Let's do a technical deep dive on some of the exploitation technique that we have.
1263440	1267340	Let me show you the real bound calculation vulnerability pattern.
1267600	1272680	The verifier bound calculation logic here is vulnerable to an integer overflow.
1273680	1278720	That is vulnerable as an integer overflow can occur during the range validation.
1279580	1284320	This simplified code shows how the verifier check conditions.
1284900	1289300	But integer overflow can make this check pass when it shouldn't.
1289300	1293300	This is one of the possible vulnerabilities you can have.
1293340	1295000	But how we exploit it?
1295000	1298360	It is how we can exploit this.
1298400	1302520	We craft specific ABPF program to trigger overflow.
1302900	1308740	We set the condition then in this case specific case we set the offset to 200.
1308740	1314460	The result is an overflow that bypassed the bound check giving us arbitrary memory access.
1315200	1319320	This specific instruction sequence triggered the vulnerability reliably.
1319420	1321540	That's one of the key points.
1322180	1328880	From this bound bypass we develop the exploitation primitives.
1329420	1333920	We manipulate the verifier state to achieve control and memory offsets.
1334020	1339580	We convert the bound bypass into reliable memory disclosure for arbitrary reads.
1340220	1346860	And we extend the technique for control and memory corruption to get arbitrary memory writes.
1348660	1355940	We use the information disclosure for the KSLR bypass and the kernel based discovery.
1355960	1359780	This is the fundamental for a full privilege escalation.
1362730	1376250	The second type of bugs that I'm showing you is the type of confusion attack that exploit the verifier type tracking across different code paths.
1377350	1383870	Here is a simplified example of the verified code.
1384010	1394670	And you can see here that the verified has two paths and it can be confused looking for one path or another based on the condition.
1397110	1403990	In this particular bug class we have four main type confusion exploitation categories.
1405250	1411050	Point and integer confusion treats pointer values as integer for arithmetic operation.
1412150	1414190	Map type confusion access.
1415030	1421530	And we have contest type error and cross path type issue in this case.
1423510	1431550	Using these primitives we craft program that confuse the verifier type taking through the state manipulation.
1432090	1437630	We exploit type inconsistencies during contest switching.
1438250	1443310	And we use type confusion to access restricted helper function.
1443410	1445810	That's one of the key point.
1446490	1450810	And we leverage type confusion from memory layout attacks and corruption.
1451790	1455510	This way we have multiple paths to kernel compromise.
1457010	1459350	Let's talk a little bit about the JIT.
1459390	1466050	Our JIT compiler exploitation engine targets multiple architectures systematically.
1466050	1474710	We can target x86, JIT bugs, ARM, MIPS, RISC 5, power PC and so on.
1475090	1481450	The framework automatically analyzes the compilation across different architecture type.
1482330	1485610	To find platform specific vulnerabilities.
1487690	1490610	But let's go to the fun part.
1491830	1495570	Let's check how the framework works.
1499780	1503720	First of all, wait, let me open it.
1512940	1517040	Now this is the first run in which we do fuzzing.
1517040	1518300	Just fuzzing.
1519680	1525240	And these are against a vulnerable machine by design.
1525440	1528440	Because we just make the point across for the demo.
1529080	1540060	We load up old machine learning models and we integrate them inside the platform.
1541920	1546880	We have a bunch of pattern categories and we start the fuzzing.
1547360	1554380	In this case, we are just generating a few programs just then for the sake of the demo.
1555560	1568300	Those programs are designed to exploit some of the patterns found in the database based on the machine that the system is analyzing.
1573510	1584710	It generates ten samples in this case, but over those ten samples, for him, just six were actual vulnerability.
1585570	1588190	So we have a 60% success rate.
1588330	1603430	At this point he tried to compile it and see if they work on the system because the platform is monitoring the entire kernel to see if he gets a crash condition.
1605710	1609710	And he starts to analyze the entire framework.
1610430	1629310	He starts to analyze the machine behavior and we just find out that among those six just three were actual vulnerability.
1629950	1632550	This is just by design.
1632550	1639090	This is just something that was planned for the demo, but it works beautifully on every machine.
1639790	1647110	So if you have a vulnerable machine, this just generates a C code that is a POC to get the vulnerability tested.
1648350	1657250	But that's not the unique, you can have also other nice feature here.
1658010	1668190	One of the feature you can have, actually the framework can analyze ABPF programs that interact, that should interact with ABPF.
1668390	1671350	So let's make point across.
1671390	1678270	For instance, you have Calico, you have Cilium, you have this kind of program that interact with ABPF.
1678270	1680630	All those programs can be analyzed with the framework.
1680630	1684050	So all ABPF systems can be analyzed directly.
1685050	1697090	And you are analyzing them using dynamic train tracking and symbolic execution to help guide the analysis of the framework over those specific samples.
1697730	1701430	In this case, we just have a bound checker.
1701430	1702390	That's it.
1705760	1707880	And the framework is analyzing it.
1709320	1712920	And it found a bunch of path that it can follow.
1715140	1717980	It starts solving constraint with Zeta 3.
1719520	1723520	And you can actually check.
1723520	1726840	And after the result with Zeta 3, it starts the taint.
1727940	1740180	When you finish up with the taint, it mixes up all the results and analyze them using the machine learning models to see if the ABPF software is actually vulnerable.
1741920	1750160	In this case, for this specific example, we just have three vulnerabilities found.
1750600	1758120	Two high confidence and one is medium for the sake of the demo.
1760980	1762740	But that's not it.
1763960	1768880	The framework is able to do the complete exploitation chain.
1769200	1773880	So it starts from the fuzzing that we have done in the first demo.
1773960	1781760	It took the three vulnerability found and it generated the primitives from that.
1784240	1792160	It starts analyzing it and using the machine learning models, it tried to weaponize it directly.
1793440	1801940	So you can have C code after this stage that is actually pretty complete.
1803200	1811220	And you can, interacting with the framework, you can actually test the exploits on different platforms.
1811220	1815880	In this case, I just had a bunch of machines to test it on.
1815880	1821620	It's connecting over those machines and testing if the exploit works.
1821620	1824560	The entire chain works over those machines.
1825500	1829160	And it come out with an average success rate.
1829160	1835300	In this case, we have roughly 90 percent of success rate for the exploits.
1853890	1858250	So what we have seen so far.
1859370	1864110	What we have seen is a state of fuzzing targeting specific verifier.
1864630	1866330	Vulnerability classes.
1866390	1874450	For instance, what we have seen in the first three vulnerabilities that we found.
1874990	1883030	We are doing live verified bypass discovering in bound calculation logic.
1884490	1894610	We have seen the complete development of the exploit and also the fact that we can analyze an ABPF system directly with the framework.
1894610	1897470	An ABPF program directly with the framework.
1898270	1909390	That can give us some insight on pre-escalation and actually we can get some juicy CV if you would like to see that way.
1911290	1915270	But let's talk about some defensive recommendation.
1916590	1922550	I would like to highlight the run time protection that you can have.
1922550	1930750	The run time protection requires an input validation and capability restriction.
1931890	1935150	For all the function in the outputs.
1935150	1937250	So that's something that you need to monitor.
1938270	1951690	You need to have real time detection of the exploitation attempts on the ABPF subsystem and you need to monitor a little bit better with the auditing the system a little bit better.
1951690	1961310	Because so far what I have seen is that with ABPF a lot of people trust it and they just don't check the logs of ABPF.
1961310	1963970	They just don't audit ABPF.
1963970	1970830	But ABPF can be easily exploited and abused.
1973560	1979660	So what's the future of the framework?
1980300	1990800	From a future research direction I'm going to develop more on state modeling using machine learning.
1991820	1995180	Cross component analysis mostly.
1996180	2004880	I try to provide formal verification for some parts in particular for the quantum in the post quantum crypto.
2005500	2009420	And also hardware integration.
2009580	2012560	But there is something that is really juicy here.
2015160	2017280	Windows is accepting.
2017280	2022660	It starts to work on ABPF integration.
2023840	2029600	Means that we have another attack surface that we can use.
2030700	2037560	And this is the actual scheme of the ABPF subsystem that Windows is implementing.
2037560	2041820	It's a little bit different compared to Linux.
2042820	2056780	But in this case, as you can see from the slides, we have an alternative way to interact with the kernel in a Windows environment using ABPF.
2056780	2062080	That's something that should scare you from a certain perspective.
2062080	2064680	But it's a new research opportunity.
2066820	2070520	So let me conclude with some key takeaways.
2072540	2082120	We develop state of the world methodologies that provide a good improvement in vulnerability discovery efficiency.
2083660	2087400	The systematic exploitation framework is Leviathan.
2087400	2094280	Enable reliable exploitation chain usually in a decent amount of cases.
2096500	2099700	And we also have some ordering recommendation .
2099700	2104680	You need to monitor it more and you need to check the usage of ABPF.
2106800	2113800	That concludes our journey to ABPF exploitation chains.
2114620	2123040	And the framework will be open source, will be shared at the end of the August.
2123900	2134100	Because from the frameworks came out during the first run roughly half a dozen CVE on ABPF subsystem.
2134100	2139560	So working with maintainer we are trying to fix it.
2140600	2145820	And we are trying to provide some guidance on how to improve the ABPF security.
2147580	2149440	Thank you for your time.
2149440	2151060	I hope you are enjoying DEF CON.
2151360	2155460	And I'm here if you want to ask some questions.
2155660	2156400	Thank you.
