KeyChecker: "key_ops" does not tell content decryption from key unwrapping, and "deriveKey"/"deriveBits" are not accepted on both sides

未关闭
#761 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
php
领域
security

调研方向

Start by reading KeyChecker::checkKeyUsage() and tracing the encryption and decryption paths for dir and ECDH-ES. The issue specifies the expected dir operations and that deriveKey and deriveBits should both work on either side for key agreement. Check the existing tests for those modes and add coverage showing those cases pass while wrapping-only keys cannot decrypt dir content.

由索引模型根据 Issue 内容生成。

描述

enhancement
Version(s) affected

All released versions (3.4.x, 4.0.x, 4.1.x, 4.2.x), and the 4.3.x and 5.0.x branches.

Description

KeyChecker::checkKeyUsage() accepts any of decrypt, unwrapKey and deriveBits for every decryption, and any of encrypt, wrapKey and deriveKey for every encryption, whatever the key management mode. Two consequences:

  • A key restricted to ["wrapKey", "unwrapKey"], meant for key wrapping only, can still decrypt dir content. key_ops therefore does not prevent the key confusion described in #760.
  • The two lists disagree for key agreement: a key restricted to deriveKey can encrypt with ECDH-ES but cannot decrypt, and a key restricted to deriveBits can decrypt but cannot encrypt.
Possible Solution
  • 4.3.0: dir requires encrypt when building and decrypt when decrypting; deriveKey and deriveBits are both accepted on both sides for key agreement.
  • A strict mapping per key management mode would refuse keys exported by WebCrypto (for example AES-GCM keys with encrypt/decrypt used for A*GCMKW, RSA keys with decrypt used for RSA-OAEP, or ECDH public keys exported with an empty key_ops). It is left for 5.0.0, if at all.
Additional Context

Found by the Anthropic OSS Scanner (ANT-2026-Z8KOO4J9).

主要语言
PHP
星标
954
派生
119
平均合并
48 分钟
30 天内合并 PR
17

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

web-token/jwt-framework 的其他 Issue

查看 web-token/jwt-framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。