WEBVTT
Kind: captions
Language: en

00:00:00.160 --> 00:00:05.759 align:start position:19%
Apple just launched their new lineup of
iPhones and aside from the new features

00:00:03.919 --> 00:00:09.360 align:start position:19%
and improvements, there's one important
security change that has flown under the

00:00:07.520 --> 00:00:15.360 align:start position:19%
radar for the average consumer. With
their new A19 chip being based on the

00:00:11.840 --> 00:00:20.320 align:start position:19%
ARMv9A architecture, iOS now supports
the memory tagging extension feature.

00:00:17.920 --> 00:00:25.760 align:start position:19%
MTE is an ARM feature introduced a few
years ago in the ARV 8.5 architecture

00:00:23.359 --> 00:00:29.439 align:start position:19%
and has only been in use on a couple of
other consumer devices on the market up

00:00:27.760 --> 00:00:33.040 align:start position:19%
until now. Apple calls their
implementation memory integrity

00:00:31.439 --> 00:00:36.399 align:start position:19%
enforcement. And with the release of
these new phones, they published a

00:00:34.800 --> 00:00:39.840 align:start position:19%
technical breakdown on their security
blog. So today in this video, we're

00:00:38.000 --> 00:00:44.640 align:start position:19%
going to explore this mitigation and see
how it aims to make exploitation of iOS

00:00:42.160 --> 00:00:49.039 align:start position:19%
devices significantly more difficult.
The vast majority of exploits against

00:00:46.480 --> 00:00:54.079 align:start position:19%
iOS devices rely on memory corruption
bugs. These are bugs where as a result

00:00:51.360 --> 00:00:58.719 align:start position:19%
of faulty system logic, an attacker can
write to out-of-bounds memory or type

00:00:56.559 --> 00:01:02.800 align:start position:19%
confuse objects in order to corrupt
important parts of the process data and

00:01:01.039 --> 00:01:06.880 align:start position:19%
ultimately take control of the system.
Memory corruption bugs have been around

00:01:04.559 --> 00:01:11.119 align:start position:19%
forever and are unlikely to go away
completely. Even with the latest iOS

00:01:09.119 --> 00:01:15.840 align:start position:19%
versions, we see many bugs of this
category being fixed in patch updates on

00:01:13.680 --> 00:01:20.880 align:start position:19%
a regular basis. It would be infeasible
to aim for a bug-free iOS. So instead,

00:01:18.960 --> 00:01:25.520 align:start position:19%
Apple has focused a lot of their efforts
in recent years on making these bugs as

00:01:23.680 --> 00:01:28.080 align:start position:19%
difficult as possible to exploit.
They've already done a great job at this

00:01:26.799 --> 00:01:31.520 align:start position:19%
in their software and hardware
enhancements over the past 5 years with

00:01:30.240 --> 00:01:35.920 align:start position:19%
the introduction of pointer
authentication codes to mitigate control

00:01:33.600 --> 00:01:40.640 align:start position:19%
flow hijacking, zone sequestering, and
other allocator hardening techniques to

00:01:37.920 --> 00:01:45.119 align:start position:19%
mitigate certain types of heap attacks
and other proprietary hardware

00:01:42.159 --> 00:01:48.960 align:start position:19%
mitigations like KTRR and PPL. Apple's
memory integrity enforcement is thought

00:01:46.960 --> 00:01:53.119 align:start position:19%
to be the final nail in the coffin,
potentially ending memory corruption

00:01:50.560 --> 00:01:57.920 align:start position:19%
exploitation in iOS completely. The goal
of MIE is to catch every type of

00:01:55.439 --> 00:02:02.240 align:start position:19%
out-of-bounds access or use after free
situation at the earliest possible point

00:02:00.079 --> 00:02:06.240 align:start position:19%
in time and panic the system to prevent
an attacker leveraging this in an

00:02:03.920 --> 00:02:10.239 align:start position:19%
exploit. It works much like an address
sanitizer, which is a common debugging

00:02:08.239 --> 00:02:15.440 align:start position:19%
tool used in software development.
Address sanitizers instrument a program

00:02:12.560 --> 00:02:19.520 align:start position:19%
to include extra sanity checks on every
memory access operation. And these

