jd-opensource / jd-opensource/joyrpc

joyrpc存在iv=key的密码误用

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
478
Forks
181
PR merge metrics
No merged PRs in 30d

Description

一、漏洞摘要

joyrpc中的加密代码使用了IV=key的模式,从而会导致CCA攻击,进而让攻击者获取密钥。

https://github.com/jd-opensource/joyrpc/blob/ff7bbce76a5ba2542935707c0147a4c0008e3965/joyrpc-core/src/main/java/io/joyrpc/codec/crypto/aes/AesCrypto.java#L45-L49
二、复现步骤:逻辑清晰,步骤严密
截获密文:攻击者截获一段使用IV = Key加密的密文C = (C1, C2, C3, ..., Cn)。
构造特制密文:攻击者构造一个新的密文C' = (C1, 0, C1, C2, C3, ..., Cn),其中0表示一个全零的块。
解密过程:解密C1时,P1 = AES_decrypt(C1, Key) XOR Key。解密第二个块时,P2 = AES_decrypt(0, Key) XOR C1。解密第三个块时,P3 = AES_decrypt(C1, Key) XOR 0。恢复Key:由于P1 = AES_decrypt(C1, Key) XOR Key,且P3 = AES_decrypt(C1, Key),所以P1 XOR P3 = Key。
可以参阅:https://cedricvanrompay.gitlab.io/cryptopals/challenges/27.html

三、修复方案

IV应该设置为随机数。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.