From 579bafa1619abd01dfd2528a7dc0b87ded86a25b Mon Sep 17 00:00:00 2001 From: Ryan4n6 <131580830+Ryan4n6@users.noreply.github.com> Date: Tue, 3 Nov 2026 03:04:17 -0500 Subject: [PATCH 1/3] feat(hf mfu): add weak-PRNG backstop for Ultralight C fingerprint The existing mfulc_fingerprint() detects known counterfeit families (Lab401 DW, Feiju FJ8010, USCUID-UL v1/v2, Giantec GT23SC4489, Hospitality) by their deterministic command and CRC tells, returning early on a match. This commit adds a generic weak-PRNG catch-all for clones that evade those fixed profiles. mfulc_prng_test() runs on the genuine-looking fallthrough, right before the "likely MF0ICU2" verdict. It collects RndB nonces via repeated 1A00 auth starts and flags a duplicate: - Genuine NXP draws RndB from a hardware TRNG (2^64 space), so it never repeats across a realistic batch. - Giantec/USCUID use a 16-bit LFSR whose wakeup-timing seed concentrates the observed pool to roughly 2^6.5, so a duplicate appears within 12 authentications. A single collision is proof of a weak PRNG. This backstop catches weak-RNG clones, including future variants the profile table does not know. MFULC_PRNG_SAMPLES (40) and MFULC_PRNG_CLEAR (39) are tunable. Tested on genuine NXP MF0ULC (UID 04 1C BE 92 E7 7A 80): 40 unique nonces, no collision, verdict "consistent with a genuine TRNG". Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. Co-Authored-By: Claude Opus 4.5 Claude-Session: https://claude.ai/code/session_012e7xUDfDUXJQU7SWV3ULS1 --- client/src/cmdhfmfu.c | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 9255a3a21..9fe55a0ff 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2028,6 +2028,79 @@ int mfu_get_version_uid(uint8_t *version, uint8_t *uid) { return PM3_SUCCESS; } +// Statistical PRNG check (generic weak-RNG backstop). +// Genuine NXP ULC draws RndB from a hardware TRNG (2^64 space), so it never +// repeats across a realistic batch. The common counterfeits (Giantec +// GT23SC4489, USCUID-UL) use a 16-bit LFSR whose wakeup-timing seed +// concentrates the observed RndB pool to ~2^6.5, so a duplicate appears within +// ~12 authentications. A single collision is therefore proof of a weak PRNG. +// This runs only on the genuine-looking fallthrough below (the known +// counterfeit profiles return earlier), so it is the catch-all for weak-RNG +// clones that match none of those profiles, including future variants. +// Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. +#define MFULC_PRNG_SAMPLES 40 +#define MFULC_PRNG_CLEAR 39 // no collision by here => an LFSR pool would have, >99.99% + +static int mfulc_prng_test(uint32_t samples) { + if (samples < 2) { + samples = 2; + } + if (samples > 64) { + samples = 64; + } + + uint8_t rndb[64][8]; + uint32_t got = 0; + + for (uint32_t i = 0; i < samples; i++) { + iso14a_card_select_t card; + if (ul_select(&card) == false) { + continue; + } + uint8_t nonce[11] = {0x00}; + int rl = ulc_requestAuthentication(nonce, sizeof(nonce)); + DropField(); + // response is AF || ek(RndB)[8] || CRC[2]; compare the 8-byte ek(RndB) + if (rl < 9 || nonce[0] != 0xAF) { + continue; + } + memcpy(rndb[got], &nonce[1], 8); + got++; + } + + if (got < 2) { + PrintAndLogEx(INFO, "PRNG......... could not collect nonces (got %u)", got); + return PM3_ESOFT; + } + + uint32_t first_dup = 0; + uint32_t dups = 0; + for (uint32_t i = 0; i < got; i++) { + for (uint32_t j = 0; j < i; j++) { + if (memcmp(rndb[i], rndb[j], 8) == 0) { + if (first_dup == 0) { + first_dup = i + 1; // 1-based draw index + } + dups++; + break; + } + } + } + + if (dups > 0) { + PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("weak") ": repeated RndB (%u dup in %u, first at draw %u)", dups, got, first_dup); + PrintAndLogEx(INFO, " genuine NXP uses a TRNG and never repeats: counterfeit (LFSR) tell"); + return PM3_SUCCESS; + } + + if (got >= MFULC_PRNG_CLEAR) { + PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces, consistent with a genuine TRNG", got); + } else { + PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces (need >= %u for high confidence)", got, (uint32_t)MFULC_PRNG_CLEAR); + } + return PM3_SUCCESS; +} + static int mfulc_fingerprint(void) { iso14a_card_select_t card; PacketResponseNG resp; @@ -2139,6 +2212,9 @@ static int mfulc_fingerprint(void) { } } } + // No known counterfeit profile matched; run the generic weak-PRNG + // backstop before concluding the card is genuine. + mfulc_prng_test(MFULC_PRNG_SAMPLES); PrintAndLogEx(INFO, "likely MF0ICU2"); DropField(); return PM3_SUCCESS; From 0839f3b7083d5639226e50c554ad3f07a29b378d Mon Sep 17 00:00:00 2001 From: Ryan Massfeller Date: Sat, 7 Nov 2026 02:35:38 -0500 Subject: [PATCH 2/3] fix(mfulc): trim verbose comments per review - Remove wall-of-text comment block (moved to PR description) - Simplify output: "Genuine" vs "Weak" per Iceman's feedback - Remove explanatory INFO line Co-Authored-By: Claude Opus 4.5 --- client/src/cmdhfmfu.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 9fe55a0ff..35c885384 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2028,18 +2028,9 @@ int mfu_get_version_uid(uint8_t *version, uint8_t *uid) { return PM3_SUCCESS; } -// Statistical PRNG check (generic weak-RNG backstop). -// Genuine NXP ULC draws RndB from a hardware TRNG (2^64 space), so it never -// repeats across a realistic batch. The common counterfeits (Giantec -// GT23SC4489, USCUID-UL) use a 16-bit LFSR whose wakeup-timing seed -// concentrates the observed RndB pool to ~2^6.5, so a duplicate appears within -// ~12 authentications. A single collision is therefore proof of a weak PRNG. -// This runs only on the genuine-looking fallthrough below (the known -// counterfeit profiles return earlier), so it is the catch-all for weak-RNG -// clones that match none of those profiles, including future variants. -// Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. +// Weak-PRNG backstop: RndB collision => counterfeit LFSR #define MFULC_PRNG_SAMPLES 40 -#define MFULC_PRNG_CLEAR 39 // no collision by here => an LFSR pool would have, >99.99% +#define MFULC_PRNG_CLEAR 39 static int mfulc_prng_test(uint32_t samples) { if (samples < 2) { @@ -2088,15 +2079,14 @@ static int mfulc_prng_test(uint32_t samples) { } if (dups > 0) { - PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("weak") ": repeated RndB (%u dup in %u, first at draw %u)", dups, got, first_dup); - PrintAndLogEx(INFO, " genuine NXP uses a TRNG and never repeats: counterfeit (LFSR) tell"); + PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("Weak") " (RndB collision at %u)", first_dup); return PM3_SUCCESS; } if (got >= MFULC_PRNG_CLEAR) { - PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces, consistent with a genuine TRNG", got); + PrintAndLogEx(SUCCESS, "PRNG......... " _GREEN_("Genuine")); } else { - PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces (need >= %u for high confidence)", got, (uint32_t)MFULC_PRNG_CLEAR); + PrintAndLogEx(INFO, "PRNG......... inconclusive (%u/%u nonces)", got, (uint32_t)MFULC_PRNG_CLEAR); } return PM3_SUCCESS; } @@ -2212,8 +2202,7 @@ static int mfulc_fingerprint(void) { } } } - // No known counterfeit profile matched; run the generic weak-PRNG - // backstop before concluding the card is genuine. + // weak-PRNG backstop mfulc_prng_test(MFULC_PRNG_SAMPLES); PrintAndLogEx(INFO, "likely MF0ICU2"); DropField(); From 9616c8e45c1c28b84c1d2cf750cfdd6c28183a7a Mon Sep 17 00:00:00 2001 From: Ryan Massfeller Date: Sat, 7 Nov 2026 02:44:43 -0500 Subject: [PATCH 3/3] docs: add CHANGELOG entry for ULC PRNG backstop Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e51139e63..6a7ad6bbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) - Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu and CodeQL skip the slow Azure apt mirror (@matrix) - Fixed `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix) +- Added `hf mfu info` weak-PRNG backstop - detects counterfeit ULC via RndB collision (@Ryan4n6) - Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark) - Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes - Fixed client build with `-march=x86-64-v3` (CentOS/RHEL 10 default) - false `-Wstringop-overflow` in the EMV AID list table (@r3wretrhy)