<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7" -->

---
title: Preventing Destructive Actions with Step-up Authentication
description: A walkthrough shows how Cursor AI generated a complete step-up authentication feature for a Next.js admin panel, gating a destructive 'reset all scores' action...
canonical: https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Preventing Destructive Actions with Step-up Authentication | daily.dev
og:description: A walkthrough shows how Cursor AI generated a complete step-up authentication feature for a Next.js admin panel, gating a destructive 'reset all scores' action...
og:url: https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7
og:image: https://api.daily.dev/og/posts/0VXSMlxe7.png
og:image:alt: Preventing Destructive Actions with Step-up Authentication
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Preventing Destructive Actions with Step-up Authentication

**[Auth0](https://daily.dev/sources/auth0)** · 16 min read · 0 upvotes · 0 comments

## Summary

A walkthrough shows how Cursor AI generated a complete step-up authentication feature for a Next.js admin panel, gating a destructive 'reset all scores' action behind fresh MFA verification. It explains why role checks alone are insufficient for high-impact actions, details three protection tiers (role check, MFA-in-session, step-up authentication), and breaks down the generated code: a helper module checking amr/acr/custom claims and auth_time freshness, a beforeSessionSaved hook needed because Auth0's Next.js SDK drops these claims by default, a three-gate API endpoint (session, role, freshness), and a client component that opens the MFA popup proactively before the reset request fires. Several gotchas are covered, including the critical need for the beforeSessionSaved hook and an iat fallback when auth_time is missing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://auth0.com/blog/preventing-destructive-actions-with-step-up-authentication>

## Questions this post answers

### Why doesn't checking that a user's session already has MFA prove they're authorized to perform a destructive admin action?

A session with MFA in it only proves the user enrolled MFA and authenticated with it at some point, but auth_time could be hours old, making a stale session indistinguishable from an actively re-verified one. Step-up authentication instead requires amr to contain mfa, plus auth_time (or iat as fallback) within a 5-minute freshness window, forcing re-verification at the moment of the action rather than relying on login-time MFA.

_Developers hardening admin actions can compare session-MFA versus step-up patterns using resources surfaced on daily.dev._

### Why does hasFreshMfaStepUp return false even after a user completes MFA with the Auth0 Next.js SDK?

The Auth0 Next.js SDK's default claim filter strips amr, auth_time, iat, acr, and any custom step-up claim from the session by default, so every signal the freshness check relies on is undefined. Adding a beforeSessionSaved hook on the Auth0Client that manually re-adds these five claims after running filterDefaultIdTokenClaims fixes it; without this hook the reset button stays permanently stuck at mfa_required.

_Anyone debugging Auth0 session claims in Next.js can track SDK gotchas like this via daily.dev._

### Why does a step-up MFA check need to fall back to the iat claim instead of only using auth_time?

An MFA-only step-up challenge triggered without max_age=0 sometimes does not refresh auth_time on the returned token, even though it does mint a new ID token with a fresh iat. Checking iat as a fallback within the same freshness window (5 minutes in this implementation) catches that case; without it, the freshness check silently fails even though the MFA challenge actually ran.

_Developers implementing MFA freshness checks can find edge cases like this while researching on daily.dev._

## Similar posts on daily.dev

- [A Practical Guide to Secure Authentication for Developers](https://daily.dev/posts/a-practical-guide-to-secure-authentication-for-developers-p5rufwxgq) · SitePoint · 0 upvotes · 0 comments
- [A Comprehensive Guide to Auth0 Security for Identity Attacks](https://daily.dev/posts/a-comprehensive-guide-to-auth0-security-for-identity-attacks-oiypqqvmq) · Auth0 · 0 upvotes · 0 comments
- [Protecting Next.js Applications in the Era of Server Actions](https://daily.dev/posts/protecting-next-js-applications-in-the-era-of-server-actions-wqyz3uq9e) · JS Dev Space · 2 upvotes · 0 comments
- [When attackers already have the keys, MFA is just another door to open](https://daily.dev/posts/when-attackers-already-have-the-keys-mfa-is-just-another-door-to-open-w43ekq8fj) · BleepingComputer · 0 upvotes · 0 comments

---

Tags: [#authentication](https://daily.dev/tags/authentication), [#nextjs](https://daily.dev/tags/nextjs), [#auth0](https://daily.dev/tags/auth0)

[View this post on daily.dev](https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Preventing Destructive Actions with Step-up Authentication","url":"https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7"},"datePublished":"2026-09-17T16:30:57.619Z","dateModified":"2026-09-17T19:07:55.964Z","description":"A walkthrough shows how Cursor AI generated a complete step-up authentication feature for a Next.js admin panel, gating a destructive 'reset all scores' action...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3bc6bff3820a39cf20b8955a4ec64fb5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3bc6bff3820a39cf20b8955a4ec64fb5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Auth0","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Auth0","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/6510ffa7350449618fbacdddae663b82","url":"https://daily.dev/sources/auth0"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"authentication,nextjs,auth0","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Auth0","item":"https://daily.dev/sources/auth0"},{"@type":"ListItem","position":3,"name":"Preventing Destructive Actions with Step-up Authentication"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/preventing-destructive-actions-with-step-up-authentication-0vxsmlxe7#faq","mainEntity":[{"@type":"Question","name":"Why doesn't checking that a user's session already has MFA prove they're authorized to perform a destructive admin action?","acceptedAnswer":{"@type":"Answer","text":"A session with MFA in it only proves the user enrolled MFA and authenticated with it at some point, but auth_time could be hours old, making a stale session indistinguishable from an actively re-verified one. Step-up authentication instead requires amr to contain mfa, plus auth_time (or iat as fallback) within a 5-minute freshness window, forcing re-verification at the moment of the action rather than relying on login-time MFA. Developers hardening admin actions can compare session-MFA versus step-up patterns using resources surfaced on daily.dev."}},{"@type":"Question","name":"Why does hasFreshMfaStepUp return false even after a user completes MFA with the Auth0 Next.js SDK?","acceptedAnswer":{"@type":"Answer","text":"The Auth0 Next.js SDK's default claim filter strips amr, auth_time, iat, acr, and any custom step-up claim from the session by default, so every signal the freshness check relies on is undefined. Adding a beforeSessionSaved hook on the Auth0Client that manually re-adds these five claims after running filterDefaultIdTokenClaims fixes it; without this hook the reset button stays permanently stuck at mfa_required. Anyone debugging Auth0 session claims in Next.js can track SDK gotchas like this via daily.dev."}},{"@type":"Question","name":"Why does a step-up MFA check need to fall back to the iat claim instead of only using auth_time?","acceptedAnswer":{"@type":"Answer","text":"An MFA-only step-up challenge triggered without max_age=0 sometimes does not refresh auth_time on the returned token, even though it does mint a new ID token with a fresh iat. Checking iat as a fallback within the same freshness window (5 minutes in this implementation) catches that case; without it, the freshness check silently fails even though the MFA challenge actually ran. Developers implementing MFA freshness checks can find edge cases like this while researching on daily.dev."}}]}
```

