fix(core/prodtest): exclude the space before CRC value from its calculation
What changed, and why it matters
This commit fixes a tiny bug in Trezor's factory production-test command-line tool. The tool can require a CRC32 checksum at the end of each command to catch typos. The bug was that the checksum was accidentally calculated over an extra space character that sits just before the checksum value, so the device would reject commands whose checksum was computed the 'obvious' way. The patch removes that extra space from the checksum calculation and updates the README examples. It only affects the production-testing CLI, not normal wallet operation.
No urgent security action. Treat as a normal correctness fix. If using the prodtest CLI, update any tooling that pre-computes CRCs to match the corrected algorithm (exclude the space before the CRC).
Security signals we found
CRC validation logic changed in command parser
Production test CLI affected, not main firmware runtime
No mention of vulnerability, CVE, researcher, or security impact in commit message
Evidence from the diff
In core/embed/rtl/cli.c, cli_process_io computes a CRC32 over the user-typed command line before comparing it to the appended CRC. Previously the length passed to cli_crc32 included the space separator immediately preceding the CRC token (CLI_CRC_LENGTH covers the CRC hex digits, but not the space). The patch subtracts one more byte so the CRC is computed over the command/arguments only, excluding the trailing space and CRC. README.md examples are updated to reflect the corrected CRC values. This is a functional/robustness fix in the prodtest project, not a cryptographic or firmware-runtime security boundary.
Changed components
core/embed/rtl/cli.ccore/embed/projects/prodtest/README.mdInspect captured patch +5 / −5
diff --git a/core/embed/projects/prodtest/README.md b/core/embed/projects/prodtest/README.md
index a68df3a2..eda7a4e4 100644
--- a/core/embed/projects/prodtest/README.md
+++ b/core/embed/projects/prodtest/README.md
@@ -103,12 +103,12 @@ OK ABC 24DA4527
Example with `checked-` prefix (enforces CRC for a single command even if CRC is otherwise disabled):
```
-checked-ping ABC 35F69145
+checked-ping ABC 3240F7DC
OK ABC 24DA4527
```
If the command has no arguments, the format is `checked-<command> <CRC32>`:
```
-checked-ping D720F16C
+checked-ping 25D53DFD
OK D38BF920
```
diff --git a/core/embed/rtl/cli.c b/core/embed/rtl/cli.c
index dab7433d..068ceb80 100644
--- a/core/embed/rtl/cli.c
+++ b/core/embed/rtl/cli.c
@@ -640,9 +640,9 @@ const cli_command_t* cli_process_io(cli_t* cli) {
size_t crc_offset = cstr_starts_with(cli->line_buffer, CLI_CRC_PREFIX)
? strlen(CLI_CRC_PREFIX)
: 0;
- uint32_t calculated_crc =
- ~cli_crc32(CRC32_INITIAL, cli->line_buffer + crc_offset,
- MAX((int)cli->line_len - (int)crc_offset - CLI_CRC_LENGTH, 0));
+ uint32_t calculated_crc = ~cli_crc32(
+ CRC32_INITIAL, cli->line_buffer + crc_offset,
+ MAX((int)cli->line_len - (int)crc_offset - CLI_CRC_LENGTH - 1, 0));
// Split command line into arguments
if (!cli_split_args(cli)) {
Why this scored 23/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.