HelloZeroNet / HelloZeroNet/ZeroNet
SafeRe is vulnerable to ReDoS
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.8k
- Forks
- 2.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### Step 1: Please describe your environment
* ZeroNet version: 0.7.2 (4555)
### Step 2: Describe the problem:
["To avoid the ReDoS algorithmic complexity attack" ](https://zeronet.io/docs/site_development/content_json/#regular-expression-limitations) the function bellow is used to validate user defined regular expressions.
https://github.com/HelloZeroNet/ZeroNet/blob/454c0b2e7e000fda7000cba49027541fbf327b96/src/util/SafeRe.py#L10-L22
This function fails to identify regular expressions that can require exponential time complexity to match user inputs.
#### Steps to reproduce:
```
>>> from SafeRe import isSafePattern, match
>>> p = "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
>>> isSafePattern(p)
True
>>> match(p, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
```
#### Observed Results:
`match` hangs and the execution never completes.
#### Expected Results:
`isSafePattern` should properly detect that the pattern is unsafe.
Alternatively, `match` should use an algorithm with guaranteed linear time complexity to compile and match inputs (e.g. Thompson NFA).
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con src/util/SafeRe.py en las líneas 10-22 y reproduce el patrón proporcionado usando isSafePattern y match. Investiga cómo el validador gestiona los patrones que pueden causar un tiempo de matching exponencial. Se considera terminado cuando el ejemplo se rechaza por ser inseguro o el matching utiliza el enfoque propuesto de tiempo de ejecución lineal garantizado sin quedarse bloqueado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- security
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100