00:02:17.280 --> 00:02:23.840 align:start position:19%
sanity checks ensure that the program is
not reading or writing outside of an

00:02:21.840 --> 00:02:27.360 align:start position:19%
allocated buffer and that it's not
accessing memory that's already been

00:02:25.440 --> 00:02:31.280 align:start position:19%
freed. The problem with softwarebased
address sanitizers is that they have a

00:02:29.520 --> 00:02:35.840 align:start position:19%
significant overhead due to the
inefficiency of performing extra logic

00:02:33.840 --> 00:02:39.680 align:start position:19%
on every single memory access. It
wouldn't be a good idea to ship a

00:02:37.440 --> 00:02:43.280 align:start position:19%
production device with a softwarebased
address sanitizer active because

00:02:41.680 --> 00:02:47.040 align:start position:19%
performance would take too much of a
hit. The cool thing about the mte

00:02:45.280 --> 00:02:52.239 align:start position:19%
feature is that it leverages new
hardware instructions available in the

00:02:49.200 --> 00:02:56.720 align:start position:19%
ARMV9A architecture that implement the
functionality of a software address

00:02:54.000 --> 00:03:01.440 align:start position:19%
sanitizer but in a hardwarebacked way.
These new CPUs have built-in circuitry

00:02:59.280 --> 00:03:04.959 align:start position:19%
to handle the sanity checks. So
performance takes no real hit. Let's

00:03:03.440 --> 00:03:10.560 align:start position:19%
take a look at this on a technical
level. If we download the latest iOS 26

00:03:08.000 --> 00:03:15.120 align:start position:19%
IPSW for the newest iPhone, we can
inspect the kernel itself and see these

00:03:13.040 --> 00:03:18.959 align:start position:19%
new MTE instructions present in the
kernel cache binary. The first new

00:03:16.720 --> 00:03:23.920 align:start position:19%
instruction we see is the IRG
instruction which inserts a random tag

00:03:21.680 --> 00:03:29.120 align:start position:19%
into a pointer. Now, much like pointer
authentication codes, the IRG

00:03:26.080 --> 00:03:33.840 align:start position:19%
instruction generates a random 4-bit tag
and inserts it into the top bits of a

00:03:31.760 --> 00:03:38.000 align:start position:19%
given pointer. These bits are unused
under normal circumstances. So the

00:03:36.080 --> 00:03:42.640 align:start position:19%
system is able to store data here
without affecting normal execution. Once

00:03:40.080 --> 00:03:47.920 align:start position:19%
a pointer has been tagged, the memory
associated with the pointer can be

00:03:44.480 --> 00:03:51.840 align:start position:19%
tagged with the same value using the STG
instruction. This instruction will take

00:03:49.760 --> 00:03:57.439 align:start position:19%
the tag value from the pointer's top
bits and write it into a special private

00:03:54.959 --> 00:04:02.640 align:start position:19%
shadow memory region that can hold tags
per 16 byt granule of memory. This means

00:04:00.159 --> 00:04:08.000 align:start position:19%
that for every 16 bytes of memory, we
can store a different 4-bit tag in this

00:04:05.519 --> 00:04:12.000 align:start position:19%
special shadow region. Now, unlike with
software address sanitizers, this shadow

00:04:10.239 --> 00:04:17.120 align:start position:19%
memory region is actually not part of
the normal memory, but this is instead a

00:04:14.400 --> 00:04:21.919 align:start position:19%
private region only interfaceable via
these MTE instructions. So once a

00:04:19.919 --> 00:04:26.479 align:start position:19%
pointer and its corresponding memory
have been tagged using these MTE

00:04:24.000 --> 00:04:30.720 align:start position:19%
instructions, any subsequently executed
memory access instruction will trigger

00:04:28.560 --> 00:04:34.800 align:start position:19%
an exception. if the tags are ever found
to be mismatched. Checking for

00:04:32.479 --> 00:04:39.120 align:start position:19%
mismatched tags does not require any new
logic to be implemented in software. The

00:04:37.120 --> 00:04:43.919 align:start position:19%
typical ARM 64 load and store
instructions have new circuitry

00:04:41.280 --> 00:04:48.080 align:start position:19%
hard-coded in these latest ARM CPUs,
which actually validates the pointer and

