CWE-323 在加密中重用Nonce与密钥对

admin 2022年1月5日21:07:19CWE(弱点枚举)评论13 views1930字阅读6分26秒阅读模式

CWE-323 在加密中重用Nonce与密钥对

Reusing a Nonce, Key Pair in Encryption

结构: Simple

Abstraction: Variant

状态: Incomplete

被利用可能性: High

基本描述

Nonces should be used for the present occasion and only once.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 344 cwe_View_ID: 1000 cwe_Ordinal: Primary

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Access Control ['Bypass Protection Mechanism', 'Gain Privileges or Assume Identity'] Potentially a replay attack, in which an attacker could send the same data twice, could be crafted if nonces are allowed to be reused. This could allow a user to send a message which masquerades as a valid message from a valid user.

可能的缓解方案

Implementation

策略:

Refuse to reuse nonce values.

Implementation

策略:

Use techniques such as requiring incrementing, time based and/or challenge response to assure uniqueness of nonces.

示例代码

This code takes a password, concatenates it with a nonce, then encrypts it before sending over a network:

bad C

void encryptAndSendPassword(char password){

char nonce = "bad";
...
char data = (unsigned char)malloc(20);
int para_size = strlen(nonce) + strlen(password);
char paragraph = (char)malloc(para_size);
SHA1((const unsigned char)paragraph,parsize,(unsigned char)data);
sendEncryptedData(data)

}

Because the nonce used is always the same, an attacker can impersonate a trusted party by intercepting and resending the encrypted password. This attack avoids the need to learn the unencrypted password.

This code sends a command to a remote server, using an encrypted password and nonce to prove the command is from a trusted party:

bad C++

String command = new String("some command to execute");
MessageDigest nonce = MessageDigest.getInstance("SHA");
nonce.update(String.valueOf("bad nonce"));
byte[] nonce = nonce.digest();
MessageDigest password = MessageDigest.getInstance("SHA");
password.update(nonce + "secretPassword");
byte[] digest = password.digest();
sendCommand(digest, command)

Once again the nonce used is always the same. An attacker may be able to replay previous legitimate commands or execute new arbitrary commands.

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
CLASP Reusing a nonce, key pair in encryption

文章来源于互联网:scap中文网

特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日21:07:19
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  CWE-323 在加密中重用Nonce与密钥对 http://cn-sec.com/archives/612775.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: