RT-Thread / RT-Thread/rt-thread
Weak random source in RT-Thread rt_random driver
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
Description
Hi,
I would like to report another potential vulnerability in the current version of RT-Thread. Please let me know if you plan to ask for a CVE ID in case the vulnerability is confirmed. I'm available if you need further clarifications.
Weak random source in RT-Thread rt_random driver
Summary
I noticed a weak random source at the following location in the RT-Thread rt_random driver source code:
https://github.com/RT-Thread/rt-thread/blob/master/components/drivers/misc/rt_random.c#L16-L28
Details
Weak random generator in the the calc_random() function:
static rt_uint16_t calc_random(void)
{
seed = 214013L * seed + 2531011L;
return (seed >> 16) & 0x7FFF; /* return bits 16~30 */
}
static rt_ssize_t random_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{
rt_uint16_t rand = calc_random(); /* VULN: weak random source */
ssize_t ret = sizeof(rand);
rt_memcpy(buffer, &rand, ret);
return ret;
}
Impact
If the reported weak random generator is used in a security context, such as cryptographic operations, it can expose to a number of attacks aimed to break encryption.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review components/drivers/misc/rt_random.c, especially calc_random() and random_read(), and verify how the returned value is used in security-sensitive contexts. Confirm whether the reported generator is unsuitable for those uses, then document the required security outcome and validate it with relevant RT-Thread tests or usage checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, operating-systems, security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100