`stsafea_query_mask_id()` reads `sub_tag` uninitialised when the transfer fails
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
- 领域
- embedded-iot, security
调研方向
问题出在 services/stsafea/stsafea_put_query.c 中的 stsafea_query_mask_id(),它在 stsafea_frame_raw_transfer() 之后检查 sub_tag,而不考虑返回值。先阅读 sub_tag 是如何从响应帧中设置的,然后在比较 sub_tag 之前检查基于 ret 的提前返回。当传输失败时返回其自身的错误码而不是 STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE,并且 sub_tag 始终被初始化时,即完成。
由索引模型根据 Issue 内容生成。
描述
In v1.1.11, stsafea_query_mask_id() (services/stsafea/stsafea_put_query.c) checks sub_tag after stsafea_frame_raw_transfer() whatever its result:
ret = stsafea_frame_raw_transfer(pSTSE, &CmdFrame, &RspFrame, ...);
if (sub_tag != STSAFEA_SUB_TAG_MASK_ID)
{
return (STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE);
}
return ret;
When the transfer fails before the response is read (for example STSE_PLATFORM_BUS_ACK_ERROR after every polling retry), sub_tag is never written, so the function reads an uninitialised variable. stse_init() then usually returns STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE instead of the bus error, and a device that does not answer looks like a device of another type.
The same happens when the device answers with an error status: the payload elements of the response frame are dropped, and sub_tag is not written either.
Suggested fix: return ret first when it is not STSE_OK, then check sub_tag; or initialise sub_tag to a value other than STSAFEA_SUB_TAG_MASK_ID.
Present in v1.1.11 and in main (5e9e04f).
- 主要语言
- C
- 星标
- 15
- 派生
- 12
- 平均合并
- 9 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
STMicroelectronics/STSELib 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 65/100
STMicroelectronics/STSELib#115 ·
-
Max `pBuffer` size for `stse_data_storage_update_data_zone()` unclear due to hidden overhead bytes未关闭
难度 3/5 1-2 天 新手友好度 45/100
STMicroelectronics/STSELib#84 · 4 条评论 ·
-
# Bug: `stse_perso_info_t` AC status 2-bit mask truncates valid AC values可能重新可做 @Grom- 于 220 天前认领,目前没有进行中的 PR。 未关闭bug
STMicroelectronics/STSELib#69 · 1 条评论 · 已指派 1 人 ·
-
`stse_platform_Crc16_Accumulate()` is not safe可能重新可做 @nils-cercariolo-st 于 209 天前认领,目前没有进行中的 PR。 未关闭
STMicroelectronics/STSELib#65 · 3 条评论 · 已指派 1 人 ·
-
STSAFE A120: Reprovisioning is successful, but returns error STSE_INVALID_C_MAC可能重新可做 @Grom- 于 352 天前认领,目前没有进行中的 PR。 未关闭bug
STMicroelectronics/STSELib#47 · 1 条评论 · 已指派 1 人 ·
查看 STMicroelectronics/STSELib 的全部 Issue
相似的 Issue
-
documentation severity: low
难度 1/5 1 小时以内 新手友好度 88/100
luainkernel/lunatik#2231 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
apache/arrow-swift#209 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
libretiny-eu/libretiny#435 ·
维护者通常 4 天内回复
-
Needs-Triage
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
trezor/trezor-firmware#8210 ·
维护者通常 3 天内回复