fix(firmware): reject malformed UTF-8 producer reports

This commit is contained in:
morluto committed 2026-10-09 05:15:23 +08:00
1 parent 2b86ea9c7c
commit 4a45c14742
3 files changed
+51 -3

No files matched your search

+5 -1
View File
@@ -153,7 +153,11 @@ export const readFirmwareReport = async (
`Report exceeded ${FIRMWARE_LIMITS.reportBytes} bytes`,
);
try {
const value: unknown = JSON.parse(bytes.toString("utf8"));
const value: unknown = JSON.parse(
new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(
bytes,
),
);
return value;
} catch (cause: unknown) {
throw new AnalysisOutputError(