Repository navigation
Fix secu issues - #1099
Fix secu issues#1099
Conversation
eip712_v1_context_init() now sets appState = APP_STATE_PREPARING_EIP712 on success so that handle_first_sign_chunk()'s APP_STATE_IDLE guard blocks any interleaved INS_SIGN during the struct-definition phase. ui_712_init() restricts its explicit_bzero to strings.tmp.tmp instead of the whole strings union; the EIP-712 init path has no business clearing strings.common, which may belong to another flow.
set_batch_transfer_ui() derived pair_idx from the screen index without checking it against ERC1155_BATCH_DISPLAY_MAX before indexing into batch_ids[] and batch_values[]. An out-of-range screen index would access stale context memory, so return ETH_PLUGIN_RESULT_ERROR instead.
- v1_set_array: reject re-entry when array_remaining > 0 but
array_levels_remaining == 0; prevents re-opening a leaf-level
array frame that is still consuming elements
- filtering handlers: add `if (discarded) return true;` at the
start of the Handling section in all ten filter handlers that
were missing the guard (filtering_calldata_{spender,amount,
selector,chain_id,callee,value}, filtering_trusted_name,
filtering_date_time, filtering_amount_join_{token,value});
filtering_raw_field was already the only correct one
- ui_712_start_review: call set_tx_simulation_warning() before
ui_tx_simulation_finish_str() so the finish button label
reflects the actual simulation verdict
|
elf sizes
Stack consumption summary (clone_app_stack_consumption)
Stack consumption summary
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1099 +/- ##
===========================================
- Coverage 74.71% 74.58% -0.14%
===========================================
Files 162 162
Lines 14623 14659 +36
Branches 3505 3529 +24
===========================================
+ Hits 10926 10933 +7
- Misses 3457 3481 +24
- Partials 240 245 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Coverage OverviewLanguages: C C / code-coverage/unittestsThe overall coverage in commit 92b1930 in the Show a code coverage summary of the most covered files.
Updated |
v1_set_struct_name() was using strings.tmp.tmp as a scratch buffer to null-terminate the incoming struct name before passing it to td_create_struct_def(). strings.tmp.tmp aliases strings.common (same union), so any write during an active review silently corrupts the displayed fromAddress, toAddress and other fields. Allocate an exact-sized temporary buffer via APP_MEM_ALLOC, pass it to td_create_struct_def() which makes its own copy, then immediately free.
tokenContext_t (plugin name, contract address, method selector, pluginChainId, pluginStatus, token lookups) was never zeroed between signing sessions, allowing stale plugin/token state from a previous transaction to bleed into the next one. Add memset(&dataContext) alongside the existing clears of tmpCtx, txContext and tmpContent.
Every error path in handle_network_info() called network_info_cleanup(g_last_added_network) unconditionally. network_info_cleanup(NULL) erases the entire dynamic network list, so a single malformed PROVIDE_NETWORK_INFO APDU sent before any network was registered wiped all previously loaded networks and freed any icons held by live reviews. Add a NULL check before each cleanup call on error paths.
`test_get_info_invalid_p1_rejected` now sets up an in-flight network before the call so the NULL guard does not suppress the cleanup, and asserts that cleanup received the correct pointer. Added `test_get_info_invalid_p1_no_in_flight_no_cleanup` to verify that cleanup is skipped when `g_last_added_network` is NULL, preventing the unintended deletion of the entire dynamic network list.
ui_pairs_cleanup() was freeing g_pairs while NBGL could still hold a pointer to the backing array via g_pairsList->pairs. Any render callback firing between the free and the next idle screen would dereference freed memory. Clear g_pairsList->pairs and nbPairs before APP_MEM_FREE_AND_NULL so that any in-flight NBGL callback finds an empty list rather than a dangling pointer.
tokenContext_t contains an anonymous union where pluginContext[1024] aliases contractAddress[20]+methodSelector[4] at offset 0. Nothing prevented code from reading contractAddress after INIT_CONTRACT had overwritten those bytes with plugin-private data. Add a plugin_ctx_mode_t enum (PLUGIN_CTX_ADDR_SEL / PLUGIN_CTX_PLUGIN) that tracks which half of the union is active. The discriminant is set to PLUGIN_CTX_PLUGIN just before eth_plugin_call(INIT_CONTRACT) activates the plugin context. An early app_exit() in eth_plugin_perform_init_default() fires if the flag is already set, catching double-INIT_CONTRACT attempts that would read stale plugin bytes as an address/selector.
eip712_format_hash() was storing NBGL display pointers directly into strings.tmp.tmp, a scratch buffer shared with every other signing flow. Any APDU processed while the EIP-712 review is displayed (the APDU loop stays alive on SWO_NO_RESPONSE) could silently overwrite the domain/ message hash strings without NBGL noticing.
ui_712_approve() and ui_712_reject() explicitly called reset_app_context() after the _cb, but io_seproxyhal_send_status(..., true, ...) — which both _cb functions call — already invokes reset_app_context() synchronously before the APDU response is sent. The wrappers were therefore double- resetting the context. With the extra reset removed, the wrappers become trivial pass-throughs. Remove them entirely and have ui_typed_message_review_choice() call ui_712_approve_cb/ui_712_reject_cb directly, matching what the v0 path already did.
780049f to
02e1437
Compare
02e1437 to
e2a6d22
Compare
final_process() frees g_msg_hash_ctx on success but leaves signMsgCtx live for the UI. A subsequent P1_MORE with length=0 bypassed the length check ((0 + N) > N is false) and re-entered final_process() with a NULL hash context, causing a null-pointer dereference. Guard against this by checking g_msg_hash_ctx != NULL before processing any further data.
f0fef13 to
92b1930
Compare
Code coverage reportPer-file coverage
|
Description
Changes include