Skip to content

[Fix] Issue-564: Sub-Ghz corrupts .sub files randomly after transmit#565

Open
Lechnio wants to merge 1 commit into
Next-Flip:devfrom
Lechnio:Lechniofixissue_564
Open

[Fix] Issue-564: Sub-Ghz corrupts .sub files randomly after transmit#565
Lechnio wants to merge 1 commit into
Next-Flip:devfrom
Lechnio:Lechniofixissue_564

Conversation

@Lechnio

@Lechnio Lechnio commented Jul 11, 2026

Copy link
Copy Markdown

What's new

Fix for issue 564


For the reviewer

  • I've uploaded the firmware with this patch to a device and verified its functionality
  • I've confirmed the bug to be fixed / feature to be stable

lewisQ17 added a commit to lewisQ17/Momentum-Firmware that referenced this pull request Jul 19, 2026
…ext-Flip#443, Next-Flip#564

Memory-safety (attacker-controlled length written into fixed buffers):

* EMV .nfc loader (emv.c, Next-Flip#553): bound file-supplied PAN/AID lengths and
  use length-checked string copies. Fixes 5 heap-overflow write sites.
* EMV poller (emv_poller_i.c): the TLV decoder copied card-supplied
  lengths into fixed struct/stack buffers with no bounds check, reachable
  by tapping a crafted/emulated EMV card. Added emv_tlv_copy_clamped() and
  clamped every copy (AID, application label/name, cardholder name, PAN,
  track1/track2 stack buffers, log fields), fixed the GPO_FMT1 length
  underflow, bounded active_tr into trans[], and validated TLV value
  lengths against the response buffer in both walkers to stop over-reads.
  Clamps are a no-op for well-formed cards.
* FeliCa loader (felica.c): reject a file whose "Blocks total" exceeds the
  fixed dump buffer before the read loop overflows it.
* MIFARE DESFire loader (mf_desfire_i.c): bound the file-supplied access
  rights length to the fixed access_rights[] array.
* bit_lib_get_bits (bit_lib.c, FL-3534): only read the second byte when the
  requested field actually crosses the byte boundary (fixes a 1-byte OOB
  read reachable from 300+ parser call sites; result is bit-identical).
* iso15693_3_is_block_locked (iso15693_3.c): bound the index against the
  block-security array length for legacy/partial files.
* Asset pack loader (asset_packs.c): guard the .bmx frame_size subtraction
  against underflow (corrupt file -> huge malloc).

Bug fixes:

* Next-Flip#538 NTAG21x false "password protected": only hide PWD/PACK pages when the
  tag is actually protected (AUTH0 < page count). AUTH0 = 0xFF (unprotected,
  e.g. after a set-then-clear) now reads as unlocked, matching NFC Tools.
* Next-Flip#443 GuiSrv crash on bad icon: compress_icon_decode() now renders a blank
  icon instead of a furi_check crash when a custom asset-pack icon is
  malformed/oversized (built-in icons are unaffected).
* SubGHz decode-RAW double-free: NULL the file-encoder worker after freeing
  it on a failed start so a later Back event cannot use-after-free it.
* Next-Flip#564 SubGHz RAW .sub corruption after TX: gate the post-TX dynamic
  save-back on transmitting the internal fff_data, plus a RAW guard in
  subghz_save_to_file() (adopts the reviewed community fix from PR Next-Flip#565).

Verified: clean release build (fbt) + updater_package (.tgz). No changes to
the bootloader or radio co-processor stack.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JA9f5sJuwNgBwBNqHWsx2h
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.

1 participant