researchers find an unfixable bug in EVERY ARM cpu

Low Level Learning
10 Jul 202409:48

Summary

TLDRThis video delves into a fascinating CPU vulnerability that exploits speculative execution and memory tagging in ARM architecture. The attack, reminiscent of Spectre and Meltdown, leverages cache invalidation to bypass security measures, allowing information leakage. The presenter, Ed, breaks down complex concepts like memory corruption, buffer overflows, and memory tagging, explaining how researchers have identified a method to leak memory tags within the V8 JavaScript engine sandbox, highlighting the intricacies of this advanced exploit.

Takeaways

  • πŸ’‘ Computers can 'see' the future to some extent through speculative execution, which is a method used to predict and preload memory addresses to avoid cache misses.
  • πŸ” The video discusses a memory corruption vulnerability that exploits CPU's speculative execution to bypass ARM's security architecture.
  • πŸ‘€ The presenter, Ed, introduces the topic with a focus on cybersecurity and software security, encouraging viewers to subscribe for more content.
  • πŸ“š The script mentions 'Smashing the Stack', a foundational paper on buffer overflows that have been a major source of hacks since the 1990s.
  • πŸ›‘οΈ ARM's chip architecture has implemented features like memory tagging in ARMv8 and ARMv9 to enhance security against memory corruption vulnerabilities.
  • πŸ”‘ Memory tagging involves adding a specific number or tag to a pointer, which the CPU checks to ensure it matches metadata on each load and store operation.
  • πŸ”„ The script explains how pointers work, including their role in virtual memory and how they are used to translate virtual memory addresses to physical memory addresses.
  • 🚫 Memory tagging is designed to prevent attacks like use-after-free by recoloring freed memory addresses with different tags, causing exceptions if incorrectly accessed.
  • πŸ•΅οΈβ€β™‚οΈ The researchers discovered a method to leak memory tags through speculative execution, which can undermine the security provided by memory tagging.
  • πŸ’» The attack, named 'MTE Leak', operates within the V8 sandbox, which is used for running JavaScript, and the researchers found multiple 'TIC tag gadgets' that can be exploited.
  • 🌐 The video concludes by emphasizing the complexity and significance of the paper, urging viewers to read the original research for a deeper understanding.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is the discussion of a memory corruption vulnerability that allows bypassing a major feature of the ARM computer instruction set, which is related to memory tagging and speculative execution.

  • What are the two infamous bugs mentioned in the video that broke the internet around 2016-2017?

    -The two infamous bugs mentioned are Spectre and Meltdown, which are related to CPU vulnerabilities.

  • What is the purpose of memory tagging in ARM architecture?

    -Memory tagging in ARM architecture is a security feature that adds a specific number or tag to a pointer to prevent memory corruption attacks. If the tag is altered, the CPU will crash at runtime.

  • How does a buffer overflow work in the context of memory corruption?

    -A buffer overflow occurs when data is written past the boundaries of a buffer, potentially overwriting adjacent memory locations such as the return pointer, which can allow an attacker to take control of the program flow.

  • What is a pointer in computer architecture?

    -A pointer in computer architecture is a variable that stores the memory address of another value or object. It is used as an index into tables, which is part of the virtual memory system.

  • What is speculative execution and why is it used?

    -Speculative execution is a technique where the CPU predicts the path a program will take and preloads memory addresses into the cache to avoid cache misses and speed up execution.

  • How does the attack described in the video exploit speculative execution?

    -The attack exploits speculative execution by creating a guess pointer and a test pointer with the same memory tag. It then uses the speculative execution to check if the guessed tag is correct by timing whether the test pointer has been cached.

  • What is a cache invalidation side channel?

    -A cache invalidation side channel is a method used by attackers to leak information about the CPU's cache state, which can be used to infer the execution flow or data values.

  • What is a 'TIC tag gadget' mentioned in the video?

    -A 'TIC tag gadget' is a snippet of code that can be used to leak memory tags by exploiting speculative execution and cache invalidation side channels.

  • How did the researchers find TIC tag gadgets in the V8 VM?

    -The researchers identified TIC tag gadgets in the V8 VM by looking for code snippets that perform speculative execution and cache checks, which can be used to leak ARM V8 tags.

  • What is the significance of the attack being able to bypass hardware memory protection?

    -The significance is that it demonstrates a sophisticated method of exploiting CPU vulnerabilities, even within hardware-enforced security measures like ARM's memory tagging, to potentially execute memory corruption attacks.

Outlines

00:00

πŸ’‘ CPU Speculative Execution and Memory Corruption Vulnerability

This paragraph introduces the concept of how CPUs can 'see' the future through speculative execution, which is a method that allows the CPU to predict and preload memory addresses to improve performance. However, this feature has been exploited to bypass security features in ARM's instruction set architecture. The video discusses a memory corruption vulnerability that leverages this speculative execution to undermine ARM's security architecture, similar to the Spectre and Meltdown vulnerabilities that emerged around 2016-2017. The video aims to explain the technical aspects of this attack for viewers with varying levels of experience in cybersecurity and computer architecture.

05:02

πŸ”’ Memory Tagging and Its Role in Security

The second paragraph delves into the specifics of memory tagging, a security feature introduced by ARM in its ARMv8 and RV9 specifications. Memory tagging involves appending a unique tag to a pointer, which the CPU checks during load and store operations to ensure data integrity. The paragraph explains how this feature is designed to prevent buffer overflows and use-after-free vulnerabilities, which have been common attack vectors in software security. It also discusses the concept of virtual memory and how pointers work, including how ARM uses reserved bits in pointers for memory protection features like memory tagging and pointer authentication codes. The paragraph concludes with a mention of the video's sponsor, LLL Academy, which offers courses in assembly and C programming.

Mindmap

Keywords

πŸ’‘CPU

CPU stands for Central Processing Unit, which is the primary component of a computer that performs most of the processing inside the computer. In the context of the video, the CPU is discussed in relation to how it 'looks into the future' through speculative execution, which is a technique used to improve performance by predicting future operations. The video also mentions a vulnerability in CPU cash invalidation that allows attackers to bypass security features.

πŸ’‘Memory Corruption

Memory corruption refers to a type of software bug where a program writes data outside the bounds of allocated memory, leading to unpredictable behavior or security vulnerabilities. The video discusses how memory corruption vulnerabilities, such as buffer overflows, can be exploited to take control of a program by altering the return pointer, which is a fundamental aspect of many hacks since the 1990s.

πŸ’‘ARM

ARM is a company that designs processors and related technologies, including the ARM architecture used in various devices. The video highlights ARM's efforts to enhance security through features like memory tagging in ARMv8 and ARMv9. These features aim to prevent memory corruption attacks by adding metadata to pointers, which can cause the CPU to crash if tampered with.

πŸ’‘Memory Tagging

Memory tagging is a security feature that involves adding a tag or a specific number to the end of a pointer. This tag is checked by the CPU during each load and store operation to ensure that the pointer and its metadata match. The video explains how memory tagging can prevent attacks like use-after-free, where data is accessed after it has been freed, by changing the tag of the memory address to a different color.

πŸ’‘Buffer Overflow

A buffer overflow is a common type of security vulnerability where a program writes more data to a buffer than it can hold, causing data to overflow into adjacent memory. The video references the seminal paper 'Smashing the Stack' by Aleph One, which discusses how buffer overflows can be exploited to change the return pointer and execute malicious code, highlighting its significance in historical hacks.

πŸ’‘Virtual Memory

Virtual memory is a memory management technique that provides the illusion to a program that it has access to more memory than is physically available by using a translation from virtual to physical memory addresses via page tables. The video explains that pointers are essentially indexes into tables that manage virtual memory, allowing programs to think they have access to the entire memory map.

πŸ’‘Speculative Execution

Speculative execution is a method used by CPUs to improve performance by predicting future operations and preloading data into cache. The video discusses how speculative execution can lead to security vulnerabilities, such as the one exploited in the attack described, where the CPU's prediction process can be used to leak information about memory tags.

πŸ’‘Cache Invalidation

Cache invalidation is the process of marking data in a CPU cache as no longer valid, which can be exploited in security attacks. The video mentions cache invalidation as a side channel that can be used to leak information about the CPU, similar to the Spectre and Meltdown vulnerabilities that emerged in 2016 and 2017.

πŸ’‘Use After Free

Use after free is a type of memory corruption vulnerability that occurs when a program accesses memory after it has been freed. The video explains how memory tagging can help prevent use after free attacks by changing the tag of the freed memory, causing an exception if the old pointer is used.

πŸ’‘V8 Sandbox

The V8 sandbox is a virtual machine used to run JavaScript in a secure environment, isolating it from the rest of the system. The video discusses how researchers found 'tic tag gadgets' in the V8 sandbox that can be used to leak ARM V8 tags, demonstrating the potential for attacks even within secure environments.

