Back to skill

Security audit

Next.js Production Engineering

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent Next.js guidance, but its production authentication example can accidentally leave protected pages unprotected.

Review this skill before installing if you might ask it to add authentication. Do not copy its middleware auth snippet as-is; require verified sessions through Auth.js, a trusted session store, or signed-token validation, and add tests for protected routes. The rest of the package appears to be ordinary Next.js production guidance rather than malicious behavior.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:357
Finding
Authentication Bypass Through Unverified Session Cookie<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 357–381 **Vulnerability Type**: Authentication bypass caused by trusting an unverified cookie **Risk Level**: High ### Vulnerable Code ```tsx const publicRoutes = ['/', '/login', '/register', '/api/webhooks'] const authRoutes = ['/login', '/register'] export function middleware(request: NextRequest) { const { pathname } = request.nextUrl const token = request.cookies.get('session')?.value // Public routes — allow if (publicRoutes.some(route => pathname.startsWith(route))) { // Redirect authenticated users away from auth pages if (token && authRoutes.some(route => pathname.startsWith(route))) { return NextResponse.redirect(new URL('/dashboard', request.url)) } return NextResponse.next() } // Protected routes — require auth if (!token) { const loginUrl = new URL('/login', request.url) loginUrl.searchParams.set('callbackUrl', pathname) return NextResponse.redirect(loginUrl) } return NextResponse.next() } ``` ### Technical Analysis The middleware considers a request authenticated whenever the `session` cookie contains any non-empty value. It does not cryptographically verify the cookie, resolve it against a trusted server-side session store, or validate properties such as expiration, revocation status, issuer, or audience. Cookies are controlled by the requesting client. Unless another trusted layer independently validates the session, an attacker can create an arbitrary `session` cookie and satisfy the middleware’s only authentication condition. This pattern is especially hazardous because it is presented as a production authentication pattern. Applications that copy it may rely on the middleware as their primary access-control boundary. Route-level authorization does not correct the middleware flaw unless every protected page, API handler, and Server Action independently validates the authenticated session. ### Attack Path 1. The ...[truncated 1407 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Replace cookie-presence checks with trusted session validation: 1. Use the selected authentication framework’s middleware or server-side session API rather than manually checking whether a cookie exists. 2. For signed tokens, verify the cryptographic signature and validate expiration, issuer, audience, and token type before accepting the request. 3. For opaque session identifiers, resolve the identifier through a trusted server-side session store and verify that the session is active, unexpired, and not revoked. 4. Use secure cookie settings: `HttpOnly`, `Secure`, an appropriate `SameSite` policy, a restricted `Path`, and a narrowly scoped `Domain`. 5. Reject malformed, expired, revoked, or unverifiable sessions by default. 6. Perform independent authentication and resource-level authorization in every Server Action, Route Handler, and sensitive data-access operation. Middleware should be treated as defense in depth, not the sole authorization boundary. 7. Add tests proving that arbitrary, expired, incorrectly signed, and revoked session cookies cannot access protected routes. 8. Update the Skill documentation so its production example demonstrates actual verification rather than cookie presence. A hardened conceptual pattern is: ```tsx export async function middleware(request: NextRequest) { const session = await verifySession(request) if (!session) { const loginUrl = new URL('/login', request.url) loginUrl.searchParams.set('callbackUrl', request.nextUrl.pathname) return NextResponse.redirect(loginUrl) } return NextResponse.next() } ``` `verifySession` must use a trusted authentication library or perform complete cryptographic/server-side validation; it must not merely return the cookie value. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Intent-Code Divergence

High
Confidence
99% confidence
Finding
The middleware example is logically broken because `publicRoutes` includes `'/'` and the check uses `pathname.startsWith(route)`, which makes every path match as public. If copied into a real app, protected routes would become accessible without authentication, causing a complete authentication bypass at the routing layer.

External Transmission

Medium
Category
Data Exfiltration
Content
```tsx
// Static data (cached indefinitely, revalidated on deploy)
const data = await fetch('https://api.example.com/data', {
  cache: 'force-cache'  // Default in App Router
})
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
```tsx
// Static data (cached indefinitely, revalidated on deploy)
const data = await fetch('https://api.example.com/data', {
  cache: 'force-cache'  // Default in App Router
})
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
```tsx
// Static data (cached indefinitely, revalidated on deploy)
const data = await fetch('https://api.example.com/data', {
  cache: 'force-cache'  // Default in App Router
})
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
```tsx
// Static data (cached indefinitely, revalidated on deploy)
const data = await fetch('https://api.example.com/data', {
  cache: 'force-cache'  // Default in App Router
})
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Vague Triggers

Medium
Confidence
89% confidence
Finding
This markdown file defines activation-style commands such as "Optimize performance," "Add authentication," and "Audit my app" that are common requests and are not bounded by explicit invocation context, trigger matching rules, or negative examples. That ambiguity increases the chance the skill could be invoked for general conversation or unrelated engineering tasks rather than only when the user intends this specific skill.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
The example config restricts font subsets to `latin` and sets `<html lang="en">`, which reflects a fixed language/locale assumption in natural-language-facing application output. Because the document does not present this as optional, user-selected, or region-specific, it conflicts with the policy against forcing a specific language or locale without opt-in.

Static analysis

No suspicious patterns detected.