Skip to content

Insufficient randomness in generation of DNS query IDs

Moderate
bradh352 published GHSA-8r8p-23f3-64c2 May 22, 2023

Package

c-ares

Affected versions

< 1.19.1

Patched versions

1.19.1

Description

Impact

Description of issue(s):

  1. When /dev/urandom or RtlGenRandom() are unavailable, c-ares uses rand() to generate random numbers used for DNS query ids. This is not a CSPRNG, and it is also not seeded by srand() so will generate predictable output.
  2. Input from the random number generator is fed into a non-compilant RC4 implementation and may not be as strong as the original RC4 implementation.
  3. No attempt is made to look for modern OS-provided CSPRNGs like arc4random() that is widely available.

Correction(s) made:

  1. Detect arc4random() and if available, use it directly to generate DNS query ids.
  2. Use /dev/urandom or RtlGenRandom() directly to generate DNS query ids as a fallback
  3. As a last resort, use the current rand() + RC4 logic (should only apply to esoteric systems), with these modifications:
  • replace RC4 implementation with official algorithm
  • seed rand() using srand()

Patches

Fixed in 1.19.1

Workarounds

No workarounds are available.

Credit

David Gstir and Hannes Moesl
X41 D-SEC GmbH
Audit funded by Open Source Technology Improvement Fund (OSTIF)

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N

CVE ID

CVE-2023-31147

Weaknesses