00:04:45.759 --> 00:04:51.600 align:start position:19%
memory tags almost instantly with no
noticeable performance overhead. So, in

00:04:50.240 --> 00:04:56.400 align:start position:19%
practice, how would this prevent
exploitation? Apple has updated their

00:04:54.000 --> 00:05:01.280 align:start position:19%
allocator logic to implement these new
MTE instructions such that anytime an

00:04:59.040 --> 00:05:05.759 align:start position:19%
allocation is made, the pointer and the
memory allocated are both tagged. And

00:05:03.520 --> 00:05:10.160 align:start position:19%
when the allocation is freed, the memory
is rettagged with a new value. For

00:05:08.000 --> 00:05:14.320 align:start position:19%
typical use after free bugs, a program
mistakenly uses a pointer that

00:05:12.160 --> 00:05:18.960 align:start position:19%
references already freed memory. But
with MTE now enabled, this is no longer

00:05:16.960 --> 00:05:23.440 align:start position:19%
possible because as soon as a memory
access is made on the freed pointer, the

00:05:21.440 --> 00:05:27.680 align:start position:19%
ARM hardware will recognize that the
pointer and the memory tags do not match

00:05:25.919 --> 00:05:32.320 align:start position:19%
and an exception will be triggered.
Similarly, for buffer overflows and any

00:05:30.000 --> 00:05:36.240 align:start position:19%
other out-ofbounds access bugs, these
are no longer useful to attackers

00:05:33.840 --> 00:05:40.000 align:start position:19%
because different allocations are tagged
separately. So if a program mistakenly

00:05:38.320 --> 00:05:44.240 align:start position:19%
tries to write beyond the bounds of an
allocated buffer, the very first

00:05:41.759 --> 00:05:48.320 align:start position:19%
outofbounds write will fail due to the
address tag and the memory tag mismatch.

00:05:46.639 --> 00:05:52.880 align:start position:19%
One small caveat worth mentioning here
is that since these memory tags are only

00:05:50.479 --> 00:05:56.720 align:start position:19%
four bits, it is possible for separate
allocations to have the same tag, but

00:05:55.280 --> 00:06:01.520 align:start position:19%
this still provides a pretty strong
defense against exploits since the

00:05:58.880 --> 00:06:06.319 align:start position:19%
reliability will drop to a 1 in6 chance
of success. There has been some public

00:06:03.440 --> 00:06:10.479 align:start position:19%
research into exploitation with MTE on
Android platforms and some researchers

00:06:08.800 --> 00:06:14.479 align:start position:19%
have managed to work around it in an
exploit. However, these workarounds have

00:06:12.639 --> 00:06:18.319 align:start position:19%
involved very unique primitives that
actually didn't require triggering

00:06:16.479 --> 00:06:22.639 align:start position:19%
typical memory corruption bugs. So, we
can be confident that this is a powerful

00:06:20.080 --> 00:06:25.840 align:start position:19%
mitigation and definitely a gamecher for
traditional memory corruption

00:06:23.919 --> 00:06:29.440 align:start position:19%
exploitation. On Apple's own research
blog, they state that they believe

00:06:27.520 --> 00:06:33.280 align:start position:19%
memory integrity enforcement represents
the most significant upgrade to memory

00:06:31.440 --> 00:06:36.960 align:start position:19%
safety in the history of consumer
operating systems and that even with

00:06:35.120 --> 00:06:41.360 align:start position:19%
substantial effort, their internal
research team were actually not able to

00:06:39.440 --> 00:06:45.840 align:start position:19%
rebuild any of their sample exploit
chains to work around this mitigation on

00:06:43.360 --> 00:06:49.840 align:start position:19%
iOS. As an iPhone user, this should be a
very comforting statement, and for the

00:06:47.759 --> 00:06:53.520 align:start position:19%
hacker community, it presents a daunting
challenge. Check out Apple's own

00:06:51.600 --> 00:06:56.560 align:start position:19%
technical blog on this new mitigation.
There's some other details that were not

00:06:55.039 --> 00:07:00.720 align:start position:19%
mentioned in this video that would be
worth reading. I'll leave the link in

00:06:57.840 --> 00:07:00.720 align:start position:19%
the description below.

