fix(core/prodtest): fix error message in check_cert_chain
What changed, and why it matters
This is a one-line formatting fix in an internal production-testing tool. The error message had an accidental extra format placeholder ('%d.') that would have caused the printf-style function to read an extra missing argument, leading to undefined behavior when a specific certificate parsing failure occurred. The patch removes the stray placeholder so the single provided argument (cert_count) matches the single '%d' in the format string. It is a straightforward bug fix with no security-relevant behavior change visible in the diff.
No security action required beyond normal code review and merge. The change is a safe formatting correction.
Security signals we found
format-string/variadic argument mismatch in error logging path
production-test-only code path (not end-user firmware runtime)
no functional change to certificate validation logic
Evidence from the diff
In core/embed/projects/prodtest/cmd/common.c, the cli_error() call inside check_cert_chain() used a format string containing two ‘%d’ specifiers (‘cert %d.’, ‘%d.’) but only passed one variadic argument (cert_count). This mismatch is undefined behavior in C variadic functions and could cause the second specifier to consume an arbitrary stack value. The patch corrects the format string to a single ‘%d’ matching the single argument. The affected code path is only triggered on a DER parsing failure during production-test certificate-chain validation.
Changed components
core/embed/projects/prodtest/cmd/common.ccheck_cert_chain()prodtest CLI error reportingInspect captured patch +1 / −1
diff --git a/core/embed/projects/prodtest/cmd/common.c b/core/embed/projects/prodtest/cmd/common.c
index 7ed4cf65..f07e53e9 100644
--- a/core/embed/projects/prodtest/cmd/common.c
+++ b/core/embed/projects/prodtest/cmd/common.c
@@ -584,7 +584,7 @@ bool check_cert_chain(cli_t* cli, const uint8_t* chain, size_t chain_size,
DER_ITEM sig_alg = {0};
if (!der_read_item_expected(&cert.buf, DER_SEQUENCE, &sig_alg)) {
cli_error(cli, PRODTEST_ERR_COMMON_CERT_CHAIN_READ_SIG_ALG,
- "check_device_cert_chain, der_read_item 7, cert %d.", "%d.",
+ "check_device_cert_chain, der_read_item 7, cert %d.",
cert_count);
return false;
}
Why this scored 15/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.