feat(core): join debuglink task before restarting Codec v1 event loop
What changed, and why it matters
This is a small cleanup change in the Trezor firmware's internal message-handling loop. It makes sure a special developer/debug task is fully shut down before the device resets its communication loop. The change only affects debug builds (not normal user devices) and appears designed to prevent a stale debug session from surviving across a loop restart. There is no direct evidence in the commit that this fixes an exploitable security vulnerability in production.
Treat as a low-risk hardening/cleanup commit. No urgent action required. If reviewing for security, verify that apps.debug.close_session() cannot itself be abused to block the event loop or introduce new debug-only attack surface, and confirm it is absent from release/production firmware builds.
Security signals we found
Debug-only code path modified
Task lifecycle cleanup (join/close before loop restart)
Potential stale debug session/task being terminated
No production code path directly changed
Evidence from the diff
In core/src/trezor/wire/init.py, the Codec v1 event-loop restart path now awaits apps.debug.close_session() before calling loop.clear() and returning. The guard if __debug__: means this code is compiled only in debug builds. The change joins the debuglink task to avoid a leftover debug session/task continuing after the wire loop is cleared. The commit message frames this as a feature/cleanup (‘feat(core)’) and explicitly marks ‘[no changelog]’. No CVE, advisory, or security disclosure is referenced.
Changed components
core/src/trezor/wire/__init__.pyCodec v1 event loop restart pathapps.debug debuglink sessionInspect captured patch +4 / −2
diff --git a/core/src/trezor/wire/__init__.py b/core/src/trezor/wire/__init__.py
index f2ff99440..46b4607df 100644
--- a/core/src/trezor/wire/__init__.py
+++ b/core/src/trezor/wire/__init__.py
@@ -167,9 +167,11 @@ else:
if not do_not_restart:
# Wait for all active workflows to finish.
await workflow.join_all()
- # Let the session be restarted from `main`.
if __debug__:
- log.debug(__name__, "loop.clear()", iface=iface)
+ import apps.debug
+
+ await apps.debug.close_session()
+ # Let the session be restarted from `main`.
loop.clear()
return # pylint: disable=lost-exception
Why this scored 22/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.