¿Qué hacer cuando se publica una nueva vulnerabilidad en un servicio que utilizamos? Veremos una vulnerabilidad reciente, analizaremos el método de explotación y aprenderemos a proteger nuestro servidor vulnerable.
2. Sobreviviendo al exterior con tu IPS
Carlos Brendel
• Ingeniero de Telecomunicaciones
por la Universidad Politécnica de
Valencia (UPV).
• Estudiando el Máster de
Ciberseguridad en la universidad
Oberta de Cataluña (UOC).
• Técnico analista en el SOC de
Telefónica.
4. Sobreviviendo al exterior con tu IPS
Intrusion Prevention System
• Sistema que cursa y monitoriza tráfico.
• Procesa los paquetes en busca de
actividad maliciosa, aceptándolos o
bloqueándolos en función del
resultado.
• Basado en firmas o anomalías.
AB
GIF FW
28. Sobreviviendo al exterior con tu IPS
CVE-2017-5638
Definición CVE: "The Jakarta Multipart parser in Apache Struts 2 2.3.x before 2.3.32
and 2.5.x before 2.5.10.1 has incorrect exception handling and error-message
generation during file-upload attempts, which allows remote attackers to execute
arbitrary commands via a crafted Content-Type, Content-Disposition, or Content-
Length HTTP header, as exploited in the wild in March 2017 with a Content-Type
header containing a #cmd= string. " - https://cve.mitre.org
29. Sobreviviendo al exterior con tu IPS
CVE-2017-5638
Definición CVE: "The Jakarta Multipart parser in Apache Struts 2 2.3.x before 2.3.32 and 2.5.x before
2.5.10.1 has incorrect exception handling and error-message generation during file-upload attempts,
which allows remote attackers to execute arbitrary commands via a crafted Content-Type, Content-
Disposition, or Content-Length HTTP header, as exploited in the wild in March 2017 with a Content-
Type header containing a #cmd= string. " - https://cve.mitre.org
Traducción al mundo real: Tras el error provocado por un "Content-Type" no
válido, la expresión no se escapa y se utiliza por la función
"LocalizedTextUtil.findText" para generar el mensaje de error. Pero esta función
interpreta como OGNL (Object-Graph Navigation Language, cosas de Java...)
todo código entre %{...}
GIF GIRL!
30. Sobreviviendo al exterior con tu IPS
CVE-2017-5638
Definición CVE: "The Jakarta Multipart parser in Apache Struts 2 2.3.x before 2.3.32 and 2.5.x before
2.5.10.1 has incorrect exception handling and error-message generation during file-upload attempts,
which allows remote attackers to execute arbitrary commands via a crafted Content-Type, Content-
Disposition, or Content-Length HTTP header, as exploited in the wild in March 2017 with a Content-
Type header containing a #cmd= string. " - https://cve.mitre.org
Traducción al mundo real: Tras el error provocado por un "Content-Type" no
válido, la expresión no se escapa y se utiliza por la función
"LocalizedTextUtil.findText" para generar el mensaje de error. Pero esta función
interpreta como OGNL (Object-Graph Navigation Language, cosas de Java...)
todo código entre %{...}
GIF GIRL!
41. Sobreviviendo al exterior con tu IPS
Redacción de firma
[ACTION] [PROTOCOL] [SOURCE] [SPORT] [DIRECTION] [DESTINATION] [DPORT]
( [MSG]; [CONTENT]; [MODIFIER]; [STICKY BUFFER]; [CONTENT1]; [CONTENT2];…;
[SID]; )
http://suricata.readthedocs.io/en/latest/rules/http-keywords.html
42. Sobreviviendo al exterior con tu IPS
CVE-2017-5638
Definición CVE: "The Jakarta Multipart parser in Apache Struts 2 2.3.x before 2.3.32
and 2.5.x before 2.5.10.1 has incorrect exception handling and error-message
generation during file-upload attempts, which allows remote attackers to execute
arbitrary commands via a crafted Content-Type, Content-Disposition, or Content-
Length HTTP header, as exploited in the wild in March 2017 with a Content-Type
header containing a #cmd= string. " - https://cve.mitre.org
43. Sobreviviendo al exterior con tu IPS
Redacción de firma
[ACTION] [PROTOCOL] [SOURCE] [SPORT] [DIRECTION] [DESTINATION] [DPORT]
( [MSG]; [CONTENT]; [MODIFIER]; [STICKY BUFFER]; [CONTENT1]; [CONTENT2];…;
[SID]; )
http://suricata.readthedocs.io/en/latest/rules/http-keywords.html
44. Sobreviviendo al exterior con tu IPS
Redacción de firma
[ACTION] [PROTOCOL] [SOURCE] [SPORT] [DIRECTION] [DESTINATION] [DPORT]
( [MSG]; [CONTENT]; [MODIFIER]; [STICKY BUFFER]; [CONTENT1]; [CONTENT2];…; [SID]; )
Primera firma:
- drop tcp $EXTERNAL_NET any -> $HOME_NET $HTTP_PORTS
(msg:"Detectado exploit Apache Struts – CVE-2017-5638!";
content: "GET"; http_method;
http_content_type; content: "#cmd=";
sid:3;)
http://suricata.readthedocs.io/en/latest/rules/http-keywords.html
45. Sobreviviendo al exterior con tu IPS
Redacción de firma
[ACTION] [PROTOCOL] [SOURCE] [SPORT] [DIRECTION] [DESTINATION] [DPORT]
( [MSG]; [CONTENT]; [MODIFIER]; [STICKY BUFFER]; [CONTENT1]; [CONTENT2];…; [SID]; )
Primera firma:
- drop tcp $EXTERNAL_NET any -> $HOME_NET $HTTP_PORTS
(msg:"Detectado exploit Apache Struts – CVE-2017-5638!";
content: "GET"; http_method;
http_content_type; content: "#cmd=";
sid:3;)
http://suricata.readthedocs.io/en/latest/rules/http-keywords.html
¿?
70. Sobreviviendo al exterior con tu IPS
Step By Step
• Entender en qué consiste la vulnerabilidad
• Entender cómo funciona el exploit de la PoC
• Montar pequeño laboratorio
• Let the fun begin!
71. Sobreviviendo al exterior con tu IPS
Step By Step
• Entender en qué consiste la vulnerabilidad
• Entender cómo funciona el exploit de la PoC
• Montar pequeño laboratorio
• Let the fun begin!
72. Sobreviviendo al exterior con tu IPS
Máquina utilizada
CVE-2017-5638
https://mega.nz/#!HjRRWTYZ!tEPSChwUkZ8PNHs6mUkR_ICfxIyjkKjGrGQN-nnYFt0
debian:debian
root:debian