Skip to content
KitploitKITPLOIT
HerramientasBlog
Enviar
HerramientasBlog
Enviar

¡Herramientas de Hacking, PenTest y Ciberseguridad para tu Arsenal de Seguridad!

Kitploit es un directorio de herramientas de hacking, ciberseguridad y pentesting. Descubre las últimas actualizaciones de proyectos para encontrar vulnerabilidades, analizar sistemas, automatizar pruebas y fortalecer tu seguridad.

··Feeds·Contacto·Privacidad·© 2026 Kitploit

Directorio de Herramientas

Categorías

Ver todas las categorías
Loading categories
Next.js_exploit_CVE-2024-34351 — Demostración educativa de una vulnerabilidad de Server-Side Request Forgery (SSRF) en Next.js (CVE-2024-34351), con ejemplos paso a paso de explotación y mitigación. | Kitploit
Herramientas/GitHubGitHub/avergnaud/next.js_exploit_cve-2024-34351
Análisis de VulnerabilidadesExplotación de Aplicaciones WebSeguridad WebAprendizaje y EducaciónLabs y Práctica
GitHubavergnaud/next.js_exploit_cve-2024-34351

Next.js_exploit_CVE-2024-34351

Demostración educativa de una vulnerabilidad de Server-Side Request Forgery (SSRF) en Next.js (CVE-2024-34351), con ejemplos paso a paso de explotación y mitigación.

Ver Repositorio
1hace 2 añosAún no revisado

Más Populares

Ver todos →

Descubre las herramientas más usadas por nuestra comunidad.

Explora todas las herramientas

Explora nuestra colección de herramientas

Ver todas las herramientas →
Compartir

csr-rsc-ssg-isr-ssr-ssrf

Este repositorio puede servir como soporte para presentar uno o varios meetup(s). El recorrido es el siguiente...

  • "CSR" Client Side Rendering: React como librería SPA estándar
  • "RSC" React Server Components: ejecución de componentes React únicamente del lado del servidor
  • "SSG" Static Site Generation: ejecución de componentes React durante el build
  • "ISR" Incremental Static Regeneration: regeneración de componentes a la demanda
  • "SSR" Server Side Rendering: pre-renderizado del lado del servidor y luego ejecución (hidratación) del lado del cliente
  • "SSRF" Server Side Request Forgery: una vulnerabilidad de seguridad corregida recientemente en Next.JS

Este trabajo se basa principalmente en dos fuentes:

  • https://demystifying-rsc.vercel.app/
  • https://www.assetnote.io/resources/research/digging-for-ssrf-in-nextjs-apps

mind map

CSR Client Side Rendering

1-csr-load-data vanilla react SPA loading data

mind map CSR

[!IMPORTANT] CSR (Client-Side Rendering): React code is delivered to the browser, which generates content that is inserted into the DOM.

client side rendering loading data

demostración

root@kitploit:~
cd 1-csr-load-data
npm start

CSR load data gif

2-csr-router vanilla react SPA routing

[!IMPORTANT] After the page has been loaded for the first time, navigating to other pages on the same website uses JavaScript to re-render parts of the page without requiring a full page refresh.

demostración

root@kitploit:~
cd 2-csr-router
npm start

client side rendering routing

RSC React Server Components

3-rsc-load-data React Server Components (Next.js impl) loading data

mind map CSR

[!IMPORTANT] React components which are written to run only on the server, rather than in the browser.

React Server Components loading data

demostración

root@kitploit:~
cd 3-rsc-load-data
npm run build
npm run start

client side rendering routing

4-rsc-router React Server Components (Next.js impl) routing

mind map CSR

[!IMPORTANT] Components are executed only on the server. The default behavior is static rendering: components are executed at build time.

demostración

root@kitploit:~
cd 4-rsc-router
npm run build
npm run start

React server components routing

5-SSR SSR Server Side Rendering

mind map SSR

[!IMPORTANT] SSR means prerendering client components on the server. React code runs at the time it is requested. The result may be cached for future requests.

Best practice: define 'use client'; components as far down the component tree as possible.

https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#moving-client-components-down-the-tree

Hydration

[!IMPORTANT] "In React, “hydration” is how React “attaches” to existing HTML that was already rendered by React in a server environment. During hydration, React will attempt to attach event listeners to the existing markup and take over rendering the app on the client. In apps fully built with React, you will usually only hydrate one “root”, once at startup for your entire app."

https://react.dev/reference/react-dom/client/hydrateRoot

https://www.gatsbyjs.com/docs/conceptual/partial-hydration/

demostración

root@kitploit:~
cd 5-ssr
npm run build
npm run start

SSR

6-pages-router-ssg (Next.js impl)

mind map page router SSG

[!IMPORTANT] SSG (Static Site Generation) using the pages router: React code is run when you build your application, and the generated output is static.

demostración

root@kitploit:~
cd 6-pages-router-ssg
npm run build
npm run start

7-pages-router-isr (Next.js impl)

mind map page router ISR

[!IMPORTANT] ISR (using pages router): "Next.js allows you to create or update static pages after you’ve built your site. Incremental Static Regeneration (ISR) enables you to use static-generation on a per-page basis, without needing to rebuild the entire site. With ISR, you can retain the benefits of static while scaling to millions of pages."

