T09 · Insecure Skill Coding Practices
- Location
references/templates/auth-slice.md:27- Finding
Unvalidated Post-Authentication Redirect
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a coherent Next.js scaffolding skill, but it needs review because its auth templates include an unsafe post-login redirect and its setup can run a mutable third-party CLI.
Install only if you are comfortable reviewing generated auth and setup code. Before using it for a real app, validate returnTo so login can only redirect to safe same-origin paths, pin any CLI package executed during scaffolding, and run installs/migrations in a development environment without production secrets or databases.
references/templates/auth-slice.md:27Unvalidated Post-Authentication Redirect
SKILL.md:72Execution of a Mutable Third-Party CLI Package
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
components.json # shadcn config; rsc: true
.eslintrc.json (or eslint.config.mjs)
.prettierrc
.env.example # NEVER .env — only .env.example committed
middleware.ts # NextAuth-driven route gate; re-exports `auth`
docker-compose.yml # optional: only if user picked "local Docker"
prisma/
The skill instructs the agent to auto-trigger on broad phrases like 'new Next app', 'use my Next.js conventions', or 'add a feature end-to-end', including when the user does not name the skill. This can cause overbroad activation and unintended file generation or command execution in ordinary conversations, reducing user intent verification and increasing the chance of risky actions being taken on the wrong project or request.
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
The template sets <html lang="en">, which enforces an English locale at the application root. Under the policy, locale-specific behavior should be optional or clearly justified; this file provides neither user opt-in nor documentation that the skill is intentionally English-only.
The login page reads a user-controlled returnTo query parameter and passes it directly to router.replace(returnTo) after successful authentication, with no validation that the destination is same-origin and within an allowed path set. This creates an open-redirect style post-login flow that can be abused for phishing, redirect chaining, or steering authenticated users to attacker-controlled destinations if absolute URLs or crafted paths are accepted by the router.
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
- **No `requireSession()` call** in any handler outside `/api/auth/*` and explicitly-public ones (and the public ones must comment why).
- **Trusting `userId` from the request body.** Always read it from the session: `session.user.id`.
- **Returning the full record on POST/PATCH without checking ownership first** on updates — the `where: { id, userId }` predicate is the gate.
- **`prisma.$queryRaw` with string concatenation.** Use parameterized template literals (`prisma.$queryRaw\`... ${value} ...\``) or stick to the typed query builder.
- **Catching and re-throwing without logging.** `withApiErrors` logs unexpected errors; if you write your own try/catch, log unexpected ones at least once.
- **Returning 500 with the raw error message.** Leaks stack traces. `withApiErrors` returns a generic message; if you write your own, do the same.
This markdown template instructs implementers to parse request JSON in matching API route handlers and the form component performs create/update mutations, but the template does not mention that submitted data will be transmitted to server endpoints and saved. For markdown files, SQP-2 applies when behavior affecting user data or privacy is described without warning.
This is a markdown file, so SQP-2 applies to omissions in the skill description. The text states that the login form uses NextAuth's signIn directly, which implies network transmission of email/password, but it does not include any warning about credential handling or privacy implications.
No suspicious patterns detected.