eSIM / Java Card VM Exploitation
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Learn & practice Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)
Support HackTricks
- Check the subscription plans!
- Join the π¬ Discord group or the telegram group or follow us on Twitter π¦ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
Overview
Embedded SIMs (eSIMs) are implemented as Embedded UICC (eUICC) smart-cards that run a Java Card Virtual Machine (JC VM) on top of a secure element.
Because profiles and applets can be provisioned over-the-air (OTA) via Remote SIM Provisioning (RSP), any memory-safety flaw inside the JC VM instantly becomes a remote code-execution primitive inside the most privileged component of the handset.
This page describes a real-world full compromise of Kigenβs eUICC (Infineon SLC37 ESA1M2, ARM SC300) caused by missing type-safety checks in the getfield
and putfield
bytecodes. The same technique can be re-used against other vendors that omit on-card byte-code verification.
Attack Surface
- Remote Application Management (RAM)
eSIM profiles may embed arbitrary Java Card applets. Provisioning is performed with standard APDUs that can be tunnelled through SMS-PP (Short Message Service Point-to-Point) or HTTPS. If an attacker owns (or steals) the RAM keys for a profile, they canINSTALL
/LOAD
a malicious applet remotely. - Java Card byte-code execution
After installation, the applet executes inside the VM. Missing run-time checks allow memory corruption.
The Type-Confusion Primitive
getfield
/ putfield
are supposed to operate only on object references. In Kigen eUICC the instructions never validate whether the operand on the stack is an object or an array reference. Because an array.length
word lives at the exact same offset as the first instance field of a normal object, an attacker can:
- Create a byte-array
byte[] buf = new byte[0x100];
- Cast it to
Object o = (Object)buf;
- Use
putfield
to overwrite any 16-bit value inside an adjacent object (including VTABLE / ptr translation entries). - Use
getfield
to read arbitrary memory once internal pointers are hijacked.
// Pseudo-bytecode sequence executed by the malicious applet
// buf = newarray byte 0x100
// o = (Object) buf // illegal but not verified
// putfield <victimObject+offset>, 0xCAFE // arbitrary write
// ... set up read-what-where gadgets ...
The primitive provides arbitrary read / write in the eUICC address space β enough to dump the device-unique ECC private key that authenticates the card to the GSMA ecosystem.
End-to-End Exploitation Workflow
- Enumerate firmware β Use undocumented
GET DATA
itemDF1F
:80 CA DF 1F 00 // β "ECu10.13" (vulnerable)
- Install malicious applet OTA β Abuse publicly-known keys of the TS.48 Generic Test Profile and push SMS-PP fragments that transport the CAP file (
LOAD
) followed by anINSTALL
:// simplified APDU chain 80 E6 02 00 <data> // LOAD (block n) 80 E6 0C 00 <data> // INSTALL for load
- Trigger type-confusion β When the applet is selected it performs the write-what-where to hijack a pointer table and leak memory through normal APDU responses.
- Extract GSMA certificate key β Private EC key is copied to the appletβs RAM and returned in chunks.
- Impersonate the eUICC β The stolen key pair + certificates let the attacker authenticate to any RSP server as a legitimate card (EID binding may still be required for some operators).
- Download and modify profiles β Plaintext profiles contain highly sensitive fields such as
OPc
,AMF
, OTA keys and even additional applets. The attacker can:- Clone a profile to a second eUICC (voice/SMS hijack);
- Patch Java Card applications (e.g. insert STK spyware) before re-uploading;
- Extract operator secrets for large-scale abuse.
Cloning / Hijacking Demonstration
Installing the same profile on PHONE A and PHONE B results in the Mobile Switching Centre routing incoming traffic to whichever device most recently registered. One session of Gmail 2FA SMS interception is enough to bypass MFA for the victim.
Automated Test & Exploit Toolkit
The researchers released an internal tool with a bsc
(Basic Security Check) command that immediately shows whether a Java Card VM is vulnerable:
scard> bsc
- castcheck [arbitrary int/obj casts]
- ptrgranularity [pointer granularity/tr table presence]
- locvaraccess [local variable access]
- stkframeaccess [stack frame access]
- instfieldaccess [instance field access]
- objarrconfusion [object/array size field confusion]
Modules shipped with the framework:
introspector
β full VM and memory explorer (~1.7 MB Java)security-test
β generic verification bypass applet (~150 KB)exploit
β 100 % reliable Kigen eUICC compromise (~72 KB)
Mitigations
- On-card byte-code verification β enforce full control-flow & data-flow type tracking instead of stack-top only.
- Hide array header β place
length
outside of overlapping object fields. - Harden RAM keys policy β never ship profiles with public keys; disable
INSTALL
in test profiles (addressed in GSMA TS.48 v7). - RSP server side heuristics β rate-limit profile downloads per EID, monitor geographic anomalies, validate certificate freshness.
Quick Checklist for Pentesters
- Query
GET DATA DF1F
β vulnerable firmware stringECu10.13
indicates Kigen. - Check if RAM keys are known β> attempt OTA
INSTALL
/LOAD
. - After applet installation, brute-force simple cast primitive (
objarrconfusion
). - Try to read Security Domain private keys β success = full compromise.
References
- Security Explorations β eSIM security
- GSMA TS.48 Generic Test Profile v7.0
- Java Card VM Specification 3.1
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Learn & practice Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)
Support HackTricks
- Check the subscription plans!
- Join the π¬ Discord group or the telegram group or follow us on Twitter π¦ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.