Back to skill

Security audit

NextJS

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent Next.js guidance skill with disclosed local memory use, but users should be careful with its beta authentication dependency advice and local project-memory persistence.

Install only if you are comfortable with the skill storing local Next.js project context under ~/Clawic/data/nextjs/. Before applying its auth setup, pin and review authentication package versions instead of blindly using next-auth@beta, and enforce admin authorization in Server Actions, route handlers, and data-access functions rather than relying on middleware alone.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
auth.md:38
Finding
Mutable Prerelease Authentication Dependency## Vulnerability Details **File Location**: `auth.md`, lines 38–40 **Vulnerability Type**: Supply-chain risk from an unpinned prerelease dependency **Risk Level**: Medium **Vulnerable Code Snippet**: ```markdown ### Installation ```bash npm install next-auth@beta ``` ``` ### Technical Analysis The Skill recommends installing `next-auth` through the mutable `beta` distribution tag rather than an exact, reviewed version. The package version selected by this command can therefore change after the Skill has been audited, making installation behavior non-reproducible. This dependency is particularly security-sensitive because it participates in credential verification, OAuth integration, session creation, and authorization decisions. Running `npm install` can also execute lifecycle scripts from the selected package or its transitive dependencies in the context of the user's project. This finding does not establish that the current `next-auth` beta package is malicious. The vulnerability is the unsafe dependency-selection practice: a future defective or compromised prerelease could be installed without any corresponding change to the reviewed Skill. ### Attack Path 1. A user or agent follows the authentication setup instructions in `auth.md`. 2. The command `npm install next-auth@beta` asks the npm registry to resolve the package currently associated with the mutable `beta` tag. 3. The resolved release or one of its transitive dependencies has been compromised, contains a malicious lifecycle script, or introduces a security regression. 4. During installation, any applicable lifecycle code executes with the permissions of the user running npm and can access the project workspace and environment available to that process. 5. The dependency subsequently executes within the application's authentication boundary, potentially affecting credentials, OAuth tokens, sessions, or authorization decisions. ### Impact Assessment ...[truncated 732 chars]
Remediation
## Remediation Suggestions 1. Replace the mutable prerelease tag with an exact version that has been reviewed and tested, for example: ```bash npm install --save-exact next-auth@<reviewed-version> ``` 2. Commit the generated lockfile and use `npm ci` in CI and deployment workflows to enforce reproducible dependency resolution. 3. Require explicit user confirmation before running package-installation commands generated from the Skill. 4. Review release notes, known vulnerabilities, provenance, and package integrity before upgrading the pinned version. 5. Use automated dependency scanning and lockfile review for both direct and transitive dependencies. 6. Where operationally feasible, disable unnecessary npm lifecycle scripts during initial validation with `--ignore-scripts`, then explicitly permit only required installation behavior after review. 7. Prefer a stable release rather than a beta release unless the documented Next.js/Auth.js integration specifically requires prerelease functionality.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (7)

Ae1

High
Category
analysis-evasion
Content
| Page slow, sequential awaits, streaming, Server Actions | `data-fetching.md` |
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Credential Access

High
Category
Privilege Escalation
Content
```
Loading order (first wins):
1. .env.local            (gitignored; not loaded in test)
2. .env.[environment].local
3. .env.[environment]
4. .env
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
1. .env.local            (gitignored; not loaded in test)
2. .env.[environment].local
3. .env.[environment]
4. .env
```

- No prefix → server only. `NEXT_PUBLIC_` → **inlined into the client bundle at build time** (SKILL.md Rule 8).
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Hidden Instructions

High
Category
Prompt Injection
Content
- **File organization:** 

## Project Conventions
<!-- Add team/personal conventions here -->

## Learned Patterns
<!-- Patterns discovered through working together -->
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The manifest description says to use the skill for "any Next.js routing, data, cache, or build issue," which is a very broad activation condition without explicit constraints or negative examples. In a manifest file, this can cause the skill to match a wide range of common development conversations beyond a narrowly defined trigger.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The document correctly states that middleware is not a security boundary because it can be bypassed, but the later RBAC example performs admin authorization in middleware for `/admin` paths without showing an equivalent enforcement in the data layer, route handler, or Server Action. Readers may copy this pattern and rely on middleware-only role checks, which can expose admin functionality if middleware is skipped or becomes stale, directly contradicting the earlier warning.

Missing User Warnings

Low
Confidence
90% confidence
Finding
The skill explicitly instructs persisting project context and user preferences to a local memory file, but it does not require any user-facing disclosure or consent before storing that information. While this is not overtly malicious, it creates a privacy and transparency risk because users may not realize that preferences, conventions, or deployment details are being retained across sessions.

Static analysis

No suspicious patterns detected.