Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.
Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)
This vulnerability occurs when a Pseudo-Random Number Generator (PRNG) is used, but its initial seed value is not handled securely or predictably, compromising the randomness of its output.
What is CWE-335?
Real-world CVEs caused by CWE-335
-
Cloud application on Kubernetes generates passwords using a weak random number generator based on deployment time.
-
server uses erlang:now() to seed the PRNG, which results in a small search space for potential random seeds
-
Product's PRNG is not seeded for the generation of session IDs
-
Router's PIN generation is based on rand(time(0)) seeding.
Ruta del atacante paso a paso
- 1
The following code uses a statistical PRNG to generate account IDs.
- 2
Because the program uses the same seed value for every invocation of the PRNG, its values are predictable, making the system vulnerable to attack.
- 3
Both of these examples use a statistical PRNG seeded with the current value of the system clock to generate a random number:
- 4
An attacker can easily predict the seed used by these PRNGs, and so also predict the stream of random numbers generated. Note these examples also exhibit CWE-338 (Use of Cryptographically Weak PRNG).
- 5
This code grabs some random bytes and uses them for a seed in a PRNG, in order to generate a new cryptographic key.
Vulnerable Java
The following code uses a statistical PRNG to generate account IDs.
private static final long SEED = 1234567890;
public int generateAccountID() {
Random random = new Random(SEED);
return random.nextInt();
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-335
- Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
- Implementation Validate input at trust boundaries; use allowlists, not denylists.
- Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
- Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
- Operation Monitor logs for the runtime signals listed in the next section.
How to detect CWE-335
Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.
Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.
Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.
Plexicus detecta automáticamente CWE-335 y abre un PR de corrección en menos de 60 segundos.
Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.
Frequently asked questions
¿Qué es CWE-335?
This vulnerability occurs when a Pseudo-Random Number Generator (PRNG) is used, but its initial seed value is not handled securely or predictably, compromising the randomness of its output.
¿Qué gravedad tiene CWE-335?
MITRE no ha publicado una calificación de probabilidad de explotación para esta debilidad. Trátala como de impacto medio hasta que tu modelo de amenazas demuestre lo contrario.
¿Qué lenguajes o plataformas se ven afectados por CWE-335?
MITRE no ha especificado plataformas afectadas para esta CWE — puede aplicar a la mayoría de los stacks de aplicaciones.
¿Cómo puedo prevenir CWE-335?
Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.
¿Cómo detecta y corrige Plexicus CWE-335?
El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-335 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.
¿Dónde puedo aprender más sobre CWE-335?
MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/335.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.
Weaknesses related to CWE-335
Use of Insufficiently Random Values
This vulnerability occurs when an application uses random values that are not sufficiently unpredictable in security-sensitive operations,…
Generation of Weak Initialization Vector (IV)
This vulnerability occurs when software uses a weak or predictable Initialization Vector (IV) for cryptographic operations. Many…
Use of Predictable Algorithm in Random Number Generator
This vulnerability occurs when a device or application relies on a predictable algorithm to generate pseudo-random numbers, making the…
Insufficient Entropy
This vulnerability occurs when a system's random number generator or algorithm lacks sufficient unpredictability, creating patterns or…
Small Space of Random Values
This vulnerability occurs when a system uses a random number generator that produces too few possible values. Attackers can easily predict…
Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
This vulnerability occurs when software uses a pseudo-random number generator (PRNG) that is not cryptographically strong for…
Generation of Predictable Numbers or Identifiers
This vulnerability occurs when a system creates numbers or identifiers that are too easy to guess, undermining security mechanisms that…
Use of Invariant Value in Dynamically Changing Context
This vulnerability occurs when code uses a fixed, unchanging value (like a hardcoded string, number, or reference) in a situation where…
Same Seed in Pseudo-Random Number Generator (PRNG)
This vulnerability occurs when a Pseudo-Random Number Generator (PRNG) is repeatedly initialized with the same starting seed value.
Deja de pagar por desarrollador.
Empieza a cerrar el bucle.
Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.