chore(vendor): disable unused MicroPython features
What changed, and why it matters
This commit turns off several unused features in the MicroPython interpreter that runs on Trezor hardware wallets. It is a hardening change that reduces the amount of code available to an attacker, but it does not by itself fix a known, exploitable bug. The commit message explicitly calls it a routine cleanup ('chore') and says it needs no changelog entry.
Treat as a low-risk hardening improvement. No urgent action is required, but verify that downstream firmware and emulator builds still compile and that no legitimate application code depends on the disabled features (str.center, weak links, or uctypes in Bitcoin-only mode).
Security signals we found
Disables MicroPython module weak links, removing a dynamic module-resolution mechanism
Disables the str.center builtin, removing a string-formatting code path
Makes uctypes conditional on !BITCOIN_ONLY, removing a C-struct introspection module from Bitcoin-only builds
Commit is tagged as routine maintenance ('chore') with '[no changelog]'
Evidence from the diff
The patch disables three MicroPython capabilities in both firmware and unix emulator builds: MICROPY_MODULE_WEAK_LINKS, MICROPY_PY_BUILTINS_STR_CENTER, and MICROPY_PY_UCTYPES (the last now only enabled for non-Bitcoin-only builds because it is used by FIDO). These are compile-time feature flags. Turning them off removes the corresponding code paths from the built firmware, shrinking the attack surface. There is no diff evidence of an accompanying vulnerability or exploit; the change is defensive.
Changed components
core/embed/projects/firmware/mpconfigport.hcore/embed/projects/unix/mpconfigport.hMicroPython runtime configuration in Trezor firmwareInspect captured patch +6 / −6
diff --git a/core/embed/projects/firmware/mpconfigport.h b/core/embed/projects/firmware/mpconfigport.h
index efa495e8..5928bc3b 100644
--- a/core/embed/projects/firmware/mpconfigport.h
+++ b/core/embed/projects/firmware/mpconfigport.h
@@ -81,7 +81,7 @@
#endif
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_STREAMS_NON_BLOCK (1)
-#define MICROPY_MODULE_WEAK_LINKS (1)
+#define MICROPY_MODULE_WEAK_LINKS (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#define MICROPY_USE_INTERNAL_ERRNO (1)
#define MICROPY_ENABLE_SCHEDULER (0)
@@ -93,7 +93,7 @@
#define MICROPY_PY_DESCRIPTORS (0)
#define MICROPY_PY_DELATTR_SETATTR (0)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
-#define MICROPY_PY_BUILTINS_STR_CENTER (1)
+#define MICROPY_PY_BUILTINS_STR_CENTER (0)
#define MICROPY_PY_BUILTINS_STR_PARTITION (1)
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
@@ -135,7 +135,7 @@
#define MICROPY_PY_FSTRINGS (1)
// extended modules
-#define MICROPY_PY_UCTYPES (1)
+#define MICROPY_PY_UCTYPES (!BITCOIN_ONLY) // used in FIDO
#define MICROPY_PY_UZLIB (0)
#define MICROPY_PY_UJSON (0)
#define MICROPY_PY_UOS (0)
diff --git a/core/embed/projects/unix/mpconfigport.h b/core/embed/projects/unix/mpconfigport.h
index cdca8864..18e5e9bd 100644
--- a/core/embed/projects/unix/mpconfigport.h
+++ b/core/embed/projects/unix/mpconfigport.h
@@ -89,7 +89,7 @@
#endif
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_STREAMS_NON_BLOCK (1)
-#define MICROPY_MODULE_WEAK_LINKS (1)
+#define MICROPY_MODULE_WEAK_LINKS (0)
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#define MICROPY_VFS_POSIX_FILE (1)
#define MICROPY_USE_INTERNAL_ERRNO (0)
@@ -102,7 +102,7 @@
#define MICROPY_PY_DESCRIPTORS (0)
#define MICROPY_PY_DELATTR_SETATTR (0)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
-#define MICROPY_PY_BUILTINS_STR_CENTER (1)
+#define MICROPY_PY_BUILTINS_STR_CENTER (0)
#define MICROPY_PY_BUILTINS_STR_PARTITION (1)
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
@@ -144,7 +144,7 @@
#define MICROPY_PY_FSTRINGS (1)
// extended modules
-#define MICROPY_PY_UCTYPES (1)
+#define MICROPY_PY_UCTYPES (!BITCOIN_ONLY) // used in FIDO
#define MICROPY_PY_UZLIB (0)
#define MICROPY_PY_UJSON (0)
#define MICROPY_PY_UOS (1)
Why this scored 26/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.