fix(mifare): handle readable Key B fields correctly - #973
Conversation
Greptile SummaryThe PR distinguishes readable MIFARE Classic Key B trailer data from recovered authentication keys.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| chameleonultragui/lib/helpers/mifare_classic/recovery.dart | Adds separate readable-Key-B state management, access-condition decoding, and authentication-key validation. |
| chameleonultragui/lib/gui/component/key_check_marks.dart | Adds the readable-data input and renders readable Key B fields with a distinct tooltip and icon. |
| chameleonultragui/lib/gui/component/mifare/classic.dart | Supplies recovery-readable data to the key-checkmark widget. |
| chameleonultragui/test/key_check_marks_test.dart | Updates the widget test setup for the new required readable-data input. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Recover Key A] --> B[Read sector trailer]
B --> C{Key B field readable?}
C -- No --> D[Continue Key B recovery]
C -- Yes --> E[Extract returned Key B bytes]
E --> F{Usable for memory access?}
F -- Yes --> G[Store in validKeys as found]
F -- No --> H[Store in readableData as readable]
Reviews (2): Last reviewed commit: "feat(mifare): show readable Key B data i..." | Re-trigger Greptile
|
~~ This confirms the GUI does not assume that B is readable merely from expected/test metadata. It only marks B as readable after successfully authenticating to the sector and reading/validating the trailer ACL.~~
|
SummaryFix MIFARE Classic recovery handling for sector trailers where Key B is configured as readable data. Previously, readable Key B fields could remain displayed as failed or unresolved keys even though the sector trailer was successfully readable with Key A. Successful Key B authentication was also not consistently followed by a real memory-access check before the value was accepted as a usable authentication key. This change:
TestingTested against both a physical MIFARE Classic 1K card and a controlled Proxmark3 state-matrix emulator image. Physical card validation
State-matrix regression validation
Build/test validation
|
Current findings and regression testingI completed additional regression testing around the revised Key B handling, including both a physical MIFARE Classic 1K card and a purpose-built Proxmark3 state-matrix image. The current behavior is now:
Physical cardThe physical MIFARE Classic 1K card used for testing has sector trailers configured with Using an A-only dictionary:
This is significant because those B values were not supplied by the dictionary. They were recovered from the card-returned trailer data and independently validated before being accepted. State-matrix regressionA second test used a controlled MIFARE Classic 1K emulator image with mixed sector states:
The emulator follows the expected behavior where the readable The patched GUI produced the expected distinction:
This confirms that the readable state is not inferred simply from the test image or ACL pattern. The GUI must first authenticate with A, successfully read the trailer, and evaluate the returned ACL before classifying the B field. The readable-only values are also now visible directly in the tooltip, for example:
Export regressionThe state-matrix export contained exactly 22 usable authentication keys:
The exported dictionary before and after adding the readable-data tooltip was byte-for-byte equivalent:
This confirms that storing the readable bytes separately for display does not contaminate Build/test regression
At this point the two important cases are both represented correctly: a readable B field can remain data-only when it cannot actually be used as Key B, while a card that returns readable B bytes that also work for memory access can have those values promoted to valid authentication keys. |
## SummaryFix MIFARE Classic recovery handling for sector trailers where Key B is configured as readable data.Previously, these Key B fields could remain displayed as failed/unresolved keys even though the sector trailer was successfully readable with Key A.This change:- adds a distinctreadablestate for Key B- checks the sector trailer access conditions after finding Key A- marks readable Key B fields as resolved without treating them as authentication keys- displays readable Key B fields with a separate visibility icon- keeps readable Key B data out ofvalidKeys- allows the card-returned Key B bytes to remain intact in dumps- prevents readable Key B data from being exported as recovered authentication keys## TestingTested against a physical MIFARE Classic 1K card with readable Key B fields.Verified:- readable Key B fields are displayed distinctly instead of as failed keys- recovered Key A authentication keys remain displayed normally- card-returned Key B field bytes are preserved in the resulting dump- readable Key B data is not exported by "Export found keys"-flutter analyze --no-pubreports no issues related to this change~~ - one unrelated existing deprecation remains in
lib/helpers/font.dart~~-flutter test --no-pub: 18 tests passed- Windows release build completed successfully