Skip to content

Commit edd1a85

Browse files
authored
Merge pull request #2304 from HackTricks-wiki/research_update_src_generic-hacking_esim-javacard-exploitation_20260531_135717
Research Update Enhanced src/generic-hacking/esim-javacard-e...
2 parents 3c146d4 + 2e04393 commit edd1a85

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

‎src/generic-hacking/esim-javacard-exploitation.md‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ This page describes a real-world full compromise of Kigen’s eUICC (Infineon SL
1515
After installation, the applet executes inside the VM. Missing run-time checks allow memory corruption.
1616

1717
### 2024–2025 ecosystem changes
18-
* **GSMA TS.48 v7.0 (18 Jun 2025)** removed public RAM keysets from the Generic Test Profile and blocks `INSTALL` unless randomized keys are provided; cached v≤6 profiles still expose static RAM keys and remain exploitable.
19-
* **GSMA AN‑2025‑07 (09 Jul 2025)** recommends on-card bytecode verification; most eUICCs still skip full verification so VM memory bugs stay reachable after applet install.
20-
* **Kigen OTA hardening (Jul 2025)** blocks applet loading when legacy TS.48 test profiles are active and adds runtime checks, but unpatched devices stay vulnerable.
18+
* **TS.48 v7.x rollout** – the public GSMA TS.48 repository now deprecates all Generic Test Profile versions `v1`–`v6`, tells testers to use `v7.0`, and notes that `v7.1` is only an editorial change. For pentests this matters because many labs, factory images and cached profiles still carry legacy TS.48 material.
19+
* **Security-driven profile restrictions** – public reporting around the `v7.0` change indicates new separation between **Certified** and **Test** eUICCs, deprecation of older public test profiles, and tighter rules around RAM / public credentials in certified-eUICC test scenarios. In practice, old cards and leaked test credentials remain the most valuable entry point.
20+
* **GSMA operator guidance** – 2025 guidance explicitly treats malicious Java Card installation through profile misuse as an ecosystem-level risk, but that does not remove the underlying VM bug from already deployed cards.
21+
* **Vendor OTA mitigations** – Kigen publicly stated that OTA mitigations and a security bulletin were issued in July 2025, but researchers still observed vulnerable cards outside the narrow product descriptions from the bulletin. Treat vendor model lists as hints, not as proof that a target card is safe.
2122

2223
## The Type-Confusion Primitive
2324
`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:
@@ -55,6 +56,12 @@ The primitive provides **arbitrary read / write** in the eUICC address space –
5556
* Patch Java Card applications (e.g. insert STK spyware) before re-uploading;
5657
* Extract operator secrets for large-scale abuse.
5758

59+
### Persistence & Post-Exploitation Targets
60+
Once arbitrary read / write exists, the attacker is not limited to a one-shot ECC key dump:
61+
* **Stealthy firmware patching / backdoor ideas** – Security Explorations described a post-exploitation scenario where normal APDU handlers (for example `GET DATA`) are patched so the card returns sensitive material without re-running the whole exploit chain.
62+
* **Profile tampering** – The researchers explicitly verified that a downloaded profile can be modified offline, loaded into another eUICC and still operate for calls / SMS while carrying an injected custom Java STK app.
63+
* **Secret harvesting order** – In practice, dump the eUICC identity key first, then operator material such as `OPc`, `AMF`, OTA keysets and sensitive applets. Losing OTA keys may be as damaging as stealing the subscriber profile itself.
64+
5865
## Cloning / Hijacking Demonstration
5966
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.
6067

@@ -74,25 +81,40 @@ Modules shipped with the framework:
7481
* `security-test` – generic verification bypass applet (~150 KB)
7582
* `exploit` – 100 % reliable Kigen eUICC compromise (~72 KB)
7683

84+
## Lab Validation Without OTA
85+
If you have a lab card or removable UICC with card-management credentials, you can validate the same applet-loading path locally before moving to SMS-PP / HTTPS delivery:
86+
87+
```bash
88+
verifycap -target 3.1.0 exports/*.exp poc.cap -outfile cap.hashes
89+
pySIM-shell (00:MF)> select ADF.ISD
90+
pySIM-shell (00:MF/ADF.ISD)> establish_scp02 --key-dek <DEK> --key-enc <ENC> --key-mac <MAC> --security-level 1
91+
pySIM-shell (SCP02[01]:00:MF/ADF.ISD)> install_cap ./poc.cap --install-parameters-non-volatile-memory-quota 255 --install-parameters-volatile-memory-quota 255
92+
```
93+
94+
`verifycap` only proves that the CAP is structurally valid against the expected export files. It does **not** protect a target whose VM still lacks run-time type checks. This is useful in practice because it separates **CAP formatting mistakes** from **target-side bytecode verification failures** before you burn OTA attempts or risk key lockout.
95+
7796
## Mitigations
7897
1. **On-card byte-code verification** – enforce full control-flow & data-flow type tracking instead of stack-top only.
7998
2. **Hide array header** – place `length` outside of overlapping object fields.
80-
3. **Harden RAM keys policy** – never ship profiles with public keys; disable `INSTALL` in test profiles (TS.48 v7 removes RAM keysets).
99+
3. **Harden RAM keys policy** – never ship profiles with public or reusable credentials; constrain or disable `INSTALL`/`LOAD` in test profiles and migrate to the `TS.48 v7.x` handling model.
81100
4. **RSP server side heuristics** – rate-limit profile downloads per EID, monitor geographic anomalies, validate certificate freshness.
82-
5. **Keep devices off legacy test profiles** – apply the July 2025 OTA that blocks applet loading with TS.48 v≤6 or remove the test profile from factory images.
101+
5. **Keep devices off legacy test profiles** – retire / remove `TS.48 v≤6` material, apply vendor OTA fixes, and avoid shipping factory images with leftover test profiles.
83102
84103
## Quick Checklist for Pentesters
85-
* Query `GET DATA DF1F` – vulnerable firmware string `ECu10.13` indicates Kigen.
86-
* Inspect loaded profiles: TS.48 test profiles with static RAM keys (v≤6) are directly exploitable; v7 without RAM keys need a new key leak.
104+
* Query `GET DATA DF1F` – `ECu10.13` is a known vulnerable Kigen string, but do **not** assume other returned strings are safe without testing.
105+
* Inspect loaded profiles: legacy TS.48 material and any reusable test credentials are the most valuable entry points; `v7.x` reduces exposure, but cached / preloaded older profiles still matter.
87106
* Check if RAM keys are known ‑> attempt OTA `INSTALL`/`LOAD`.
88-
* After applet installation, brute-force simple cast primitive (`objarrconfusion`).
89-
* Try to read Security Domain private keys – success = full compromise.
107+
* If OTA is unavailable, reproduce locally through ISD access and a secure channel (`SCP02`/equivalent) to confirm that the card accepts your CAP and that failures are due to target-side checks, not packaging mistakes.
108+
* After applet installation, brute-force simple cast primitive (`objarrconfusion`) and prioritize Security Domain / eUICC identity keys before moving to operator secrets.
109+
* Treat vendor advisories as incomplete coverage; run `bsc` or a minimal object/array confusion probe even on cards that do not exactly match the public bulletin wording.
90110
91111
## References
92112
- [Security Explorations – eSIM security](https://security-explorations.com/esim-security.html)
93113
- [GSMA TS.48 Generic Test Profile v7.0](https://www.gsma.com/get-involved/working-groups/gsma_resources/ts-48-v7-0-generic-euicc-test-profile-for-device-testing/)
94114
- [GSMA AN-2025-07 Preventing misuse of an eUICC Profile](https://www.gsma.com/solutions-and-impact/technologies/esim/gsma_resources/an-2025-07-preventing-misuse-of-an-euicc-profile-and-installation-of-malicious-java-card-application-v1-0/)
95115
- [The Hacker News – eSIM vulnerability in Kigen eUICC (July 2025)](https://thehackernews.com/2025/07/esim-vulnerability-in-kigens-euicc.html)
96116
- [Java Card VM Specification 3.1](https://docs.oracle.com/en/java/javacard/3.1/jc-vm-spec/F12650_05.pdf)
117+
- [GSMA public TS.48 Generic eUICC Test Profile repository](https://github.com/GSMATerminals/Generic-eUICC-Test-Profile-for-Device-Testing-Public)
118+
- [Osmocom pySIM – Installing Java Card applets](https://downloads.osmocom.org/docs/pysim/master/html/cap-tutorial.html)
97119
98120
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)