Skip to content

lf t55xx: fix the help text leak, dump fails on an incomplete page 0 - #3850

Merged
iceman1001 merged 3 commits into
RfidResearchGroup:masterfrom
matrix:fix-lf-t55xx-help-leak
Nov 22, 2026
Merged

iceman1001 merged 3 commits into
RfidResearchGroup:masterfrom
matrix:fix-lf-t55xx-help-leak

Conversation

@matrix

@matrix matrix commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Problem

  • arg_add_t55xx_downloadlink() builds the help texts of --r0 to --r3 and --all with calloc() on every call. argtable keeps the pointers and never frees them. The 16 lf t55xx commands that use the helper leak 224 bytes per call, 280 when they have --all (detect, chk, bruteforce, recoverpw).
  • lf t55xx dump saves the file only when all of page 0 is read, but returns PM3_SUCCESS either way, without a message. With no tag it prints an empty table and exits with 0.

Change

client/src/cmdlft55xx.c:

  • arg_add_t55xx_downloadlink(): the five help texts are static buffers of 56 bytes, filled as before. They take 280 bytes for the life of the client, and the helper no longer has an allocation that can fail.
  • CmdT55xxDump(): when a block of page 0 is not read, it prints Page 0 not read in full and returns PM3_ESOFT. The check comes before --ns, as in lf em 4x05 dump. The save code loses its if (success) and moves one level left, otherwise unchanged.

Behaviour change

  • The help texts are the same.
  • lf t55xx dump, with or without --ns, returns an error when page 0 is not read in full.

Testing

Proxmark3 RDV2 with the firmware of master 6d4ee98, the clients of master and of this branch, 3 runs per case.

Case master this branch
each of the 16 commands with -h, clients built with SANITIZE=1, 1 run 224 bytes leaked, 280 for the four with --all no leak, help text identical to master
lf t55xx detect; lf t55xx dump -f <file> on a T5577, SANITIZE=1 504 bytes leaked no leak, the same file
lf t55xx detect; lf t55xx dump -f <file> on a T5577 48 bytes saved, exit 0 the same file, exit 0
lf t55xx detect; lf t55xx dump --ns on a T5577 nothing saved, exit 0 nothing saved, exit 0
lf t55xx dump -f <file> without a tag no file, no message, exit 0 Page 0 not read in full, exit 246 (PM3_ESOFT)
lf t55xx dump --ns without a tag exit 0 Page 0 not read in full, exit 246

Builds

  • Linux: gcc, clang, CMake and experimental_lib clients and the six platforms without warnings, make check 319 passed, 0 failed, 8 skipped.
  • macOS: the six platforms, make check 319 passed, 0 failed, 8 skipped. The only warnings are the linker's -bind_at_load is deprecated.

Not tested

  • A T5577 with a password.
  • Windows.

Checklist

  • Proper style of own code, no unrelated reformatting included
  • Builds warning-free with gcc, also tried with clang
  • client/Makefile, client/CMakeLists.txt, and client/experimental_lib/CMakeLists.txt all updated if client sources changed (no file added, all three built)
  • ARM firmware builds clean for RDV4 and PM5 platform configs (no firmware change, all six platforms built)
  • Platform-sensitive code reasoned about / tested on Linux, Windows (ProxSpace/WSL), and macOS (if applicable): built and make check on Linux and macOS, device tests from Linux
  • Existing comments in touched files preserved
  • New comments short and direct, no restated code or PR prose
  • doc/commands.md / doc/commands.json left untouched

matrix and others added 3 commits November 15, 2026 12:15
arg_add_t55xx_downloadlink() allocated the help texts of --r0 to --r3
and --all with calloc() on every call. argtable keeps the pointers and
never frees them, so the 16 lf t55xx commands that use the helper
leaked 224 bytes per call, 280 with --all. The texts are now static
buffers.

lf t55xx dump saved the file only when all of page 0 was read, but
returned success either way, without a message. It now prints "Page 0
not read in full" and returns PM3_ESOFT, also with --ns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Gabriele Gristina <matrix@users.noreply.github.com>
Signed-off-by: Iceman <iceman@iuse.se>
@iceman1001
iceman1001 merged commit 972891a into RfidResearchGroup:master Nov 22, 2026
0 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants