Fireship · @fireship

Next.js rocked by critical 9.1 level exploit...

Uploaded March 24, 2025 · Length 3:49

Next.js rocked by critical 9.1 level exploit...

Summary

nextjs hit by critical 9.1 exploit allowing attackers to bypass authentication and authorization in middleware, prompting urgent upgrade to patch version.

  • nextjs exploit
  • nextjs security
  • middleware bypass
  • versel security
  • cloudflare vs versel

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    last Friday right after you made the

  2. 0:01

    mistake of deploying your code on a

  3. 0:03

    Friday the world's most popular

  4. 0:04

    JavaScript framework nextjs was hit by a

  5. 0:07

    critical 9.1 security advisory the

  6. 0:10

    exploit allows an attacker to bypass

  7. 0:12

    authentication and authorization in

  8. 0:13

    nextjs middleware which is really bad

  9. 0:16

    like if you have a software as a service

  10. 0:18

    product normally you would have code in

  11. 0:19

    your middleware that says something like

  12. 0:21

    if you know pay me yet redirect a

  13. 0:23

    pricing page but apparently verell the

  14. 0:25

    company behind xjs has been Vibe coding

  15. 0:27

    its security logic recently because an

  16. 0:29

    attacker can just say no thank you to

  17. 0:30

    any off checks and use your app without

  18. 0:32

    pain this mistake has led to a mass

  19. 0:34

    celebration among nextjs and react

  20. 0:36

    haters who are currently screaming I

  21. 0:38

    Told You So from Mom's basement and even

  22. 0:40

    big public companies like cloudflare are

  23. 0:41

    using this as an opportunity to poach

  24. 0:43

    customers from versel leading to some

  25. 0:45

    glorious Tech bro drama on Twitter but

  26. 0:47

    the most important thing to know right

  27. 0:49

    now is that if you currently have a

  28. 0:50

    nextjs app in production that has not

  29. 0:52

    been upgraded you could be in serious

  30. 0:54

    danger so in today's video we'll find

  31. 0:56

    out how screwed you really are and learn

  32. 0:58

    how the worst nextjs security dir flaw

  33. 1:00

    of all time actually works it is March

  34. 1:02

    24th 2025 and you're watching the code

  35. 1:04

    report let's get right down to business

  36. 1:06

    if you're currently running a nextjs

  37. 1:08

    version that hasn't been patched you

  38. 1:09

    want to upgrade as ASAP as possible

  39. 1:11

    however if you're not using nextjs

  40. 1:13

    middleware or hosting on versell or

  41. 1:15

    netlify you don't need to worry but if

  42. 1:17

    you're self-hosting and using versell

  43. 1:18

    middleware your app will likely be dead

  44. 1:20

    by the time you finish watching this

  45. 1:21

    video here's how the exploit actually

  46. 1:23

    works virtually every web framework out

  47. 1:25

    there has a concept of middleware which

  48. 1:27

    is basically just some code that sits in

  49. 1:29

    between a request re EST and response on

  50. 1:30

    your server as the name implies it's a

  51. 1:32

    layer that sits in the middle and is

  52. 1:34

    often used to perform generic actions

  53. 1:36

    like logging error handling and

  54. 1:38

    authorization so you don't have to

  55. 1:40

    reimplement that logic on every single

  56. 1:41

    route that's all good but the security

  57. 1:43

    researchers who found this exploit were

  58. 1:45

    dumpster diving through some old nextjs

  59. 1:47

    code and found a header that could be

  60. 1:49

    used to skip any nextjs middleware that

  61. 1:51

    you want you just need to know the name

  62. 1:52

    of the middleware and add it to this

  63. 1:54

    middleware sub request header and it

  64. 1:55

    just so happens that the middleware

  65. 1:57

    names are easily guessable thanks to

  66. 1:58

    naming conventions what's scary about it