fix: Integer wrap in external-plugin review pair count causes out-of-bounds writes in ui_approve_tx#1009
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1009 +/- ##
========================================
Coverage 56.10% 56.10%
========================================
Files 26 26
Lines 2417 2417
Branches 322 317 -5
========================================
Hits 1356 1356
+ Misses 1057 1017 -40
- Partials 4 44 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1202702 to
866920d
Compare
Contributor
|
elf sizes
Stack consumption summary (clone_app_stack_consumption)
Stack consumption summary
|
…bounds writes in ui_approve_tx
866920d to
77f9112
Compare
apaillier-ledger
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1008
Summary
Automated security fix for Integer wrap in external-plugin review pair count causes out-of-bounds writes in ui_approve_tx (High).
CWE: CWE-787
OWASP: A04:2021-Insecure Design
Fix Confidence: high
What Changed
The vulnerability is an integer overflow when computing
pluginUiMaxItemsfrom plugin-reported screen counts. Twouint8_tvalues (pluginFinalize.numScreensandpluginProvideInfo.additionalScreens) are added and stored inuint8_t pluginUiMaxItemswithout overflow checking. This can cause: (1) the sum itself to wrap past 255, and (2) downstreamgetNbPairs()inui_approve_tx.cto wrap when adding up to 3 more items (from address, network, max fees) to the already-large value, leading to a small allocation but large iteration count insetTagValuePairs(), causing OOB writes tog_pairs.The fix adds a validation check in
logic_sign_tx.cat the point wherepluginUiMaxItemsis assigned. It computes the sum usinguint16_tto prevent truncation, then rejects the transaction if the total exceeds 252 (leaving room for the 3 additional UI pairs thatgetNbPairsmay add, ensuring the downstreamuint8_taccumulator ingetNbPairscannot exceed 255). This single check at the source prevents both the source overflow and the downstream accumulation overflow.Caveats
Verification Checklist
Created by Cerberus Merlin