Skip to content

Reject empty hash in tlv_get_hash - #1098

Merged
cedelavergne-ledger merged 1 commit into
developfrom
cev/fix_fuz_issue
Aug 13, 2026
Merged

cedelavergne-ledger merged 1 commit into
developfrom
cev/fix_fuz_issue

Conversation

@cedelavergne-ledger

Copy link
Copy Markdown
Contributor

Description

Fix to prevent use of uninitialized memory

When hash.size == 0 after TLV extraction, the memmove was skipped but the function still returned true, leaving the caller's output buffer uninitialized. Detected by MemorySanitizer via ClusterFuzzLite in handle_selector.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Tests
  • Documentation
  • Other (for changes that might not fit in any category)

@cedelavergne-ledger
cedelavergne-ledger requested a review from a team as a code owner August 13, 2026 12:20
@codecov-commenter

codecov-commenter commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.49%. Comparing base (01e923d) to head (6e5bdea).

❗ There is a different number of reports uploaded between BASE (01e923d) and HEAD (6e5bdea). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (01e923d) HEAD (6e5bdea)
unittests 2 1
functionaltests 2 1
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1098       +/-   ##
============================================
- Coverage    87.61%   74.49%   -13.12%     
============================================
  Files          139      162       +23     
  Lines         9913    14623     +4710     
  Branches      1661     3505     +1844     
============================================
+ Hits          8685    10893     +2208     
- Misses        1029     3489     +2460     
- Partials       199      241       +42     
Flag Coverage Δ
functionaltests 81.48% <100.00%> (+0.01%) ⬆️
fuzzing 42.52% <100.00%> (?)
unittests 86.76% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-code-quality

github-code-quality Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C

C / code-coverage/unittests

The overall coverage in commit 6e5bdea in the cev/fix_fuz_issue branch is 93%. Coverage data for the develop branch is not yet available.

Show a code coverage summary of the most covered files.
File develop cev/fix_fuz_issue 6e5bdea +/-
src/uint256.c — 100% —
src/plugins/eth...lugin_handler.c — 97% —
src/features/ge...ser/gtp_field.c — 95% —
src/features/si...x/eth_ustream.c — 94% —
src/features/ge...gtp_param_raw.c — 94% —
src/features/pr.../trusted_name.c — 90% —
src/features/pr...md_get_gating.c — 89% —
src/features/ge...gtp_data_path.c — 89% —
src/features/pr...tx_simulation.c — 89% —
src/features/si...logic_sign_tx.c — 83% —

Updated August 13, 2026 16:48 UTC

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

elf sizes
source = source branch cev/fix_fuz_issue
target = target branch develop

Device .text source .text target .text delta .bss source .bss target .bss delta max stack size source max stack size target max stack size delta
nanox 125283 125283 0 21972 21972 0 8192 8192 0
nanos2 125539 125539 0 21956 21956 0 18996 18996 0
flex 191821 191821 0 23260 23260 0 13596 13596 0
apex_p 171161 171161 0 23260 23260 0 17692 17692 0
stax 191742 191742 0 23260 23260 0 13596 13596 0

Stack consumption summary (clone_app_stack_consumption)

⚠️ This summary is for informative purpose only. It may not give the application actual worst case, for example if the test coverage is low.

Device Worst case (bytes) Remaining stack (bytes) Test
apex_p 2833 37755 test_clone.py::test_clone_thundercore_tx[apex_p]
flex 2881 33611 test_clone.py::test_clone_thundercore_tx[flex]
nanosp 2705 38071 test_clone.py::test_clone_thundercore_tx[nanosp]
nanox 2697 25791 test_clone.py::test_clone_thundercore_tx[nanox]
stax 2881 33611 test_clone.py::test_clone_thundercore_tx[stax]

Full details

Stack consumption summary

⚠️ This summary is for informative purpose only. It may not give the application actual worst case, for example if the test coverage is low.

Device Worst case (bytes) Remaining stack (bytes) Test
apex_p 5821 11871 test_gcs_formatters.py::test_gcs_group_sequential[apex_p]
flex 5821 7775 test_gcs_formatters.py::test_gcs_group_sequential[flex]
nanosp 5829 13167 test_gcs_formatters.py::test_gcs_group_sequential[nanosp]
nanox 5833 859 test_gcs_formatters.py::test_gcs_group_sequential[nanox]
stax 5821 7775 test_gcs_formatters.py::test_gcs_group_sequential[stax]

Full details

@cedelavergne-ledger
cedelavergne-ledger force-pushed the cev/fix_fuz_issue branch 2 times, most recently from a939c61 to 9cec596 Compare August 13, 2026 12:58
… stack reads

Passing min_size=0 to get_buffer_from_tlv_data allowed TLV payloads shorter
than the destination buffer to pass validation. memmove would then copy fewer
bytes than the buffer size, leaving the remainder uninitialized on the stack,
which any subsequent memcmp would read.

Fix by passing size as both min and max, enforcing an exact match. Rename the
parameter from max_size to size to reflect this stricter contract.
@github-actions

Copy link
Copy Markdown
Contributor

Code coverage report

Code Coverage

Per-file coverage
Package Line Rate Branch Rate Health
src 99% 98% ✔
src.features.generic_tx_parser 93% 81% ✔
src.features.get_app_configuration 100% 100% ✔
src.features.get_challenge 100% 100% ✔
src.features.get_eth2_public_key 98% 93% ✔
src.features.get_public_key 98% 97% ✔
src.features.perform_privacy_operation 98% 86% ✔
src.features.provide_enum_value 96% 87% ✔
src.features.provide_erc20_token_information 94% 88% ✔
src.features.provide_gating 89% 82% ✔
src.features.provide_map_entry 93% 76% ✔
src.features.provide_network_info 90% 82% ✔
src.features.provide_nft_information 91% 80% ✔
src.features.provide_proxy_info 97% 89% ✔
src.features.provide_safe_account 95% 88% ✔
src.features.provide_trusted_name 90% 82% ✔
src.features.provide_tx_simulation 89% 85% ✔
src.features.set_eth2_withdrawal_index 100% 100% ✔
src.features.set_external_plugin 89% 80% ✔
src.features.set_plugin 95% 90% ✔
src.features.sign_authorization_eip7702 87% 80% ✔
src.features.sign_message 89% 76% ✔
src.features.sign_tx 89% 79% ✔
src.nbgl 97% 87% ✔
src.plugins.eip7002 95% 87% ✔
src.plugins.eip7251 97% 87% ✔
src.plugins.erc1155 91% 81% ✔
src.plugins.erc20 91% 86% ✔
src.plugins.erc721 94% 86% ✔
src.plugins.eth2 94% 90% ✔
src.plugins 97% 91% ✔
src.plugins.swap_with_calldata 98% 94% ✔
src.swap 96% 93% ✔
src.utils 93% 90% ✔
Summary 93% (6905 / 7442) 84% (3376 / 4023) ✔

@cedelavergne-ledger
cedelavergne-ledger merged commit c29d818 into develop Aug 13, 2026
321 checks passed
@cedelavergne-ledger
cedelavergne-ledger deleted the cev/fix_fuz_issue branch August 13, 2026 17:07
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