Exploring Widevine For Fun and Profit
Exploring Widevine For Fun and Profit
Exploring Widevine For Fun and Profit
Abstract—For years, Digital Right Management (DRM) sys- and video-streaming services, including Netflix and Disney+,
tems have been used as the go-to solution for media content pro- leverage Widevine to protect their content.
tection against piracy. With the growing consumption of content Widevine protects video streams at several levels. At the
arXiv:2204.09298v1 [cs.CR] 20 Apr 2022
2
B. Google Widevine The obtained keys are only accessible through Media Crypto.
Widevine is a DRM solution acquired by Google in 2010. Indeed, the encrypted content is decrypted by a Media Codec
The earlier version of Widevine that had support in old instance to which the Media Crypto object was registered.
Android versions (up to Android 5.1) was called Widevine Thus, the keys are not accessed directly. In addition to the
Classic, working only with the proprietary .wmv format. The DASH mode, the DRM APIs provide the ability to establish
current version of Widevine is called Widevine Modular, a secure session to protect arbitrary data.
and implements a different DRM and streaming standards, B. Widevine Components
including MPEG-DASH and CENC. Widevine Modular, or
henceforth simply Widevine, is supported on Android 4.4+. In Android, Widevine comes as a dynamically loadable
Widevine defines three security levels: L1, L2 and L3, HAL plugin within the mediadrmserver process. Similar
where the L1 level is considered the most secure for playing to other HAL plugins, Widevine is manufacturers-provided.
HD videos from OTT platforms. Widevine depends on the In addition, it is not open-source; only provided as binary
TEE to implement L1 security. At L1, both cryptography and code and library files. To keep things secure, when a TEE is
video processing take place inside the TEE. It is worth noting available, the HAL plugin delegates all sensitive operations to
that applications inside the TEE are hardware dependent, and the Widevine component that runs inside the TEE. Roughly
therefore Widevine shall provide a different implementation speaking, the resulting architecture looks like this (other
for each one. L2 and L3 are implemented where the TEE components might exist depending on the Android version):
is not an option, such as legacy phones or Widevine locked • Widevine library: this library is used by the
ones due to device tampering. In Android, Widevine does not mediadrmserver process to translate Android DRM
propose L2 security. The L3 lets both cryptography and video API calls to Widevine CDM ones. The behavior of this
processing take place outside the TEE. They are considered library changes depending on the Widevine security level.
more vulnerable, given that the CDM is software-only. As for In L1, it plays the role of a proxy and communicates
users, L3 delivers sub-HD resolutions since Widevine supports with the TEE through liboemcrypto.so. As for L3,
HD and ultra-HD content only for L1. it contains the obfuscated CDM. Its name can change
depending on the version and SoC including but not
III. WARM U P : W IDEVINE IN A NDROID limited to: libwvdrmengine.so, libwvhidl.so,
In this section, we describe the integration of Widevine libwvm.so, libdrmwvmplugin.so.
into the Android ecosystem. In particular, we detail all the • liboemcrypto.so: this library performs marshalling and
components of which Widevine consists of and their interac- unmarshalling of requests to the Widevine trustlet. All
tion. This will help us to better frame our reverse engineering communications with the TEE go through a specific TEE
methodology by pointing out the relevant components to driver (e.g., QSEEComAPI.so for QSEE).
analyze in order to uncover the internals of Widevine. • Widevine trustlet: it runs inside the TEE and implements
all the needed functionalities for L1.
A. Android DRM API
In order to cope with the fragmented DRM ecosystem, C. Components Interaction
Android offers a unified API in Java/Kotlin for DRM systems. Android Widevine architecture is summarized in Figure 1.
Starting from API level 18, this is implemented by some In a top down architecture, components interact as follows.
HAL (Hardware Abstraction Layer) module called Media DRM services start from the OTT application calling the An-
DRM Server that abstracts the actual running DRM from the droid Media Framework API to interact with the MediaDRM
programming interface used by OTT apps. The Android DRM and MediaCrypto objects. All calls to the DRM API
API mainly consists of two modules: Media DRM and Media go through some Java Native Interface (JNI) layer via the
Crypto. The Media DRM is used to communicate with License libmedia_jni.so library. Calls are then forwarded to the
Servers and to manage keys for a given media. As for Media Media DRM Server instantiated by the mediadrmserver
Crypto, it is used to perform decryption. The DRM APIs process, which is the last module implemented by Android.
support the ISO/IEC 23002-7: Common Encryption standard The Media DRM Server reaches the Widevine specific im-
(CENC) [4], but implement other encryption schemes. plementation through the HAL APIs. Any communication
Playing encrypted content when leveraging DASH (Dy- with Widevine first goes to its specific library such as
namic Adaptive Streaming over HTTP) works as follows. First, libwvdrmengine.so. In L3, no further component is
the app constructs a Media DRM object with a given DRM involved. As for L1, whenever CDM is required, this library
through a unique identifier. Then, the app opens a new session calls liboemcrypto.so that sends the related requests to
with the Media DRM object and gets some session identifier. the Widevine TEE trustlet.
A Media Crypto object is then constructed and bound to Of particular interest, the Widevine library does the trans-
the opened session. Next, Media DRM retrieves keys (aka lation between the HAL API to Widevine functions. Once
licenses) from the License Server. To this end, a DRM-specific translated, if Widevine is in L1 mode the Widevine API
request object is obtained from the Media DRM object, and is used to call its equivalent in liboemcrypto.so. The
the server response is delivered to the Media DRM instance. OEMCrypto library role is to forge a message for the TEE
3
Application
e.g., Netflix, • Pixel 3: Android version 11, build blueline rq3a.210805.
PrimeVideo, Disney+
4
Android Widevine Widevine
Application
Media Servers
Library CDM
ctxID
getProvisionRequest getProvisionRequest
Cert Provisioning
GenerateNonce(ctxID)
nonce
GetKeyData
provisioning token
GenerateSignature(ctxID, prov_blob)
hmac(prov_blob)
Provisioning
wrapped_rsa_key
media request
CDN
media , keyID
getKeyRequest getKeyRequest
License Provisioning
LoadDeviceRSAKey(ctxID, wrapped_rsa_key)
GenerateNonce(ctxID)
nonce
signature(request)
License Server
LoadKeys(ctxID, , hmac)
Content Decryption
queueSecureInputBuffer
media , keyID SelectKey(ctxID, keyID)
DecryptCENC
...
DecryptCENC
Content Key RoT Derived Client Key RoT Derived Server Key Session Derived Server Key Device RSA Key Server Key (Optional)
Device Key (RoT) RoT Derived Asset Key Session Derived Client Key Session Derived Asset Key Session Key
library, with the help of the CDM. Overall, the Widevine On request creation, the CDM generates a nonce to ensure
protocol involving these actors is divided into three main freshness. Then, it derives keys for certificate decryption and
phases: Certificate Provisioning, License Provisioning and integrity checks, based on the Widevine Root of Trust (RoT)
Content Decryption. An illustration of the protocol can be seen called the Device Key, and dynamically generated buffers.
in Figure 2. These buffers are based on a token within the RoT structure
detailed later. Using OEMCrypto_GenerateSignature,
Certificate Provisioning. The provisioning phase is usually the request is HMAC-protected with the RoT derived client
done once to recover a cryptographic certificate and does not key, and sent to the provisioning server.
need to be done for future media decryption. The private key
within this certificate protects the fresh session keys. A new The received response is passed to the CDM through
request is sent to the provisioning server when no certificate the OEMCrypto_RewrapDeviceRSAKey function. After
can be found, the one installed is corrupted, or the OTT needs nonce check and integrity verification using the RoT derived
to install a new certificate. server key, the certificate is decrypted using the previously
5
derived key and stored on the persistent storage of the device Device Key Content Key
certificate private key called the Device RSA Key. AES-128 CMAC
enc context buffer
AES-128 CBC
6
TABLE I its associated Content Key. The KCB is identified by the magic
W IDEVINE K EY B OX number kctl or one of the form kcXX, where XX is related to
Field Description Size (bits) Widevine version. The Content Key is accepted only when the
Device ID Internal Device ID 256 associated KCB is checked by verifyKeyControlBlock.
Device Key 128-bit AES key 128
Provisioning Token Used by provision requests 576
This function helped us to understand the structure of KCB:
Magic Number “kbox” 32 a nonce, time to live (TTL) of the key, and 32-bit of control
CRC32 CRC32 validating the keybox integrity 32 bits. These control bits define usage right (e.g., encryption,
Total 1024
MAC tag generation, etc.) and anti-rollback features. During
the lifetime of a Content Key, the KCB can be updated
remaining 16 bytes correspond to an AES key that is called, through the OEMCrypto_RefreshKey function that, unlike
according to the API, Device Key. This key is the real RoT. its name might indicate, cannot change the key or usage
We summarize the five fields of the keybox in Table I. rights but only its TTL. Such refresh requests work as li-
cense ones with the exception that the OEMCrypto function
B. Device RSA Key GenerateSignature is used for integrity protection in-
As explained in section IV, Widevine does not directly use stead of GenerateRSASignature.
its RoT to protect licenses. Instead, it leverages an RSA key Keys Usage. During loading in the CDM memory, Content
pair that, unlike the keybox, can be installed dynamically on Keys are stored in a key table structure with an identifying
the device through a process called certificate provisioning. key ID for OEMCrypto_SelectKey. For media playback,
This process is protected by the Device Key that is derived into encrypted buffers are decrypted with the chosen key by
several keys in OEMCrypto_GenerateDerivedKeys. OEMCrypto_DecryptCENC implementing MPEG-CENC.
Upon reception, the OEMCrypto_RewrapDeviceRSAKey
D. Nonces
function first verifies the integrity of the key pair by re-
computing an 256-bit HMAC tag. Then, it decrypts the key The Widevine protocol mitigates replay attacks
pair, and re-encrypts it again with a device-unique (TEE- and ensures message freshness using nonces. By
specific in L1 or keybox-related in L3) 128-bit AES key. OEMCrypto_GenerateNonce, the Widevine library
These keys never leave the CDM. This function also checks can ask the CDM to generate up to 20 nonces per second
the key pair format after decryption and before re-encryption. stored in a First In, First Out (FIFO) queue of 16 elements
Indeed, the key pair, aka the Device RSA Key, is expected within the CDM memory. These 32-bit nonces are generated
to be an RSA certificate with PKCS#5 padding in PKCS#8 using a Pseudo Random Number Generator (PRNG) and used
format as indicated by the qsee_secpkcs8_parse and at each request creation and response reception. If the nonce
get_len_with_pkcs5_padding functions. is valid, it is removed from the queue and the message is
Once re-encrypted, aka re-wrapped, the Device RSA Key is processed, otherwise the message is dropped. During Content
stored on the standard file system by the Widevine library Keys loading in OEMCrypto_LoadKeys, a single nonce
in a cert.bin file on /data/mediadrm/IDMXXXX/. can be used in multiple KCBs. In this case, the nonce is only
Widevine distinguishes L1 from L3 by using different direc- removed once all keys have been processed.
tories. This persistent data is later used in future instances of
E. Summary of Cryptographic Algorithms
the Widevine CDM to avoid making new provisioning. Here,
OEMCrypto_LoadDeviceRSAKey is used to recover the Widevine Generic Crypto API. In addition to media
stored certificate. We note that re-wrap is MAC-and-Encrypt, decryption, the Widevine CDM allows applications to perform
as it also computes an 256-bit HMAC tag on the key pair. arbitrary cryptographic operations within a dedicated session.
Please note that a new provisioning process is performed In Android, using the CryptoSession class of Media
whenever the cert.bin file is deleted or corrupted. DRM, an application can leverage the underlying DRM plugin
to protect data using the OEMCrypto_Generic_XXX family
C. Content Keys of Encrypt, Decrypt Sign and Verify functions. Here,
Keys protection. As introduced previously, content keys, each operation must have the appropriate key usage rights.
or license keys, are obtained from provideKeyResponse. Key Derivation. Widevine never uses received or stored
Here, Widevine first calls DeriveKeysFromSessionKey keys directly. Instead, it relies on key derivation algorithms,
from OEMCrypto to decrypt a special field; Session Key, implemented in OEMCrypto_GenerateDerivedKeys
using the Device RSA key. This key is later used to derive and OEMCrypto_DerivedKeyFromSessionKey, in or-
a 128-bit AES key as well as two 256-bit HMAC keys. Then, der to generate three different keys each time: a 128-bit Asset
these keys are used in OEMCrypto_LoadKeys to decrypt key, a 256-bit MAC Client Key, and a 256-bit MAC Server
the license key and verify its integrity. Key. The leveraged PRF (Pseudo-Random Function) is AES-
Key Control Block. Alongside the Session and Content 128-CMAC to generate the required 640 bits. In addition to
Keys, the response from the License Server also contains secret keys, the derivation algorithm uses two buffers, called
additional 128-bit metadata called Key Control Block (KCB), encryption context and mac context, that are created based
one for each license key in the response, and is encrypted by on device-unique information and used respectively for the
7
Asset key and both MAC keys. For each chunk, the device operations make the tool uncover the secret keys that should
blob is appended to a string that begins with a string counter exist in the memory at a particular point of time, despite of
and the word “ENCRYPTION” for encryption context or the applied obfuscation.
“AUTHENTICATION” for the mac ones. Only one encryption We implement WideXtractor using Frida to monitor all calls
context with counter “1” is needed, while the mac context to the OEMCrypto functions in the Media DRM Server.
includes four counters starting from 1. Monitoring the mediadrmserver process has two advan-
Symmetric Cryptography. All CDM operations re- tages: (1) it allows us to bypass anti-debug techniques at the
lated to key decryption, generic encryption API (i.e. application level, such as SafetyNet [16], and (2) both L1 and
Generic_Encrypt, Generic_Decrypt), and media L3 workflow can be recovered.
protection are performed using AES 128 bits. Both key decryp- Our monitoring traces any call to Widevine functions,
tion (e.g. OEMCrypto_LoadKeys) and encryption API im- hence the underlying protocol outline, while dumping the
plement AES in CBC mode, while media decryption relies on used arguments, such as buffers for requests and opaque
OEMCrypto_DecryptCENC which supports MPEG-CENC reply data. To this end, WideXtractor relies on a Frida server
(i.e. AES-128-CTR). running on the Android device with sys ptrace capability.
AES Initialization Vectors. Within key decryption func- This can be achieved by running as the media group or a
tions, IVs are being received alongside their respective system/root privileged user. Our script hooks the OEMCrypto
cyphertext in server responses. On Device RSA Key rewrap, functions after attaching to the mediadrmserver process
IV generation is handled by a PRNG algorithm with instantiating DRM libraries.
OEMCrypto_GetRandom. For protected content, MPEG- Once launched and attached, WideXtractor logs every
CENC standard is used to deal with IVs. method of the Widevine protocol and received buffers from
MAC Generation. The MAC Client Keys and Server Keys the Android OS. Our traces correspond to the library symbols
respectively protect requests and responses to provisioning that we reverse engineered and summarized in section A. Our
and license servers using HMAC-SHA256. The same algo- tool allows attackers to inspect exchanged messages during
rithm is used by the OEMCrypto API Generic_Sign and key reception and media decryption before opaque requests
Generic_Verify using the currently loaded Content Key. and responses. WideXtractor can be found on our Github.4
RSA Operations. The Device RSA Key includes a 2048-
bit private key that is used for both decryption and signature B. Case Study: Netflix
during Session Key loading and license request creation. For Leveraging WideXtractor, we automatically monitor the use
decryption, this key is used in the RSA-OAEP-SHA1 mode, of Widevine by the Netflix app, which is the most popular
while RSASSA-PSS-SHA1 and RSASSA-PKCS1-v1 5 can OTT with 200 million subscribers around the world [17]. Our
both be used for requests depending on function argument. analysis shows a large number of calls to the Widevine Generic
Crypto API compared to other OTT apps.
VI. W IDE X TRACTOR
Following our observation, we dig deeper to understand
Most OTT apps, including Netflix, Disney+ and Hulu, apply Netflix internals. We find that Netflix requires to manage
anti-debugging mechanisms in order to prevent attackers from two Widevine sessions: one to get Content Keys and de-
easily intercepting and tracing calls to Widevine. In addition, crypt protected media, and one to exchange data using the
our reverse engineering shows that it is quite demanding to Widevine Generic Crypto API. Henceforth, we will call these
untangle the Widevine interface between its different com- two sessions License Session and Generic Crypto Session
ponents. This is due to the fact that dissecting the Widevine respectively. Both sessions are initialized in the same way until
workflow provides an important insight into its internals. Thus, OEMCrypto_LoadKeys.
we implement WideXtractor; a tool tracing the Widevine calls Indeed, the License Session loads the Content Key that de-
made by an OTT app. In this section, we present an overview crypts the displayed media, while the Generic Crypto Session
of the design and the implementation of this tool. Then, we loads several keys for confidentiality and integrity protection
show the effectiveness of our tool by highlighting interesting of arbitrary data. We note that Content Key can only be
findings while analyzing the most downloaded OTT app on accessed through the queueSecureInputBuffer method
Android, namely Netflix. Finally, we extend WideXtractor to from the MediaCodec class. Thus, only keys loaded within
inspect Widevine as a plugin on Chrome. the Generic Crypto Session can be used to decrypt arbitrary
data using the Android CryptoSession. Here, each key
A. WideXtractor Design
has its own usage rights to perform specific cryptographic
We design WideXtractor to automatically trace the exe- operations. As explained in subsection V-E, Widevine asso-
cution flow of Widevine on Android. Our goal is twofold. ciates these functions to the following OEMCrypto ones:
First, researchers can easily and systematically study how OTT Generic_Encrypt and Generic_Decrypt for AES op-
apps leverage Widevine while displaying protected content. erations, and Generic_Sign with Generic_Verify for
Interesting findings can be revealed by analyzing the actual HMAC tag computation and verification.
calls and their parameters, as we demonstrate for Netflix in
the following subsection. Second, our insights about the used 4 https://github.com/Avalonswanderer/wideXtractor
8
Our study shows that all communications with the Net- MediaKeySession managing the lifetime of a DRM li-
flix CDN go through the Generic Crypto Session. Thus, cense. Next, the MediaKeySession object generates a
Netflix avoids relying solely on HTTPS to protect assets. license request by calling generateRequest. This message
For instance, from the Android OS view, the app asks is sent to the license server to require the necessary decryption
the Widevine CDM to decrypt and verify the received keys. Once the response is received, MediaKeySession
messages. The decrypted data are sent back to the app calls the update method to parse the obtained license inside
without any particular protection. Therefore, by monitoring the CDM. Now, we can decrypt the media using the keys
OEMCrypto_Generic_Decrypt, we were able to inter- loaded from the license.
cept all exchanged messages between the CDN and the In PC browsers, Widevine comes as a plugin in different
Netflix app. These messages contain download URLs for browsers, such as Firefox and Chrome, supporting the EME
timedtexttracks (for subtitles), video_tracks and standard. It is true that our work focuses mainly on Android
audio_tracks. Each of this category contains multiple Widevine. In order to overcome this limitation, we study
links corresponding to different languages for subtitles and the Widevine flow as it is implemented within the browsers
audio in addition to different qualities for video. Although the providing EME. Here, we note that the CDM software is
downloaded videos are encrypted using the Widevine CDM, obfuscated and hides its symbols. Therefore, we follow a
both audio and subtitles can be obtained in clear. We perform different approach: instead of hooking the browser EME
several experiments with the audio and subtitles URLs to functions, we implemented a browser plugin that intercepts
evaluate their validity. We find that they are accessible from all EME related data. Then, we parse these data and compare
any platform (PC web browsers, smartphones, tablets), by them with the ones obtained in Android Widevine. We notice
anyone (no need for Netflix account), from anywhere (no a big reciprocity between the Widevine messages in Android
location verification), and for a limited period of time (12 and PC browsers. This confirms that the Widevine protocol
hours approximately). We also find that there is no limit of in Figure 2 works similarly in different systems. The main
simultaneous accessed devices. difference that we noticed is that the Widevine RoT in browser
Our learned lesson is that Netflix seemingly makes it harder consists of a whitebox implementation of the Device RSA Key.
to spy on messages sent by the CDN by adding an extra Thus, we extend WideXtractor to trace the Widevine flow by
layer of protection provided by Widevine. Thus, attackers merely looking into the EME received messages. Our approach
might be clueless, since defeating Android certificate pinning has the advantage of successfully following the Widevine flow
is not enough. However, WideXtractor easily allowed us to without regard to the applied obfuscation or the actual called
identify the use of the Widevine Generic Crypto API. Thus, it functions. Based on a Chrome EME logger plugin [19], as
becomes even more straightforward to obtain the exchanged in WideXtractor we log buffer values and use key usage info
messages in clear by just recovering the returned buffer of from update calls to identify the message purpose within
OEMCrypto_Generic_Decrypt. The advantage of our the Widevine protocol. This allowed us to log additional
approach is that we no longer need to bypass certificate information to link EME calls to Widevine functions.
pinning implemented by the OTT app. We were surprised that
Netflix does not protect audio tracks by a Content Key. During VII. D ISCUSSION
our responsible disclosure, we discovered that Netflix was not
even aware of that, because they believed that non-Dash mode Widevine enthusiastically pitches the virtue of their DRM
was sufficient. We went further and analyzed six other popular solution. Widevine being proprietary, there is no easy way to
OTT apps: Disney+, Amazon Prime Video, Hulu, HBO Max, verify the security claims of this piece of software running in
Starz and Showtime. We find that, unlike Netflix, all of them billions of devices. The goal of our reverse-engineering efforts
encrypt their audio tracks with the Content Key. is to go beyond this market irrationality. In this section, we
show how our study conveniently helps in highlighting a gap
C. Widevine Over EME between what Widevine promises and their technical solution.
Similar to the unified DRM API of Android, the World Wide The raised issues concern not only OTT, but also final users.
Web Consortium (W3C) defines the Encrypted Media Exten-
sions (EME) standard to provide a standardized API enabling A. Privacy Concerns
web applications to interact with the browser-supported DRM. The Widevine protocol comes with privacy concerns for
EME is designed to make the same web application to run on users in the streaming ecosystem. These issues are due to
any browser regardless of the DRM implementation. Despite the need of Widevine to identify users’ devices for bailing
being optional, EME is supported in major browsers: Edge, purposes. Indeed, Widevine collects device specific data, and
Firefox, Chrome, Safari, Opera, and their mobile versions [18]. sends them to distant servers, such as the provisioning or
The logic of the EME standard is quite similar to the license ones. For instance, in Android these data includes the
Android DRM system. Indeed, when the web application Widevine Device ID within the Widevine keybox, and the
attempts to play an encrypted video, it starts by creating device blob containing several device-identifying fields, such
a MediaKeys, which is the object providing access to as the device architecture, phone model, CDM version, or build
the CDM. Then, it calls createSession to instantiate info.
9
Ironically, Widevine commits to respect users’ privacy. As a the Google Hall of Fame and the Android Security Acknowl-
matter of fact, Widevine claims to follow the EME standard. edgments. Our goal is to improve the knowledge about DRM,
Despite being non-normative, user-tracking issues are being and not to provide copyright infringement tools.
pointed out in the privacy section of the EME standard [18]. VIII. R ELATED W ORK
However, the usage of Distinctive Identifier or Distinctive
Permanent Identifier allows origins crossing information to A. Closed Source Proprietary Protocol
spot a single user based on these device-unique values. This Closed source protocols are often studied in the literature
is harmful for privacy, since it allows third-party servers to to provide building grounds or to point out security flaws of
profile users’ behavior during media consumption. Moreover, the analyzed protocol. For instance, Wouters et al. [20] show
users never consent to such device tracking. that the proprietary autonomous car keyless protocol of Tesla
is vulnerable to key injection, which allows an attacker to
B. Recovering Widevine L3 RoT steal a car in a matter of minutes. Moreover, in their work
Widevine presents their DRM for OTT platforms as a ARIstoteles, Kröll et al. [21] reverse engineered the Apple
solution to protect them from piracy. There exist several levels Remote Invocation undocumented protocol on iOS and found
of compromise; each one relates to some cryptographic keys several vulnerabilities. Their work also includes the design of
in the key ladder. Obviously, RoT recovery constitutes the a tool to foster future research on this topic.
most severe compromise level, since attackers can derive all B. Widevine Keys Recovery
keys allowing to decrypt any protected content. Widevine
In 2019, David Buchanan claimed to have broken L3
distinguishes L1 RoT and L3 RoT, as it is more challenging
Widevine on Linux Chrome browsers in a tweet [22] being
to compromise L1 compared to L3. Indeed, Widevine relies
the only available information about this attack. Buchanan
on software-only protection mechanisms to hide L3 RoT. It is
mentioned that L3 relies on AES-128 whitebox to protect me-
true that such protection is brittle and doomed to be broken.
dia and was vulnerable to Differential Fault Analysis (DFA).
However, advanced obfuscation techniques might make the
Buchanan has never provided any further detail.
compromise quite involving and resources demanding. Here,
Tomer Hadad released widevine-l3-decryptor on Github at
we show how our understanding of the Widevine protocol may
the end of 2020. This project is a Chrome extension on
allow attackers to get L3 RoT without specific knowledge of
Windows that contains a hard-coded value of an RSA key
the underlying obfuscation in an automated matter.
pair used by Widevine L3. Hadad mentioned that he extracted
As explained in subsection V-A, the Widevine RoT is the RSA private key “by applying some mathematical tricks to
encapsulated inside a keybox that is used to initiate the key Arxan’s whitebox algorithm”, before releasing a full writeup
ladder in order to retrieve clear content. Starting by certificate after Google’s patch. Unlike Buchanan, Hadad explained that
provisioning, the RoT is also used in L3 to protect the received the L3 RoT in Chrome browsers is a whitebox of RSA, and not
Device RSA Key for persistent storage (i.e. rewrap operation) AES. In November 2020, Google issued a DMCA takedown
or using keybox related data in device blob. Accordingly, we request against widevine-l3-decryptor and all its forks [23],
build the following approach to recover L3 RoT. We know proving that L3 security is still seen by Google as a serious
that, by design, the RoT must somehow be loaded during the matter. In a BlackHat Asia talk, Zhao [24] explained how
execution of the Widevine protocol, but the applied obfusca- he broke into Widevine L1 within the TEE to recover the
tion hides the loaded RoT. Here, we rely on WideXtractor Widevine keybox of a Pixel 4. However, he did not show how
to better discern the moment, where the RoT is actually in a recovered keybox can be used to decrypt protected contents.
the memory in clear. At this point, we dynamically analyze In our work, we took this further step and implemented the
all memory regions used during obfuscated cryptographic cryptographic mechanisms of Widevine.
operations within the Widevine library. We search for the
keybox structure (e.g., magic number, device ID). Thus, we IX. C ONCLUSION
were able to recover the L3 keybox on a Nexus 5, including In this paper, we presented the undocumented closed-source
the 128-bit AES Device Key, due to an insecure storage of Widevine protocol with its cryptographic components. By
sensitive information (CWE-922). Technical details can be reverse engineering the Widevine CDM on Android, we ex-
found in appendix B. Our method is efficient, since we limit tracted the logic behind its key ladder and provisioning phases.
the spatial and temporal memory monitoring. Based on the gained insights, we design WideXtractor, a tool
Responsible Disclosure. Our findings have been timely analyzing the protocol workflow and all message exchanges
reported to all concerned parties following their responsible between clients and distant servers. We show the effectiveness
disclosure process. Netflix was quite responsive and we got of WideXtractor by inspecting the use of Widevine by Netflix,
rewarded via their bug bounty program. Regarding Google thereby uncovering interesting findings about Netflix asset
Widevine, our security report was assigned with the highest protection. Furthermore, we were able to trivially recover
priority within the Google Vulnerability Reward Program the L3 RoT, which allows attackers to obtain any content
(VRP). The Widevine security team investigated our findings of sub-HD quality. Being widely deployed, DRM security
and issued a patch to mitigate our identified flaws. Google becomes critical. Our objective is to encourage and foster
assigned the CVE-2021-0639 for us, and acknowledged us in further research about DRM-related technologies.
10
R EFERENCES A PPENDIX A
[1] D. Dorwin, J. Smith, M. Watson, and A. Bateman, “Encrypted Media OEM C RYPTO L IBRARY S YMBOLS E QUIVALENTS
Extensions,” https://www.w3.org/TR/encrypted-media/, 2019.
[2] H. Halpin, “The Crisis of Standardizing DRM: The Case of W3C Symbols OEMCrypto Functions Symbols OEMCrypto Functions
Encrypted Media Extensions,” in SPACE, ser. Lecture Notes in Computer oecc01 Initialize oecc25 Generic Decrypt
Science, vol. 10662. Springer, 2017, pp. 10–29. oecc02 Terminate oecc26 Generic Sign
oecc03 InstallKeybox oecc27 Generic Verify
[3] Google Widevine, “Widevine,” https://widevine.com/. oecc04 GetKeyData oecc28 GetHDCPCapability
[4] ISO/IEC, “Common encryption in ISO Base Media File Format files - oecc05 IsKeyboxValid oecc29 SupportsUsageTable
2nd Edition,” 2015. oecc06 GetRandom oecc30 UpdateUsageTable
[5] D. McCullagh, “Security warning draws DMCA threat,” https:// oecc07 GetDeviceID oecc31 DeactivateUsageEntry
www.cnet.com/news/security-warning-draws-dmca-threat/, 2002. oecc08 WrapKeybox oecc32 ReportUsage
oecc09 OpenSession oecc33 DeleteUsageEntry
[6] Electronic Frontier Foundation, “Reported Case List,” https: oecc10 CloseSession oecc34 DeleteUsageTable
//www.eff.org/files/2016/03/17/1201 reported case list revised.xls, oecc11 DecryptCTR oecc35 LoadKeys*
2017. oecc12 GenerateDerivedKeys oecc36 GenerateRSASignature*
[7] MITRE, “CVE List,” https://cve.mitre.org, 2022. oecc13 GenerateSignature oecc37 GetMaxNumberOfSessions
[8] Fortune Business Insights, “Over The Top services market to reach USD oecc14 GenerateNonce oecc38 GetNumberofOpenSessions
oecc15 LoadKeys* oecc39 isAntiRollbackHwPresent
139.00 billion in 2028; emergence of Smart TVs by various companies
oecc16 RefreshKeys oecc40 CopyBuffer
to bolster growth,” https://www.globenewswire.com/news-release/ oecc17 SelectKey* oecc41 QueryKeyControl
2021/08/17/2281647/0/en/Over-The-Top-Services-Market-to-Reach- oecc18 RewrapDeviceRSAKey oecc42 LoadTestKeybox
USD-139-00-Billion-in-2028-Emergence-of-Smart-TVs-by-Various- oecc19 LoadDeviceRSAKey oecc43 ForceDeleteUsageEntry
Companies-to-Bolster-Growth-states-Fortune-Business-Insights.html, oecc20 GenerateRSASignature* oecc44 GetHDCPCapability
2022. oecc21 DeriveKeysFromSessionKey oecc45 LoadTestRSAKey
oecc22 APIVersion oecc46 Security Patch Level
[9] G. Beniamini, “QSEE privilege escalation vulnerability and ex- oecc23 GetSecurityLevel oecc47 LoadKeys*
ploit (CVE-2015-6639),” https://bits-please.blogspot.com/2016/05/qsee- oecc24 Generic Encrypt oecc48 DecryptCENC
privilege-escalation-vulnerability.html, 2016. * Duplicated entries differ in version.
[10] Google, “Factory Images for Nexus and Pixel Devices,” https://
developers.google.com/android/images.
[11] National Security Agency, “Ghidra SRE.” https://ghidra-sre.org/. A PPENDIX B
[12] “Radare2,” https://rada.re/n/. L3 K EYBOX R ECOVERY
[13] O. A. V. Ravnås, “Frida,” https://frida.re/.
[14] Widevine, “Widevine DRM,” https://www.widevine.com/solutions/ Being the root of trust, we are motivated to recover the
widevine-drm. keybox. Widevine maintains a different keybox for the differ-
[15] C. Garman, M. Green, G. Kaptchuk, I. Miers, and M. Rushanan, “Danc-
ing on the Lip of the Volcano: Chosen Ciphertext Attacks on Apple ent levels of security. In subsection V-A, we explained that
iMessage,” in USENIX Security Symposium. USENIX Association, L1 protection is TEE-dependent. In QSEE, it is based on the
2016, pp. 655–672. Secure File System, whose security is outside the scope of
[16] Android, “Protect against security threats with SafetyNet,” https://
developer.android.com/training/safetynet, 2022. this paper. Here, we will focus on L3 keybox. Note that L3
[17] The Verge, “Netflix surpasses 200 million subscribers, but has more implementations are diverse. Our analysis shows that Widevine
competition than ever in 2021,” https://www.theverge.com/2021/1/ is as secure as the weakest one, since license keys for a given
19/22238877/netflix-200-million-subscribers-q4-earnings-bridgerton-
emily-paris-cobra-kai-queens-gambit, 2022. media are shared among all L3 implementations. Therefore,
[18] Can I Use, “Encrypted Media Extensions,” https://caniuse.com/eme, someone might take advantage of outdated implementations
2022. to break into Widevine. Indeed, they can intentionally display
[19] Google, “Eme Call and Event Logger,” https://
chrome.google.com/webstore/detail/eme-call-and-event-logger/ content on vulnerable smartphones, so that they can easily
cniohcjecdcdhgmlofniddfoeokbpbpb, 2022. recover protected media. This works as long as OTT platforms
[20] L. Wouters, B. Gierlichs, and B. Preneel, “My other car is your car: keep support for old Android smartphones, as they target wide
compromising the Tesla Model X keyless entry system,” IACR Trans.
Cryptogr. Hardw. Embed. Syst., vol. 2021, no. 4, pp. 149–172, 2021. audience. In this paper, we study the L3 of Google Nexus 5
[Online]. Available: https://doi.org/10.46586/tches.v2021.i4.149-172 that still runs many OTT apps.
[21] T. Kröll, S. Kleber, F. Kargl, M. Hollick, and J. Classen, “ARIstoteles By taking a closer look at libwvdrmengine.so, we
- Dissecting Apple’s Baseband Interface,” in Computer Security -
ESORICS 2021 - 26th European Symposium on Research in Computer notice that OEMCrypto L3 functions are obfuscated. This
Security, Darmstadt, Germany, October 4-8, 2021, Proceedings, Part I, makes our analysis more complex, since the keybox is only
ser. Lecture Notes in Computer Science, E. Bertino, H. Shulman, and used within these functions. Moreover, we find that all ob-
M. Waidner, Eds., vol. 12972. Springer, 2021, pp. 133–151. [Online].
Available: https://doi.org/10.1007/978-3-030-88418-5 7 fuscated functions apply anti-reverse transformations, such as
[22] David Buchanan, “Breaking Widevine L3 on Linux Chrome browser,” control flow flattening, that make static analysis less relevant.
https://twitter.com/david3141593/status/1080606827384131590, 2019. In addition, memory regions are mapped with read and exe-
[23] Github, “DMCA,” https://github.com/github/dmca/blob/master/2020/11/
2020-11-09-Google.md, 2020. cute permissions. Because of ARM architecture blurring line
[24] Q. Zhao, “Wideshears: Investigating and breaking widevine on QTEE,” between code and data, we find it hard to tell if these mapped
BlackHat Asia, 2021. regions are destined for data to load or code to execute.
The approach that we followed to recover the keybox was
not to directly break into the layer of obfuscation. This would
have made of our work technology-dependent, while we aim
for more long-term lessons. Instead, we stepped back and
monitored the unprotected functions calling the OEMCrypto
interface using WideXtractor. Indeed, we notice that most
functions of libwvdrmengine.so are not protected. Thus,
11
we managed to collect a lot of memory data loaded during the
execution of the obfuscated functions. Of particular interest,
we were able to observe all memory unmapping that happens
through calls to munmap. We noticed that the OEMCrypto
functions load a significant amount of data though these calls
especially sensitive ones.
Thus, our next target is to look for a function requiring
the keybox for its operations. We recall that the keybox
is regularly used in OEMCrypto_LoadDeviceRSAKey to
decrypt the rewrapped Device RSA Key in L3 mode, but
also during device blob creation with OEMCrypto methods
like GetDeviceID or GetKeyData. Accordingly, these
functions map a proper region of memory for the keybox, loads
the keybox value inside it, and finally unmaps that region at
the end of the function. Because of the obfuscation, it is hard
to observe the loading step. However, these functions do not
clear the memory before unmapping. Therefore, we retrieved
the content of the unmapped regions. Then, relying on what
we know about the keybox, we filtered this content to keep the
regions of size 128 bytes including the keybox magic number.
It turns out that there is only one. We verify our finding
by checking the CRC-32 value. The keybox being recovered,
we can now decrypt the license keys, hence the video tracks
destined to L3. It is worth noting that this is particularly
interesting, especially that we did not even get to break into
the underlying obfuscation. In fact, our analyses were guided
by the conceptual structure of the Widevine protocol.
12