fix(python): fix `trezorctl get-session` for legacy
What changed, and why it matters
This is a straightforward bug fix in the Python command-line tool `trezorctl`. A missing internal variable (`_version`) caused the `get-session` subcommand to crash with an error when used with older (legacy) Trezor devices. The patch adds the missing variable declaration and resets it when the connection closes. There is no security vulnerability here—just a broken feature being repaired.
No security action required. Treat as a normal bug-fix release for the Python tools package.
Security signals we found
No security-relevant change: missing attribute initialization causing a crash, not a vulnerability
No input validation, parsing, or trust-boundary changes
No cryptographic, authentication, or session-management logic altered
Evidence from the diff
The commit fixes an AttributeError in TrezorConnection within trezorlib/cli/__init__.py. The version property checked self._version, but that attribute was never declared on the class, so accessing it on instances raised AttributeError. The fix declares _version: tuple[int, int, int] | None = None at class level and clears it in close(). This only affects the trezorctl get-session command path for legacy Model 1 devices and is purely a functional repair.
Changed components
python/src/trezorlib/cli/__init__.pytrezorctl get-session commandlegacy Trezor Model 1 compatibility pathInspect captured patch +2 / −0
diff --git a/python/src/trezorlib/cli/__init__.py b/python/src/trezorlib/cli/__init__.py
index 10fe87ef..21bf34f1 100644
--- a/python/src/trezorlib/cli/__init__.py
+++ b/python/src/trezorlib/cli/__init__.py
@@ -196,6 +196,7 @@ ENV_TREZOR_SESSION_ID = os.environ.get("TREZOR_SESSION_ID")
class TrezorConnection:
_client: TrezorClient | None = None
_features: messages.Features | None = None
+ _version: tuple[int, int, int] | None = None
_transport: Transport | None = None
_standard_session: Session | None = None
@@ -312,6 +313,7 @@ class TrezorConnection:
self._transport = None
self._client = None
self._features = None
+ self._version = None
self._standard_session = None
def _passphrase_source_resolved(self) -> PassphraseSource:
Why this scored 20/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.