πŸ’‘Pointer Authentication Code

Pointer authentication code is a security feature that involves cryptographically signing pointers. If a pointer is overflowed, the signature is invalidated, making the pointer invalid. The video mentions pointer authentication code as another example of how ARM uses leftover bits in pointers for memory protection.

Highlights

CPUs use speculative execution to improve performance by predicting future paths and preloading memory addresses.

Speculative execution vulnerabilities can lead to memory corruption and bypass security features, as seen in Spectre and Meltdown.

The attack discussed exploits cache invalidation as a side channel to leak CPU information.

Memory corruption vulnerabilities, like buffer overflows, allow hackers to control return addresses and execute malicious code.

ARM has added memory tagging in ARMv8 and ARMv9 to enhance security by checking pointers and metadata tags on each load and store.

Memory tagging involves adding a specific tag to a pointer, and if this tag is changed, the CPU crashes at runtime.

Speculative execution can bypass memory tagging protections by predicting future code paths and preloading memory.

Attackers can use speculative execution to leak memory tags by timing cache fills and guessing correct tags.

The TIC-TAG attack uses speculative execution to break ARM's memory tagging security.

The attack can be performed inside the V8 JavaScript sandbox, making it highly versatile and dangerous.

The researchers found multiple TIC-TAG leak gadgets in the V8 VM that can be exploited.

TIC-TAG gadgets involve address control, speculative branching, and cache fill checks to leak memory tags.

Pointer authentication codes (PACs) in ARM cryptographically sign pointers to prevent tampering.

Memory tagging also protects against use-after-free attacks by recoloring memory tags upon deallocation.

Speculative execution attacks can invalidate hardware memory protections, demonstrating a critical security flaw.

Transcripts

play00:00

can computers see the future yes sort of

play00:02

in this video we're talking about how

play00:04

the way that CPUs look into the future

play00:06

actually presented a memory corruption

play00:08

vulnerability that allows people to

play00:10

bypass a major feature of the arm

play00:13

computer instruction set this attack is

play00:15

one of those crazy ones and I want to

play00:17

talk about this one so badly because any

play00:20

attack that uses a cash invalidation as

play00:23

a side channel to leak information about

play00:25

the CPU is already cool enough think

play00:28

about Spectre and meltdown right those

play00:30

bugs that broke the internet around 2016

play00:33

2017 time period but on top of it being

play00:35

a bug in a cash invalidation it is also

play00:39

speculative execution and Via this

play00:41

attack they're able to break one of the

play00:42

major pieces of arms security

play00:45

architecture now if you're new here hi

play00:47

my name is Ed this is Ol learning a

play00:48

channel where I make videos about cyber

play00:50

security software security and all kinds

play00:51

of other cool stuff so if you like that

play00:53

or just want to hang out hit that sub

play00:54

button I really appreciate it also yes I

play00:56

got a haircut it's uh it's a little long

play00:59

little something weird going on here

play01:00

okay I do want to give my hats off to

play01:01

the researchers here all the people are

play01:03

named here in white please go take some

play01:05

time after this video go read their

play01:07

paper 18 pages of computer architecture

play01:10

goodness binary exploitation goodness in

play01:12

this video I want to make this paper a

play01:14

little more digestible for people who

play01:15

may not have as much experience with how

play01:17

CPU memory Works how binary exploitation

play01:19

works and all that kind of stuff so what

play01:21

is memory tagging what are buffer

play01:22

overflows what what is all the stuff

play01:24

about well to understand how this attack

play01:26

works we have to start at the basics

play01:28

hackers like to exploit these sing

play01:30

called memory corruption vulnerabilities

play01:32

the basic one that everyone knows about

play01:33

is a buffer overflow right this paper

play01:35

here by alf1 called smashing the stack

play01:37

from front and profit which is a paper

play01:39

within Frack the hacker E from a million

play01:41

years ago uh talks about basically hey

play01:44

if we are able to right past the bounds

play01:47

of a buffer in C we can use that to take

play01:50

control of The Code by changing the

play01:52

return pointer this guy lf1 enumerates

play01:54

that if we are able to control the

play01:56

return address of a program by setting

play01:58

this value to a hacker controlled value

play02:01

we can put code in that location and run

play02:03

malicious code this has been the basis

play02:06

of the majority of the hacks that have

play02:07

