Make it easier to prevent Server side request forgery (SSRF) attacks
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- ruby
- Área
- networking, security
Línea de trabajo
Empieza leyendo la ruta #connect de net-http y el manejo existente de hostname=; después, compara la mitigación de SSRF descrita en el issue con la solución alternativa de Resolv en ssrf_filter. El issue sugiere un callback para la resolución de nombres de host y la aprobación de conexiones, pero no define una API ni pruebas definitivas; el trabajo estaría terminado cuando hubiera un diseño acordado y cobertura para las direcciones internas rechazadas y las conexiones HTTPS permitidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Over the years, we've received many bug bounty reports relating to Server side request forgery (SSRF) attacks. In a nutshell, these attacks use short-lived DNS entries to direct Web hooks and other URLs to internal IP addresses, such as AWS's instance metadata endpoint.
To a large extent, the problem is mitigated by using HTTPS, since a SSL certificate Common Name (CN) must match the hostname. However, there are a number of edge cases where HTTPS doesn't solve the issue. For example:
- DNS rebinding might still enable reconnaissance on the local network, since errors show the difference between "10.1.2.3:4567 unreachable" and "10.1.2.3:4567 reachable but TLS error".
- Some clients or Web hooks may disable SSL certificate verification.
In the past, we've mitigated the problem by:
- Performing a DNS lookup first for the IP address.
- If the IP address maps to internal or local networks, reject the request.
- If the IP address is allowed, make the HTTPS request with the IP address instead of the hostname. To ensure SNI works, we patched
net-httpto use the original hostname by overriding thehostname=method.
A similar approach is taken by ssrf_filter.
However, with https://github.com/ruby/net-http/pull/36, our net-http patch no longer works because hostname= isn't called when an IP address is used. To handle that, https://github.com/arkadiyt/ssrf_filter/pull/54 introduced an even uglier patch that overrides the Resolv equality methods.
Both hostname= and Resolv patches are a bit ugly, but short of patching the #connect method there's no alternative at the moment.
A better approach might be to invoke some callback in #connect that will allow the caller to resolve the hostname and decide whether the connection should still proceed.
I realize that others might argue that a proxying all external calls via a proxy server is ultimately the right approach, but that's another moving part that requires more setup.
@jeremyevans What do you think about this?
- Lenguaje dominante
- Ruby
- Estrellas
- 148
- Forks
- 95
- Merge medio
- 10 h 54 min
- PR fusionados (30 d)
- 4
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ruby/net-http
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Todos los issues de ruby/net-http
Issues similares
-
user-reported
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Kong/developer.konghq.com#7316 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TheOdinProject/curriculum#31408 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
CI: json 3.0.2 removed `quirks_mode`, breaking ActiveSupport's JSON encoder on every test job Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
bensheldon/good_job#1816 · 5 comentarios ·