chore(core): add `requires_unlock` paths helper
What changed, and why it matters
This is a small internal cleanup in the Trezor firmware that replaces several direct checks for a special SLIP-25 Bitcoin path with a single helper function called requires_unlock(). It does not change the security rules themselves; it only makes the code more consistent and easier to maintain. There is no indication this commit fixes a vulnerability or introduces a new security weakness.
No security action required. Treat as normal code hygiene; include in routine review/QA if backporting.
Security signals we found
Refactoring only: no change in access-control policy
SLIP-25 path gating remains present and centralized
External-app crypto path restriction preserved
No changelog entry, consistent with routine chore
No CVE, advisory, or vendor security disclosure referenced
Evidence from the diff
The commit refactors path-lock checks across the core firmware. It introduces paths.requires_unlock(path), which returns True when the BIP-32 path begins with the SLIP25_PURPOSE constant. Existing checks in get_public_key.py, keychain.py, and extapp/crypto.py are updated to use this helper. The behavior remains the same: SLIP-25 paths stay locked until explicitly unlocked by the user, and external apps are still forbidden from accessing them. Documentation is updated to reference the new helper.
Changed components
core/src/apps/bitcoin/get_public_key.pycore/src/apps/common/keychain.pycore/src/apps/common/paths.pycore/src/apps/extapp/crypto.pydocs/common/safety-checks.mdInspect captured patch +17 / −15
### core/src/apps/bitcoin/get_public_key.py
@@ -31,8 +31,7 @@ async def get_public_key(
ignore_xpub_magic = msg.ignore_xpub_magic # local_cache_attribute
xpub_magic = coin.xpub_magic # local_cache_attribute
- if address_n and address_n[0] == paths.SLIP25_PURPOSE:
- # UnlockPath is required to access SLIP25 paths.
+ if paths.requires_unlock(address_n):
if not UnlockPath.is_type_of(auth_msg):
raise ForbiddenKeyPath()
### core/src/apps/common/keychain.py
@@ -96,19 +96,16 @@ def __del__(self) -> None:
del self.seed
def verify_path(self, path: paths.Bip32Path) -> None:
- # When safety checks are disabled, this function accepts any path except a
- # locked SLIP-25 path without showing a warning. A handler which signs, derives a change address or
- # displays an address or a public key has to show the warning itself,
- # usually by calling paths.validate_path().
+ # When safety checks are disabled, this function accepts any path except
+ # a locked one without showing a warning. A handler which signs, derives
+ # a change address or displays an address or a public key has to show
+ # the warning itself, usually by calling paths.validate_path().
if "ed25519" in self.curve and not paths.path_is_hardened(path):
raise DataError("Non-hardened paths unsupported on Ed25519")
- if not safety_checks.is_strict():
- # A SLIP-25 path is rejected at every safety check level until the
- # user unlocks it, which adds it to the schemas. See
- # docs/common/safety-checks.md.
- if not path or path[0] != paths.SLIP25_PURPOSE:
- return
+ # Unlocking a path adds it to the schemas.
+ if not safety_checks.is_strict() and not paths.requires_unlock(path):
+ return
if self.is_in_keychain(path):
return
### core/src/apps/common/paths.py
@@ -371,6 +371,12 @@ async def show_path_warning(path: Bip32Path) -> None:
await confirm_path_warning(address_n_to_str(path))
+def requires_unlock(path: Bip32Path) -> bool:
+ """Whether the path is rejected at every safety check level until the user
+ unlocks it. See docs/common/safety-checks.md."""
+ return bool(path) and path[0] == SLIP25_PURPOSE
+
+
def is_xpub_export_restricted(path: Bip32Path) -> bool:
if path:
purpose = unharden(path[0])
### core/src/apps/extapp/crypto.py
@@ -76,8 +76,8 @@ def _curve(value: int, curves: tuple[str, ...] = _CURVES) -> str:
def _check_path(session: Session, address_n: list[int]) -> None:
- # apps get no SLIP-25 paths
- if address_n and address_n[0] == paths.SLIP25_PURPOSE:
+ # apps can't unlock paths
+ if paths.requires_unlock(address_n):
raise ValueError("Forbidden key path")
# the manifest's paths on any curve, whatever the safety-check level
# (apps can't see it)
### docs/common/safety-checks.md
@@ -49,7 +49,7 @@ path.
A path which the user has to unlock before use, such as a SLIP-25 path, is not
a non-standard path. Trezor rejects it at every safety check level until the
-user unlocks it.
+user unlocks it, see `requires_unlock()`.
### Returning without displaying
Why this scored 32/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.