kbs: zeroize JWE key material to prevent recovery from memory#183
Merged
Merged
Conversation
Collaborator
|
@jialez0 ,您好,您的请求已接收,请耐心等待结果。 |
Collaborator
|
@jialez0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
Sensitive key material in the JWE encryption paths -- the ECDH shared secret, its KDF-derived wrapping key, and the CEK -- could survive in heap or stack memory after use, making it recoverable via a memory disclosure primitive, process core dump, or cold-boot attack. Wrap all of these in Zeroizing so they are overwritten on drop. Enable the zeroize feature on aes-gcm, aes, and polyval so the AES and GHASH key schedules are also cleared by the crates themselves. Note: the AES key schedule inside aes-kw's KekAes256 cannot be covered because it derives Copy, precluding ZeroizeOnDrop. Adapted from confidential-containers/trustee 2274aa44bc01f2e231fe5d0a1654203f820302ec to this fork's jwe.rs layout (P-256 only, concat-kdf crate, aes-kw Kek API, thread_rng/log). Purely internal hardening: no API, config, or wire-format change; externally unobservable. Signed-off-by: Jiale Zhang <xinjian.zjl@alibaba-inc.com>
ed477f0 to
495b27e
Compare
Collaborator
|
@jialez0 ,您好,您的请求已接收,请耐心等待结果。 |
Collaborator
|
@jialez0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
吸收上游 confidential-containers/trustee 的 JWE 密钥材料 zeroize 安全加固,降低密钥在内存/core dump/cold-boot 场景下被恢复的风险。
2274aa44(kbs: zeroize JWE key material to prevent recovery from memory)改动内容
kbs/src/jwe.rs:将 ECDH 共享密钥z、KDF 派生的 wrapping key、CEK、以及 RSA 路径的 AES 对称密钥用zeroize::Zeroizing包装,drop 时清零。kbs/Cargo.toml:为aes-gcm/aes/polyval启用zeroizefeature(使 AES、GHASH key schedule 也被各自 crate 清零);将zeroize依赖转为常驻(从encrypted-dbfeature 列表移除)。适配说明(相对上游)
按本 fork 的
jwe.rs布局重写(仅 P-256、使用concat_kdf::derive_key_into、aes_kw::KekAPI、thread_rng/log),而非直接 cherry-pick coco 的不同实现。兼容性
验证
cargo check -p kbs通过。cargo test -p kbs --lib jwe::—— 3 个 JWE 兼容性测试全部通过(EC ECDH-ES+A256KW / RSA-OAEP-256 / RSA1.5,均用 josekit 解密回验),证明加密逻辑未被破坏。