fix(core/prodtest): Error handling in secrets-certdev-write.
What changed, and why it matters
This commit fixes a production-test tool in Trezor hardware wallets so that it now checks whether writing a device certificate to secure storage actually succeeded. Previously, the tool would silently continue and report success even if the write failed. This is a defensive hardening fix in a low-level manufacturing/QA utility, not a user-facing wallet feature.
Treat as a minor hardening fix. Verify that all other `secret_write()` and `secret_read()` call sites in prodtest and main firmware properly check `secbool` return values. No urgent end-user action is indicated because prodtest is not part of the shipped consumer firmware runtime.
Security signals we found
Unchecked return value from security-critical storage function
False success reporting on failure path
Fix located in production-test (prodtest) firmware, not main wallet firmware
No changelog entry provided
Evidence from the diff
In prodtest_secrets_certdev_write(), the call to secret_write() previously ignored its return value (type secbool). The patch captures the return value and, if it is not sectrue, emits a CLI_ERROR and returns early instead of falling through to cli_ok(). This prevents false-positive success reports during production testing when the secure-storage write fails.
Changed components
core/embed/projects/prodtest/cmd/prodtest_secrets.cprodtest_secrets_certdev_write()secret_write() return-value handlingInspect captured patch +8 / −2
diff --git a/core/embed/projects/prodtest/cmd/prodtest_secrets.c b/core/embed/projects/prodtest/cmd/prodtest_secrets.c
index 087eea3fa..033db27ed 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_secrets.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_secrets.c
@@ -282,8 +282,14 @@ static void prodtest_secrets_certdev_write(cli_t* cli) {
return;
}
- secret_write(prefixed_certificate, SECRET_MCU_DEVICE_CERT_OFFSET,
- sizeof(prefixed_certificate));
+ secbool result =
+ secret_write(prefixed_certificate, SECRET_MCU_DEVICE_CERT_OFFSET,
+ sizeof(prefixed_certificate));
+
+ if (sectrue != result) {
+ cli_error(cli, CLI_ERROR, "secret_write() failed.");
+ return;
+ }
cli_ok(cli, "");
#endif
Why this scored 34/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.