test(core): wait for debuglink task before restarting THP event loop
What changed, and why it matters
This is a test-only change for the Trezor hardware wallet firmware. It adds a small cleanup step in the debug/test code path that waits for a debug-link helper task to finish before restarting the event loop used by the new THP (Trezor Host Protocol) code. It does not change normal user-facing behavior and is not a security fix for a live vulnerability.
No security action required. Treat as a normal test reliability improvement. Review only if you are maintaining the THP test harness and want to confirm teardown ordering.
Security signals we found
Debug-only code path modified
No production code path affected
No changelog entry (test/internal change)
No mention of vulnerability, CVE, or security issue in commit message
Evidence from the diff
In core/src/trezor/wire/init.py, inside the THP event-loop restart path, the patch adds an await apps.debug.close_session() call guarded by if debug. This ensures the debuglink session is closed before loop.clear() is called during test teardown. The change is gated by debug, so it is compiled out of production firmware builds. It is marked [no changelog] and appears to be a test hardening/cleanup commit rather than a response to a disclosed security issue.
Changed components
core/src/trezor/wire/__init__.pyTHP event loop test teardown pathapps.debug debuglink sessionInspect captured patch +4 / −0
diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py
index ce54741fd..99cb8a4d3 100644
--- a/core/src/trezor/wire/__init__.py
+++ b/core/src/trezor/wire/__init__.py
@@ -110,6 +110,10 @@ if utils.USE_THP:
finally:
# Wait for all active workflows to finish.
await workflow.join_all()
+ if __debug__:
+ import apps.debug
+
+ await apps.debug.close_session()
loop.clear()
else:
Why this scored 17/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.