happened over 70% of them since the

play02:09

1990s and this is the thing that

play02:11

companies are trying to prevent by

play02:13

either secure code or secure

play02:15

architecture now arm the chip

play02:18

architecture designer that licenses out

play02:20

the arm spec has added several features

play02:23

in armv8 and rv9 one of them being this

play02:26

idea of memory tagging so memory tagging

play02:29

is theide aide of just like it sounds

play02:31

putting a tag or a specific number at

play02:34

the end of a pointer by putting that

play02:37

number there you effectively make a a

play02:40

special number that if it gets changed

play02:42

the CPU will crash at runtime the CPU

play02:45

checks that the pointer and the metadata

play02:46

tags on each load and store match now

play02:50

you're probably wondering wait aren't

play02:51

pointers memory addresses like how are

play02:53

they able to just put a random value in

play02:55

a pointer well pointers actually aren't

play02:57

all that magic they actually have a

play02:59

specific function that they do when you

play03:01

look at a 64-bit pointer for example

play03:04

there are a few things that are

play03:05

happening on the inside of this pointer

play03:06

but basically almost the entire pointer

play03:09

is a series of indexes into tables this

play03:12

index into table system is known what is

play03:14

called virtual memory that allows a

play03:16

program to think that it has access to

play03:18

all the memory on the CPU by translating

play03:22

these virtual memory addresses to a

play03:23

physical memory address via page tables

play03:26

we're able to give a program the

play03:28

illusion that it has access to the

play03:30

entire memory map meanwhile it doesn't

play03:32

actually it's a specific memory address

play03:34

that get gets mapped into a pointer now

play03:37

the entire pointer isn't actually used

play03:39

there are certain bits that are reserved

play03:41

for special purposes or that don't

play03:43

actually do anything in the pointer and

play03:44

so arm has taken advantage of these

play03:46

leftover bits and use them to do

play03:49

specific memory protection elements one

play03:51

of them being memory tagging another

play03:53

example is the pointer authentication

play03:55

code where effectively the CPU will sign

play03:58

the pointer cryptographically and if you

play04:00

overflow it you invalidated the

play04:02

signature and therefore the pointer is

play04:03

invalid also real quick this video is

play04:05

sponsored by none other than me if you

play04:07

want to learn to code in assembly or C

play04:09

or learn to do Network code in C please

play04:11

go check out my website L level Academy

play04:13

the courses are on sale right now for

play04:14

the summer go check it out if you want

play04:16

to learn to code in the C language you

play04:18

can get a free preview with the arrays

play04:20

lesson here if you want to go learn to

play04:21

code in assembly you can get a free

play04:22

lesson with the load operations lesson

play04:24

right here please go check him out I

play04:26

honestly believe that if you want to be

play04:27

a better programmer you got to learn the

play04:28

fundamentals where do you learn the

play04:30

fundamentals C and assembly on low-level

play04:33

Academy back to the video memory tagging

play04:36

stuff memory tagging an arm also

play04:38

prevents against certain attacks like

play04:39

use after freeze this place where you

play04:41

have data in a heap location for example

play04:43

you free it but accidentally access it

play04:46

later the way it works is actually

play04:47

pretty cool and this graphic here does a

play04:49

really good job of explaining it so we

play04:50

have this character pointer here that

play04:52

gets allocated 16 bytes when we allocate

play04:55

it with 16 bytes using an mte compliant

play04:58

allocator like the one on Android for

play04:59

example we have we can call this a

play05:01

particular color right now the memory is

play05:04

blue now what happens is we either can

play05:06

overflow this data or we can delete it

play05:09

we can free it and when we do that we

play05:11

recolor the data to a different color so

play05:13

this memory address now has a different

play05:16

tag if we were to in the future use the

play05:19

old pointer the use after free but it

play05:22

still has that original tag the blue

play05:24

color this will throw a CPU exception

play05:26

now the important part here is if the

play05:28

hacker is a able to reveal the tag and

play05:31

put the tag back in place this defeats

play05:34

the entire security of the system the

play05:35

idea is that the memory tag which is 16

play05:38

bits it hides in the first 16 bits of

play05:40

the pointer itself if we are able to

play05:42

leak that tag then this entire system

play05:45

falls apart now this is where the TIC

play05:47

tag paper gets really really interesting

play05:50

now what they do is they use this thing

play05:52

called speculative execution now we all

play05:55

want our computers to run as fast as

play05:56

