Skip to content

Commit 89db014

Browse files
test: Reset EIP-712 filtering globals on every process_data call
InputData.process_data() reset current_path on entry but left filtering_paths, filtering_tokens, filtering_calldatas and sig_ctx populated whenever the `filters` argument was omitted. As a result, a prior filtered signing flow contaminated later supposedly-unfiltered flows in the same Python process: the helper would replay leftover filter descriptors as extra APDUs and corrupt downstream snapshot comparisons or assertions. Clear every piece of module-level state at the start of each call, regardless of whether filters are provided. This makes the helper re-entrant within a single test process so cross-test state leakage no longer hides UI/signing regressions (CWE-664).
1 parent 350ca89 commit 89db014

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

client/src/ledger_app_clients/ethereum/eip712/InputData.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,23 @@ def process_data(aclient: EthAppClient,
595595
filters: Optional[dict] = None) -> None:
596596
global app_client
597597
global current_path
598-
598+
global filtering_paths
599+
global filtering_tokens
600+
global filtering_calldatas
601+
global sig_ctx
602+
603+
# Reset every piece of module-level state at the start of each call so
604+
# that a previous filtered run cannot contaminate the next one. The
605+
# previous behavior reset current_path but left filtering_paths,
606+
# filtering_tokens, filtering_calldatas and sig_ctx populated whenever
607+
# `filters` was omitted, leading to silent cross-test state leakage
608+
# (CWE-664).
599609
current_path = []
610+
filtering_paths = {}
611+
filtering_tokens = []
612+
filtering_calldatas = []
613+
sig_ctx = {}
614+
600615
# deepcopy because this function modifies the dict
601616
data_json = copy.deepcopy(data_json)
602617
app_client = aclient

0 commit comments

Comments
 (0)