ES256 / ECDSA P-256 keys use secp256k1 instead of NIST P-256 in the OpenSSL build
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
- 领域
- cryptography, security
调研方向
阅读 cups/jwt.c 中的 cupsJWTMakePrivateKey()、make_ec_key() 和 cupsJWTLoadCredentials() 函数,以及 cups/tls-openssl.c 中的 openssl_create_key()。将 issue 中指出的四处 NID_secp256k1 替换为 NID_X9_62_prime256v1。运行 testjwt 和 testjson,然后检查 ES256 是否能使用标准 NIST P-256 密钥正常工作,同时确保 ES384 和 ES512 仍然正确。
由索引模型根据 Issue 内容生成。
描述
In the OpenSSL build, libcups generates every key labelled "P-256" on the secp256k1 curve (the Koblitz curve) instead of NIST P-256 (secp256r1 / NID_X9_62_prime256v1). RFC 7518 section 6.2.1.1 defines the JWK "crv":"P-256" and the ES256 algorithm as NIST P-256. P-384 and P-521 are correct, so it looks like a secp256k1 vs secp256r1 slip, and the only OpenSSL constant for r1 is NID_X9_62_prime256v1.
Affected code (OpenSSL build only; the GnuTLS build uses SECP256R1 and is correct):
- cups/jwt.c, cupsJWTMakePrivateKey(): ES256 key generation uses NID_secp256k1
- cups/jwt.c, make_ec_key(): the "P-256" import/verify branch uses NID_secp256k1
- cups/jwt.c, cupsJWTLoadCredentials(): the curve read-back maps NID_secp256k1 to "P-256"
- cups/tls-openssl.c, openssl_create_key(): CUPS_CREDTYPE_ECDSA_P256_SHA256 uses NID_secp256k1
Effect:
- The key is on the wrong curve while still labelled "P-256". With Python cryptography, the public key point is not on NIST P-256; it is on secp256k1.
- cupsJWTHasValidSignature() rejects a valid ES256 token signed with a real P-256 key, and ES256 tokens CUPS signs are rejected by RFC-compliant libraries. jwcrypto rejects CUPS ES256 tokens, and CUPS reports a standard jwcrypto P-256 token as invalid. ES384 and ES512 are fine. It fails closed; there is no bypass.
- A CUPS_CREDTYPE_ECDSA_P256_SHA256 certificate is generated on secp256k1 but presented as P-256, so standard TLS clients reject it. This type is opt-in; the default is RSA-3072 or P-384.
Present in libcups 3.0.0 and 3.0.3. CUPS 2.5 master has the same code.
Fix: change NID_secp256k1 to NID_X9_62_prime256v1 in all four places. P-384 and P-521 already use NID_secp384r1 and NID_secp521r1.
Verified on macOS arm64 with Homebrew OpenSSL 3.6.3. After the fix the key point is on NIST P-256, jwcrypto verifies CUPS ES256 tokens, CUPS verifies standard P-256 tokens, and testjwt (ES256 and ES384 included) and testjson pass. I can open a PR with the fix if you want.
- 主要语言
- C
- 星标
- 84
- 派生
- 50
- 平均合并
- 10 小时 49 分钟
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenPrinting/libcups 的其他 Issue
-
enhancement priority-high security
难度 5/5 一周以上 新手友好度 35/100
OpenPrinting/libcups#163 ·
维护者通常 1 天内回复
-
enhancement priority-high security
难度 4/5 3-5 天 新手友好度 48/100
OpenPrinting/libcups#162 ·
维护者通常 1 天内回复
-
enhancement priority-medium
难度 5/5 一周以上 新手友好度 35/100
OpenPrinting/libcups#121 ·
维护者通常 1 天内回复
-
enhancement priority-medium
难度 5/5 一周以上 新手友好度 30/100
OpenPrinting/libcups#120 ·
维护者通常 1 天内回复
-
enhancement platform issue
难度 5/5 一周以上 新手友好度 25/100
OpenPrinting/libcups#109 ·
维护者通常 1 天内回复
查看 OpenPrinting/libcups 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
Bug Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
category:port-update
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
Update OpenBSD CI to OpenBSD 8.0 and vmactions/openbsd-vm v1.4.9可能已有人在做 @hyoklee 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 85/100
维护者通常 2 天内回复
-
v9.6.0: CMake incorrectly enforces presence of libevdev可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复