Skip to content

First iterative step to extend Fuzzing framework coverage on NBGL (nbgl page addon)#1625

Open
iartemov-ledger wants to merge 2 commits into
masterfrom
fuzzing-framework_nbgl_page_addon
Open

First iterative step to extend Fuzzing framework coverage on NBGL (nbgl page addon)#1625
iartemov-ledger wants to merge 2 commits into
masterfrom
fuzzing-framework_nbgl_page_addon

Conversation

@iartemov-ledger

@iartemov-ledger iartemov-ledger commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

  • add nbgl_page self-fuzz target
  • fix uint16_t underflow in page content layout

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
  • Fuzzing
  • Documentation
  • Other (for changes that might not fit in any category)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it.

Additional comments

Please post additional comments in this section if you have them, otherwise delete it.

Auto cherry-pick in API_LEVEL

If requested to port the commits from this PR on a dedicated API_LEVEL branch,
select the targeted one(s), or add new references if not listed:

[x] TARGET_API_LEVEL: API_LEVEL_26

This will only create the PR with cherry-picks, ready to be reviewed and merged.

Remember:

  • The merge will ALWAYS be a manual operation.
  • It is possible the cherry-picks don't apply correctly, mainly if previous commits have been forgotten.
  • In case of failure, there is no other solution than redo the operation manually...

@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.00%. Comparing base (e604aba) to head (2c8bc15).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1625   +/-   ##
=======================================
  Coverage   92.00%   92.00%           
=======================================
  Files          39       39           
  Lines        4653     4653           
  Branches      597      597           
=======================================
  Hits         4281     4281           
  Misses        258      258           
  Partials      114      114           
Flag Coverage Δ
unittests 92.00% <ø> (ø)

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.

@N3ur0sis
N3ur0sis force-pushed the aro/fuzzing-framework branch 3 times, most recently from 49b4056 to 7813e8c Compare July 6, 2026 11:56
@iartemov-ledger
iartemov-ledger force-pushed the fuzzing-framework_nbgl_page_addon branch from c2495ff to 4720cd5 Compare July 6, 2026 18:36
@N3ur0sis
N3ur0sis force-pushed the aro/fuzzing-framework branch 2 times, most recently from 27b7984 to 338b423 Compare July 7, 2026 09:06
Base automatically changed from aro/fuzzing-framework to master July 7, 2026 09:21
@iartemov-ledger
iartemov-ledger marked this pull request as draft July 10, 2026 12:13
@iartemov-ledger
iartemov-ledger force-pushed the fuzzing-framework_nbgl_page_addon branch 5 times, most recently from 156d307 to 4aed611 Compare July 17, 2026 08:54
@iartemov-ledger iartemov-ledger changed the title Fuzzing framework nbgl page addon First iterative step to extend Fuzzing framework coverage on NBGL (nbgl page addon) Jul 17, 2026
@iartemov-ledger
iartemov-ledger marked this pull request as ready for review July 17, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the SDK self-fuzzing (“Absolution”) coverage to NBGL page/layout construction and fixes a height-accounting underflow in nbgl_page rendering, improving robustness when building complex page contents.

Changes:

  • Fixes a uint16_t underflow risk in NBGL page content layout by using a signed availableHeight.
  • Adds a new fuzz_nbgl_page harness that exercises multiple nbgl_page* entry points with fuzzed content.
  • Registers the new fuzzer in the fuzz manifest and build system.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib_nbgl/src/nbgl_page.c Switch availableHeight to signed to prevent underflow during layout height bookkeeping.
fuzzing/sdk-fuzz/harness/fuzz_nbgl_page.c New fuzzer harness generating NBGL page content and invoking page constructors.
fuzzing/sdk-fuzz/fuzz-manifest.toml Adds the fuzz_nbgl_page target and a small dictionary for seeding.
fuzzing/sdk-fuzz/CMakeLists.txt Adds fuzz_nbgl_page to the fuzzer target list and build configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fuzzing/sdk-fuzz/harness/fuzz_nbgl_page.c
@iartemov-ledger
iartemov-ledger force-pushed the fuzzing-framework_nbgl_page_addon branch from 4aed611 to e10e1e4 Compare July 17, 2026 13:59
New sdk-fuzz target `fuzz_nbgl_page` exercising the NBGL page/layout
construction layer (lib_nbgl/src/nbgl_page.c + nbgl_layout.c). That layer is
compiled from source and instrumented, while the display/HAL layer stays
mocked (fuzzing/mock/nbgl).

The harness builds a fuzzed nbgl_pageContent_t from the input tail and drives
three entry points:
  - nbgl_pageDrawGenericContent with 6 content types (TAG_VALUE_LIST,
    SWITCHES_LIST, INFOS_LIST, CHOICES_LIST, BARS_LIST, CENTERED_INFO)
  - nbgl_pageDrawInfo
  - nbgl_pageDrawConfirmation
Strings are carved from the tail into a bounded pool and item arrays are
clamped. No new link deps: secure_sdk already pulls in nbgl + the HAL mock.
Found by SDK fuzzing (UBSan implicit-signed-integer-truncation):
availableHeight is a uint16_t decremented by the height each list item consumes.
When content is taller than the screen it underflows to a large value,
defeating the `availableHeight > 10` guard meant
to stop drawing separation lines near the bottom of the container.

Make availableHeight signed (int) in addContent() and
nbgl_pageDrawGenericContentExt(); the > 10 comparisons stay correct.
@iartemov-ledger
iartemov-ledger force-pushed the fuzzing-framework_nbgl_page_addon branch from e10e1e4 to 2c8bc15 Compare July 17, 2026 14:01
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.

3 participants