possible Right ideally our computers

play05:58

would run our programs it would load and

play06:01

store all of our memory and it would

play06:02

never take what is called a cash Miss

play06:04

where effectively when it looks up a

play06:06

memory address if the memory isn't there

play06:08

in cash it has to go out to random

play06:10

access memory and load that into cash

play06:12

now that is very expensive it causes the

play06:14

program to slow down so there has been

play06:16

this push to do this thing called

play06:18

speculative execution where your CPU

play06:21

will actually run the instructions that

play06:23

are ahead of the current program counter

play06:25

it will go into the future and predict

play06:27

what path you're going to go down and

play06:29

try to preload that memory address to

play06:32

put it into cash so that when you

play06:34

actually get there you don't miss the

play06:36

cash now like I said in the beginning of

play06:37

the video there have been a variety of

play06:39

memory corruption attacks or leaks uh

play06:42

that have come out of speculative

play06:44

execution and spoiler alert this is how

play06:47

the mte leak works now I'm going to zoom

play06:49

in here to their graphic I want to

play06:51

highlight this because this is really

play06:52

really interesting so the way that it

play06:54

works is they create a guess pointer and

play06:57

a test pointer that both both live

play07:00

within the same 16b block so that they

play07:03

have the same memory tag now they create

play07:05

an area of speculative execution that

play07:08

will go out and try to dreference the

play07:11

guest pointer and dreference the test

play07:13

pointer now notice they don't actually

play07:15

ever go and run this code all they do is

play07:18

they put it into the code in a way that

play07:20

it could conditionally execute but the

play07:23

problem here is that if the tag

play07:25

mismatches right the whole point of

play07:27

memory tagging is that if the tag Mis

play07:29

matches it crashes a CPU if it

play07:31

mismatches in a speculative case if it

play07:34

mismatches in the future it will not

play07:37

crash the CPU and even so if it

play07:40

mismatches it won't cash it won't go

play07:43

into Cash the test pointer will not be

play07:46

uh cash filled and therefore the guess

play07:48

is wrong what they're able to do they're

play07:50

able to time did we already cash fill

play07:53

this test pointer and use that to figure

play07:55

out if the tag that they guessed was

play07:57

correct so what they do is they iterate

play07:59

is tag one correct is tag two correct

play08:02

and they keep checking over and over

play08:03

again until their access to test pointer

play08:06

is now filled in cash therefore they're

play08:09

able to leak the tag of the target

play08:11

address and use that for a future memory

play08:14

corruption attack like when I read this

play08:17

paper not only are they doing cash side

play08:20

Channel leaking they are doing it in

play08:22

speculative execution to bypass a

play08:25

hardware memory protection dude it is

play08:27

just one of the craziest bugs and make

play08:29

it even more crazy what they figured out

play08:31

how to do is they're able to do this

play08:34

attack inside of the V8 sandbox so what

play08:37

the the entire structure here is they

play08:38

create these things called tic tag

play08:41

gadgets now this this graphic that I

play08:42

just showed you is called a tic tag

play08:44

Gadget template so basically if you can

play08:47

find a piece of code that does this sort

play08:49

of thing where you have address you want

play08:51

to leak address you control speculative

play08:54

branch and then you can check at the end

play08:55

of it you've created what is called a a

play08:57

gadget template so if you can look for

play09:00

Snippets of code that are like this you

play09:01

can find ways to leak the mte and other

play09:04

code and these researchers actually

play09:06

found a bunch of tic tag leak Gadgets in

play09:09

the V8 VM which as I've said in previous

play09:11

videos is the VM that they use to run

play09:14

the JavaScript sandbox right and they're

play09:15

they're showing you here in this paper

play09:17

and again I'm not going to PR like I

play09:18

know how all this works it's very very

play09:20

complicated uh that they found tic tag

play09:22

V2 gadgets that can work inside the V8

play09:25

sandbox to leak arm V8 tags so like I I

play09:30

just cannot emphasize how crazy this

play09:34

paper is I I really please go go go show

play09:36

them some love go go read it I hope it

play09:38

made this more accessible to you guys um

play09:40

and if you like this video do me a favor

play09:41

hit like hit subscribe then go check out

play09:43

this other this video that you will also

play09:46

like as well

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
CPU SecurityMemory CorruptionSpeculative ExecutionARM ArchitectureCybersecuritySoftware SecurityBuffer OverflowMemory TaggingVulnerability ResearchTech Education