Insecure Randomness
来源:互联网 发布:王欣老婆捐钱知乎 编辑:程序博客网 时间:2024/06/05 19:01
This is a Vulnerability. To view all vulnerabilities, please see theVulnerability Category page.
Last revision (mm/dd/yy): 12/20/2013
Vulnerabilities Table of Contents
Description
Standard pseudo-random number generators cannot withstand cryptographic attacks.
Insecure randomness errors occur when a function that can produce predictable values is used as a source of randomness in security-sensitive context.
Computers are deterministic machines, and as such are unable to produce true randomness. Pseudo-Random Number Generators (PRNGs) approximate randomness algorithmically, starting with a seed from which subsequent values are calculated.
There are two types of PRNGs: statistical and cryptographic. Statistical PRNGs provide useful statistical properties, but their output is highly predictable and forms an easy to reproduce numeric stream that is unsuitable for use in cases where security depends on generated values being unpredictable. Cryptographic PRNGs address this problem by generating output that is more difficult to predict. For a value to be cryptographically secure, it must be impossible or highly improbable for an attacker to distinguish between it and a truly random value. In general, if a PRNG algorithm is not advertised as being cryptographically secure, then it is probably a statistical PRNG and should not be used in security-sensitive contexts.
Examples
The following code uses a statistical PRNG to create a URL for a receipt that remains active for some period of time after a purchase (DO NOT DO THIS).
String GenerateReceiptURL(String baseUrl) {Random ranGen = new Random();ranGen.setSeed((new Date()).getTime());return(baseUrl + Gen.nextInt(400000000) + ".html");}
This code uses the Random.nextInt() function to generate "unique" identifiers for the receipt pages it generates. Because Random.nextInt() is a statistical PRNG, it is easy for an attacker to guess the strings it generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it used a random number generator that did not produce predictable receipt identifiers, such as a cryptographic PRNG.
The following code uses Java's SecureRandom class to generate a cryptographically strong pseudo-random number (DO THIS):
public static int generateRandom(int maximumValue) {SecureRandom ranGen = new SecureRandom();return ranGen.nextInt(maximumValue);}转载自:https://www.owasp.org/index.php/Insecure_Randomness
- Insecure Randomness
- Insecure Randomness
- Insecure Randomness
- fortify——Insecure Randomness
- Insecure Randomness引发对随机数生成器抵挡加密攻击的方法
- 《Fooled by Randomness》读书笔记
- Insecure Configuration Management
- Chrome block insecure content
- booting in insecure mode
- docker insecure-registry
- go get -insecure 修改URL(uses insecure protocol)
- eclipse perl 中的Insecure dependency
- 【Android Debug】 Skipping insecure file ...
- SecurityError: The operation is insecure.
- 【Android Debug】 Skipping insecure file ...
- [ZOJ2715]Insecure in Prague && 枚举
- --insecure-registry docker-reg:5000
- SecurityError: The operation is insecure.
- 查找单链表的倒数第K个元素
- nyoj zb的生日 (DFS)
- 基于Ubuntu 15.04 LTS编译Android5.1.0源代码
- Android Socket 发送与接收数据问题: 发送后的数据接收到总是粘包
- 115个Java面试题和答案——终极列表
- Insecure Randomness
- MapReduce之join和sort
- android studio无法建立项目
- JQuery Sortables插件
- 安卓JNI传结构体
- [hyddd的FindBugs分析记录][H B BC] Random object created and used only once
- R语言 向分面数据添加公式与拟合曲线
- 2015年Web框架评测
- Oracle中like查询下划线等特殊字符的处理