ECDHE_ECDSA ClientKeyExchange rejected as too short when DTLS_PSK_MAX_CLIENT_IDENTITY_LEN > 64
维护者通常 2 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
- 领域
- networking, security
调研方向
阅读dtls.c中DTLS_CKXEC_LENGTH的定义以及dtls_check_client_keyexchange()的ECDHE_ECDSA分支。将最小长度检查与issue中描述的ECDHE消息大小进行比较,然后在启用PSK和ECC的情况下,以DTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128进行构建。完成标准是在该设置下能够接受合法的ECDHE_ECDSA ClientKeyExchange,同时PSK发送缓冲区仍能容纳任一消息类型。
由索引模型根据 Issue 内容生成。
描述
Summary
When DTLS_PSK_MAX_CLIENT_IDENTITY_LEN is configured above 2 * DTLS_EC_KEY_SIZE (64), a TinyDTLS server rejects every legitimate ECDHE_ECDSA ClientKeyExchange with handshake_failure (40), because the minimum-length check uses a constant that is sized for the PSK identity.
Where
dtls.c:
#define DTLS_CKXEC_LENGTH (1 + 1 + max(DTLS_EC_KEY_SIZE + DTLS_EC_KEY_SIZE, DTLS_PSK_MAX_CLIENT_IDENTITY_LEN))
and in dtls_check_client_keyexchange() (ECDHE_ECDSA branch):
if (length < DTLS_HS_LENGTH + DTLS_CKXEC_LENGTH) {
dtls_debug("The client key exchange is too short\n");
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}
Checked against 501d93c (current main). develop has the same form.
Why it fails
An ECDHE_ECDSA ClientKeyExchange carries a 1-octet length, a 1-octet point format (0x04) and an uncompressed P-256 point of 2 * DTLS_EC_KEY_SIZE = 64 octets: 66 octets in total. With the default DTLS_PSK_MAX_CLIENT_IDENTITY_LEN of 32 the macro evaluates to 1 + 1 + max(64, 32) = 66, which happens to be exact. With -DDTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128 (RFC 4279 section 5.1 allows identities up to 128 octets) it evaluates to 130, so the 66-octet message is "too short" and the handshake fails. The PSK identity length has no bearing on the size of an ECDHE message.
Reproduction
Build with -DDTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128 and both DTLS_PSK and DTLS_ECC enabled. Run a TinyDTLS server offering TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 (raw public keys or certificates) and connect with any client that completes the ECDHE_ECDSA flight. The server logs error in check_client_keyexchange err: -552 and sends a fatal handshake_failure alert. With the default of 32 the same pair handshakes normally.
Suggested fix
Check the ECDHE message against its true size, independent of the PSK identity length:
if (length < DTLS_HS_LENGTH + 1 + 1 + 2 * DTLS_EC_KEY_SIZE) {
DTLS_CKXEC_LENGTH is still correct as the size of the send buffer in dtls_send_client_key_exchange(), since that buffer holds either the PSK message (2 + identity length) or the ECDHE message.
I have verified the fix locally: with only that comparison changed, the ECDHE_ECDSA handshake succeeds at an identity limit of 128. Happy to send a PR with a test if that is useful.
- 主要语言
- C
- 星标
- 122
- 派生
- 67
- 平均合并
- 6 天 8 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
eclipse-tinydtls/tinydtls 的其他 Issue
-
`dtls_get_cookie`: dereference before the length check (currently masked by `dtls_create_cookie`)未关闭
难度 2/5 1-3 小时 新手友好度 68/100
eclipse-tinydtls/tinydtls#279 · 2 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
MSVC build is broken (undeclared `DTLS_DEBUG_BUF_SIZE`)可能已有人在做 @mrdeep1 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
eclipse-tinydtls/tinydtls#283 · 5 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 57/100
eclipse-tinydtls/tinydtls#278 · 3 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
eclipse-tinydtls/tinydtls#274 · 2 条评论 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
eclipse-tinydtls/tinydtls#273 · 2 条评论 ·
维护者通常 2 天内回复
查看 eclipse-tinydtls/tinydtls 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
FujiNetWIFI/fujinet-lib#115 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
KalicoCrew/kalico#1012 ·
维护者通常 1 天内回复
-
[Fix proposed] macOS 10.9: crash on startup due to +[NSColor linkColor] (10.10+ API) in menu_macos.mm可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 79/100
joncampbell123/dosbox-x#6664 ·
维护者通常 1 天内回复
-
bug intrinsic low priority rt_lib
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复