Skip to content
Crypto Write-up Advanced

Minting Next.js Authentication Cookies

The post describes how an attacker who already has code execution through a deserialisation flaw in Next.js applications can forge authentication cookies to keep persistent access as any user. It frames this as a follow-on step after exploiting that deserialisation vulnerability.

embracethered.com

Published on embracethered.com

In this post, we’ll look how an adversary can mint authentication cookies for Next.js (next-auth/Auth.js) applications to maintain persistent access to the application as any user.

The author, on embracethered.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application's cookie-signing secret can be read once an attacker has code execution, letting them forge valid session cookies.

Impact

An attacker with code execution could forge cookies and keep persistent access to the application as any user.

What the attacker needed

Prior code execution via deserialisation

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Next.js is a framework for building web apps, and next-auth is a common add-on that handles logging users in. Login state is often kept in a cookie, a small piece of data the browser sends back on each request. If an attacker can learn the secret used to sign that cookie, they can create their own valid-looking cookie and pretend to be any user without knowing a password.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.