refactor(core): disable sys.argv for firmware
What changed, and why it matters
This commit removes support for sys.argv (command-line argument lists) from the Trezor firmware's embedded MicroPython interpreter. In a hardware wallet, there is no legitimate command line, so keeping sys.argv enabled only added unused code and a small potential attack surface. The change is a hardening/refactoring step rather than a fix for a known exploit.
Treat as a low-risk hardening commit. No urgent action required. Reviewers may verify that emulator/unix builds still correctly enable sys.argv and that no firmware code depends on sys.argv at runtime.
Security signals we found
Removal of unused interpreter feature reduces attack surface
Configuration macro disables sys.argv only for firmware target
No changelog entry suggests routine refactoring/hardening
No direct evidence of an exploitable vulnerability being fixed
Evidence from the diff
The patch disables MICROPY_PY_SYS_ARGV in the firmware mpconfigport.h, removes the now-unnecessary mp_obj_list_init(mp_sys_argv, 0) call from main.c, and guards the meminfo dump of mp_sys_argv_obj behind the same config macro. This strips argv handling from the firmware build while leaving it available for other builds (e.g., emulator/unix).
Changed components
core/embed/projects/firmware/main.ccore/embed/projects/firmware/mpconfigport.hcore/embed/upymod/modtrezorutils/modtrezorutils-meminfo.hInspect captured patch +3 / −1
diff --git a/core/embed/projects/firmware/main.c b/core/embed/projects/firmware/main.c
index ca814a32..827b5d59 100644
--- a/core/embed/projects/firmware/main.c
+++ b/core/embed/projects/firmware/main.c
@@ -147,7 +147,6 @@ int main_func(uint32_t cmd, void *arg) {
// Interpreter init
LOG_INF("Starting interpreter");
mp_init();
- mp_obj_list_init(mp_sys_argv, 0);
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen));
diff --git a/core/embed/projects/firmware/mpconfigport.h b/core/embed/projects/firmware/mpconfigport.h
index 86f3a755..844e0236 100644
--- a/core/embed/projects/firmware/mpconfigport.h
+++ b/core/embed/projects/firmware/mpconfigport.h
@@ -131,6 +131,7 @@
#define MICROPY_PY_SYS_STDFILES (0)
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
#define MICROPY_PY_SYS_PLATFORM "trezor"
+#define MICROPY_PY_SYS_ARGV (0)
#define MICROPY_PY_ERRNO (0)
#define MICROPY_PY_THREAD (0)
#define MICROPY_PY_FSTRINGS (1)
diff --git a/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
index 4fc76f48..dceef2c8 100644
--- a/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
+++ b/core/embed/upymod/modtrezorutils/modtrezorutils-meminfo.h
@@ -719,8 +719,10 @@ static void dump_meminfo_json(FILE *out) {
fprintf(out, "\"mp_sys_path\",\n");
dump_value_opt(out, &mp_sys_path, true);
+#if MICROPY_PY_SYS_ARGV
fprintf(out, "\"mp_sys_argv_obj\",\n");
dump_value_opt(out, &MP_STATE_VM(mp_sys_argv_obj), true);
+#endif
fprintf(out, "\"ui_wait_callback\",\n");
dump_value(out, MP_STATE_VM(trezorconfig_ui_wait_callback));
Why this scored 28/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.