demostración

root@kitploit:~
cd 7-pages-router-isr
npm run build
npm run start

¿Por qué ISR?

"the data could become stale at request time"

https://vercel.com/blog/nextjs-server-side-rendering-vs-static-generation

Server actions

https://react.dev/reference/rsc/server-actions

SSRF (fixed in NextJS v14.1.1)

Definición SSRF

...

¿Por qué?

  • Si se tiene acceso a un servidor vulnerable pero no al servidor objetivo directamente (DMZ, Firewall...)
  • Si se quieren ejecutar peticiones ocultando el propio origen
  • ...

Demostración 8-ssrf-14.1.0

Contexto

SSRF A

https://www.assetnote.io/resources/research/digging-for-ssrf-in-nextjs-apps

Objetivo

SSRF B, objetivo

Condiciones para explotar la CVE-2024-34351

  • Una aplicación basada en Next.JS con versión inferior a 14.1.1
  • El uso de la función redirect, con una ruta absoluta. En la demo, en addTodo.js: redirect(/blog/${inputValue});

Funcionamiento de la función redirect

Fuente: https://www.assetnote.io/resources/research/digging-for-ssrf-in-nextjs-apps

  • La función Next.JS redirect no devuelve una respuesta HTTP 302 al navegador.

Next.JS ejecuta la petición del lado del servidor, y luego devuelve el resultado al navegador:

  • Para ejecutar la petición, Next.JS debe construir la URL a llamar. En la demo, en addTodo.js: La función redirect('/blog/123'); construye la URL http://207.154.209.99/blog/123. Para construir esta URL, Next.JS obtiene el host 207.154.209.99 a partir del header HTTP de la petición inicial.
  • Next.JS primero realiza una petición HTTP HEAD a la URL.
  • Si la respuesta devuelve un header Content-Type: text/x-component, entonces Next.JS realiza una petición HTTP GET a la URL.

SSRF C, intro

Explotación

Para lograr un SSRF en el servidor objetivo, es necesario ejecutar otro servidor:

  • que escuche en todas las rutas (query path)
  • que devuelva un HTTP 200 con un header Content-Type: text/x-component, para cualquier petición HEAD
  • que devuelva un HTTP 302 hacia el servidor objetivo, para cualquier petición GET

SSRF D, exploit

CSR load data gif

Corrección de la vulnerabilidad en 8-ssrf-14.1.0

Solución 1 (no permanente): Configuración de nginx para forzar el host

En /etc/nginx/sites-available/nextjs

Antes:

root@kitploit:~
server {
  listen 80 default_server;
  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
}

Después:

root@kitploit:~
server {
  listen 80;
  server_name 207.154.209.99;
  location / {
    proxy_pass http://localhost:3000;
    proxy_set_header Host 207.154.209.99;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
}

Riesgo de efectos secundarios...

https://nginxtutorials.com/nginx-proxy_set_header-directive/

Solución 2: actualizar Next.js

https://github.com/vercel/next.js/security/advisories/GHSA-fr5h-rqp8-mj6g

Notas

"Extra attributes from the server"

https://stackoverflow.com/questions/75337953/what-causes-nextjs-warning-extra-attributes-from-the-server-data-new-gr-c-s-c

"getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching

https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#static-site-generation-getstaticprops

create-next-app

https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-4-migrating-pages

Pages in the app directory are Server Components by default. This is different from the pages directory where pages are Client Components.

Upgrading to Next.js 13 does not require using the new App Router. You can continue using pages with new features that work in both directories

Rendimiento

Si se quieren comparar los rendimientos de carga para las diferentes soluciones, se pueden agregar las métricas web core vitales en console.log.

https://web.dev/articles/fcp?hl=fr

otras fuentes / referencias

https://rsc-parser.vercel.app/

https://stackoverflow.com/questions/76325862/what-is-the-difference-between-react-server-components-rsc-and-server-side-ren

https://github.com/reactjs/server-components-demo?tab=readme-ov-file#should-i-use-this-demo-for-benchmarks

https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#does-this-replace-ssr

https://www.youtube.com/watch?v=jEJEFAc8tSI

ISR using App router ?

https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration

In the Next.js App Router, all fetched data is now static by default, rendered at build time. However, this can be changed easily: Next.js extends the fetch options object to provide flexibility in caching and revalidating rules. You can use the {next: {revalidate: number}} option to refresh static data at set intervals or when backend changes occur (Incremental Static Regeneration), while the {cache: 'no-store'} option can be passed in the fetch request for dynamic data (server-side rendering).

https://www.telerik.com/blogs/current-state-react-server-components-guide-perplexed

https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components

https://github.com/reactjs/server-components-demo

https://dev.to/vteacher/let-s-make-a-web-application-with-react-server-components-5dmg

https://react.dev/blog/2024/04/25/react-19

https://react.dev/reference/rsc/server-components

https://www.youtube.com/watch?v=ePAPd9qzGyM

https://www.joshwcomeau.com/react/server-components/

https://nextjs.org/docs/app/building-your-application/rendering/server-components#server-rendering-strategies

https://nextjs.org/docs/pages/building-your-application/rendering/static-site-generation

https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props

https://react.dev/reference/rsc/server-components#server-components-without-a-server

Descargar herramienta