1click Android
1click Android
02 Background
Agenda 03 Exploitation
04 Mitigations
05 Takeaways/Questions
01 Introductions
01 Introductions
Messenger and Video Family of App security with party software and
Calling security emphasis on Messenger hardware
• Crypto enthusiast, • Vulnerability research, • Vulnerability research, low
computer science reverse engineering, and level platform/device
background computer science security.
background
01 Introductions
Step Curate known vulnerabilities and develop relevant and realistic exploitation
1 scenarios to investigate (e.g. 0-click messaging vs 1-click calling)
Step Reintroduce curated vulnerabilities on top of the latest release of the target
2 software
Step Document the exploit and brainstorm security engineering work streams to
4 mitigate similar scenarios
01 Introduction: Defense through Offense Exercises To Date
Inaugural exercise targeting the Second exercise targeting Most recent exercise we will be
Quest 2 device. The exercise firmware vulnerabilities on the discussing today. The exercise
resulted in the creation of a local Ray-Ban Stories wearable glasses. created a 1-click calling exploit
privilege escalation exploit for The scenario was an over-the-air targeting the Messenger for
VROS. The exploit scenario was proximity based attack. The Android application resulting in
from the perspective of a malicious exploit allowed an attacker within remote code execution.
or compromised application Bluetooth range of a Ray-Ban
installed to VROS. Stories user to execute code on
the victim’s glasses.
02 Background
02 Background: Messenger Application Introduction
What is Messenger?
02 Background: Messenger Messaging Architecture
Messenger Messaging
Architecture
Msys
Messenger Calling
Architecture
Primarily managed by the Rsys and WebRTC libraries
• Supports both 1:1 and group audio/video calls
• Rsys manages client side signaling and WebRTC
• WebRTC maintains connections to servers/clients and
manages media
Two relevant attack vectors to consider
• Call Signaling
﹘ Communication between clients, infrastructure, and
other clients to manage call state
﹘ Structured Thrift protocol that defines messages
• Call Media
﹘ WebRTC relevant protocols (e.g. RTP, STUN, SCTP) and
audio/video codecs (e.g. OPUS, H264)
02 Background: Messenger Spark AR
Spark AR
Spark AR is the AR effect engine powering AR experiences
across Meta products
• AR effects developed in JavaScript
Group calling AR effects are auto enabled for all call
participants when any call participant enables them
• Exploit uses malicious Group AR effect to force victim client
to download and execute it
Multipeer AR effect feature
• Cross-client AR effect network communication
• Our malicious effect uses this to exfiltrate out of bounds
memory to our malicious caller
04 Mitigations
03 Exploitation
03 Defense through Offense: Social Ops
Our exploit chains four exploitation An AR effect can read out of bounds
primitives from a set of 4 vulnerabilities. Vulnerability 2 Out of bounds Read in on the heap potentially leading to
(Spark AR) SegmentationModule::getForegroundPercent information disclosure and an ASLR
These vulnerabilities are a mix of issues
defeat
crossing different FoA components. All
Malicious calling clients can send
were internally discovered during Vulnerability 3 Signaling messages sendable over media data
signaling messages P2P that should
security reviews of Meta code and have (Rsys) channel
be reserved for the server
been fixed.
Out of bounds write on the heap
Incorrect Signed Integer Comparison Leads to
Vulnerability 4 reachable client-to-client during a
OOB Write in
(Rsys) call that can corrupt the heap in a
UnifiedPlanSdpUpdateSerializer::applyDelta
targeted manner
03 Vulnerabilities
Our exploit chains four exploitation An AR effect can read out of bounds
primitives from a set of 4 vulnerabilities. Vulnerability 2 Out of bounds Read in on the heap potentially leading to
(Spark AR) SegmentationModule::getForegroundPercent information disclosure and an ASLR
These vulnerabilities are a mix of issues
defeat
crossing different FoA components. All
Malicious calling clients can send
were internally discovered during Vulnerability 3 Signaling messages sendable over media data
signaling messages P2P that should
security reviews of Meta code and have (Rsys) channel
be reserved for the server
been fixed.
Out of bounds write on the heap
Incorrect Signed Integer Comparison Leads to
Vulnerability 4 reachable client-to-client during a
OOB Write in
(Rsys) call that can corrupt the heap in a
UnifiedPlanSdpUpdateSerializer::applyDelta
targeted manner
03 Vulnerabilities
Our exploit chains four exploitation An AR effect can read out of bounds
primitives from a set of 4 vulnerabilities. Vulnerability 2 Out of bounds Read in on the heap potentially leading to
(Spark AR) SegmentationModule::getForegroundPercent information disclosure and an ASLR
These vulnerabilities are a mix of issues
defeat
crossing different FoA components. All
Malicious calling clients can send
were internally discovered during Vulnerability 3 Signaling messages sendable over media data
signaling messages P2P that should
security reviews of Meta code and have (Rsys) channel
be reserved for the server
been fixed.
Out of bounds write on the heap
Incorrect Signed Integer Comparison Leads to
Vulnerability 4 reachable client-to-client during a
OOB Write in
(Rsys) call that can corrupt the heap in a
UnifiedPlanSdpUpdateSerializer::applyDelta
targeted manner
03 Vulnerabilities
Our exploit chains four exploitation An AR effect can read out of bounds
primitives from a set of 4 vulnerabilities. Vulnerability 2 Out of bounds Read in on the heap potentially leading to
(Spark AR) SegmentationModule::getForegroundPercent information disclosure and an ASLR
These vulnerabilities are a mix of issues
defeat
crossing different FoA components. All
Malicious calling clients can send
were internally discovered during Vulnerability 3 Signaling messages sendable over media data
signaling messages P2P that should
security reviews of Meta code and have (Rsys) channel
be reserved for the server
been fixed.
Out of bounds write on the heap
Incorrect Signed Integer Comparison Leads to
Vulnerability 4 reachable client-to-client during a
OOB Write in
(Rsys) call that can corrupt the heap in a
UnifiedPlanSdpUpdateSerializer::applyDelta
targeted manner
03 Vulnerabilities
Our exploit chains four exploitation An AR effect can read out of bounds
primitives from a set of 4 vulnerabilities. Vulnerability 2 Out of bounds Read in on the heap potentially leading to
(Spark AR) SegmentationModule::getForegroundPercent information disclosure and an ASLR
These vulnerabilities are a mix of issues
defeat
crossing different FoA components. All
Malicious calling clients can send
were internally discovered during Vulnerability 3 Signaling messages sendable over media data
signaling messages P2P that should
security reviews of Meta code and have (Rsys) channel
be reserved for the server
been fixed.
Out of bounds write on the heap
Incorrect Signed Integer Comparison Leads to
Vulnerability 4 reachable client-to-client during a
OOB Write in
(Rsys) call that can corrupt the heap in a
UnifiedPlanSdpUpdateSerializer::applyDelta
targeted manner
03 Exploitation: Chained Primitives Achieve Remote Code Execution
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
The exploit sends the shared library before it initiates the call
to ensure it will be available on the file system before the
control flow hijack
03 Exploitation: Primitive 2
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
Attacker sends
Ring callee with spoofed
caller metadata
Rsys“Ring Request” signaling message encodes an incoming
call action on Rsys clients
• This is generated by the server after processing a caller
generated “Join Request” signaling message
Inside of the ring request we have the appMessages field:
﹘ Caller controlled vector of (topic, data) pairs carried Victim Receives
from the Join Request
Vulnerability 1: Rsys Apps Vulnerable to Incoming Call
Metadata Spoofing
• appMessages contained the “call_metadata” topic an
attacker could have supplied the caller name and profile
picture URI
﹘ The UI displayed whatever contents were in this field
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Primitive 2
Victim Client
03 Exploitation: Scudo Interlude
Interlude: Scudo
Scudo is the default heap allocator used on Android >= 11
• When you call malloc and free on these platforms you are
using scudo
References:
https://www.l3harris.com/newsroom/editorial/2023/10/scudo-hardened-allocator-unofficial-internals-
documentation
https://www.synacktiv.com/en/publications/behind-the-shield-unmasking-scudos-defenses
03 Exploitation: Primitive 2
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
Auto-enable malicious
AR effect to defeat OOB Read Vulnerability Snippet
ASLR
Vulnerability 2: Security vulnerability in
SegmentationModule::getForegroundPercent leads to
information disclosure
• Relative backwards out of bounds read of 32-bit value as
float data type
• Exploited via Group AR effect JavaScript program OOB Read Exploitation by AR Effect
ASLR
Vulnerability 2: Security vulnerability in
SegmentationModule::getForegroundPercent leads to
information disclosure
• Relative backwards out of bounds read of 32-bit value as
float data type
• Exploited via Group AR effect JavaScript program OOB Read Exploitation by AR Effect
Auto-enable malicious
AR effect to defeat OOB Read Vulnerability Snippet
ASLR
Vulnerability 2: Security vulnerability in
SegmentationModule::getForegroundPercent leads to
information disclosure
• Relative backwards out of bounds read of 32-bit value as Idx supplied in JS program to
float data type trigger C++ OOB Read
• Exploited via Group AR effect JavaScript program OOB Read Exploitation by AR Effect
Auto-enable malicious
AR effect to defeat
ASLR
• We can read two 32-bit floats to get a 64-bit integer
relative out of bounds read.
Auto-enable malicious
AR effect to defeat
ASLR
Next we must turn the relative 64-bit integer out of bounds
read into a 64-bit arbitrary out of bounds read
Auto-enable malicious
AR effect to defeat
ASLR
How we find our vector base?
• Some objects store the address of their own heap chunk
inside the object.
﹘ For example: linked lists, objects with internal buffers.
• Heuristic
﹘ Scan heap relative to vector looking for self-referential
heap addresses
﹘ Scudo uses tagged pointers: top byte set to 0xb4
﹘ Scudo heap chunks are 16-bit aligned.
﹘ Scudo heap pointers have high entropy, so if we
calculate the entropy of bits [4..39] of the pointer,
we can ignore any low entropy pointers
﹘ Compute candidate vector base address by accounting
for OOB index offset and scanned self-referential heap
address
﹘ Store in a frequency table
﹘ Pick most frequent address as vector base
03 Exploitation: Primitive 3
Auto-enable malicious
AR effect to defeat
ASLR
We now have an arbitrary read and can start searching for a
library we want an address of for JOP gadget computation.
• We will search for libcoldstart.so by identifying MCFData
objects on the heap
﹘ MCFData contains a type table pointer pointing to .data
within libcoldstart.so
Auto-enable malicious
AR effect to defeat
ASLR
Now that we have enumerated the scudo bins we can start
looking for MCFData objects in memory to find libcoldstart.so
offsets
• MCFData is convenient to search for since it has a very
predictable structure with expected values in memory
• We now have our ASLR defeat identifying libcoldstart.so
offset through _typeID in scanned object
03 Exploitation: Primitive 3 Iterate over each scudo bin
address and perform search
for MCFData
Auto-enable malicious
AR effect to defeat
ASLR
Now that we have enumerated the scudo bins we can start
looking for MCFData objects in memory to find libcoldstart.so
offsets
• MCFData is convenient to search for since it has a very
predictable structure with expected values in memory
• We now have our ASLR defeat identifying libcoldstart.so
offset through _typeID in scanned object
03 Exploitation: Primitive 3
Pattern match the scanned
ASLR
Now that we have enumerated the scudo bins we can start
looking for MCFData objects in memory to find libcoldstart.so
offsets
• MCFData is convenient to search for since it has a very
predictable structure with expected values in memory
• We now have our ASLR defeat identifying libcoldstart.so
offset through _typeID in scanned object
03 Exploitation: Primitive 3
Auto-enable malicious
AR effect: Controlled Spray Uint8Array
object placement
The exploit requires the AR effect to allocate an object
structured in a certain way that we can use in our subsequent
JOP chain
• The effect sprays objects on the heap using Uint8 arrays
and identifies them using the arbitrary read
• Then the effects modifies one of the objects with controlled
data for the JOP chain representing a fake MCFRuntime
class
Auto-enable malicious
AR effect: Controlled Use arbitrary read to located sprayed
objects
object placement
The exploit requires the AR effect to allocate an object
structured in a certain way that we can use in our subsequent
JOP chain
• The effect sprays objects on the heap using Uint8 arrays
and identifies them using the arbitrary read
• Then the effects modifies one of the objects with controlled
data for the JOP chain representing a fake MCFRuntime
class
Auto-enable malicious
AR effect: Controlled Overwrite sprayed objects with JOP chain payload
object placement
The exploit requires the AR effect to allocate an object
structured in a certain way that we can use in our subsequent
JOP chain
• The effect sprays objects on the heap using Uint8 arrays
and identifies them using the arbitrary read
• Then the effects modifies one of the objects with controlled
data for the JOP chain representing a fake MCFRuntime
class
Auto-enable malicious
AR effect: Controlled
object placement Leak object addresses over the network using Multipeer
The exploit requires the AR effect to allocate an object
structured in a certain way that we can use in our subsequent
JOP chain
• The effect sprays objects on the heap using Uint8 arrays
and identifies them using the arbitrary read
• Then the effects modifies one of the objects with controlled
data for the JOP chain representing a fake MCFRuntime
class
Ring callee with spoofed caller metadata and heap spray payload
(Primitive 2)
The sprayed MCFData objects are sized such that they are
allocated in the same Scudo region (0x160) as the indexed
vector
• Note: Scudo is non deterministic
﹘ Exploit is not 100% reliable
﹘ We increased probability of success by spraying
many MCFData objects
The sprayed MCFData objects are sized such that they are
allocated in the same Scudo region (0x160) as the indexed
vector
• Note: Scudo is non deterministic
﹘ Exploit is not 100% reliable
﹘ We increased probability of success by spraying
many MCFData objects
The exploit can perform the out of bounds write but now the
question is “What do we corrupt?”
• Answer: The sprayed MCFData objects from Primitive 2
The sprayed MCFData objects are sized such that they are
allocated in the same Scudo region (0x160) as the indexed
vector
• Note: Scudo is non deterministic
﹘ Exploit is not 100% reliable
﹘ We increased probability of success by spraying
many MCFData objects
The exploit can perform the out of bounds write but now the
question is “What do we corrupt?”
• Answer: The sprayed MCFData objects from Primitive 2
The sprayed MCFData objects are sized such that they are
allocated in the same Scudo region (0x160) as the indexed
vector
• Note: Scudo is non deterministic
﹘ Exploit is not 100% reliable
﹘ We increased probability of success by spraying
many MCFData objects Hijacked finalize fptr
The exploit can perform the out of bounds write but now the
question is “What do we corrupt?”
• Answer: The sprayed MCFData objects from Primitive 2
The sprayed MCFData objects are sized such that they are
allocated in the same Scudo region (0x160) as the indexed
vector
• Note: Scudo is non deterministic
﹘ Exploit is not 100% reliable
﹘ We increased probability of success by spraying
many MCFData objects Hijacked finalize fptr
Index Base
std::vector<MediaDescriptionUpdate>
Index Base
std::vector<MediaDescriptionUpdate>
Index Base
std::vector<MediaDescriptionUpdate>
std::vector<MediaDescriptionUpdate>
std::vector<MediaDescriptionUpdate>
Sprayed MCF Data Objects from Primitive 2 Point type table to fake
MCFRuntimeClass
allocated by ARFX
03 Exploitation: Primitive 4
MCFRelease
decrements ref count
to 0 and calls
corrupted finalize()
function pointer
03 Exploitation: Primitive 4
x0 dlopen
path
x9 dlopen
gadget
03 Exploitation: Primitive 4
JOP Chain to Stage 1 Payload dlopen loads the library path from
Primitive 1 achieving RCE
03 Exploitation: Primitive 4
Andrew Calvano Octavian Guzu Ryan Hall Special Mention: Sampriti Panda, for his help in the
Meta Product Security Meta Product Security Meta Red Team X exercise