Skip to content
cccskills
FreePublished on GitHub

Next.js Server Action Security Review

Checks Next.js Server Actions ('use server') for missing authentication/authorization before mutations, missing input validation, and untrusted client-supplied IDs — treating each action as a public HTTP endpoint.

The English summary is being prepared. Showing the original description.

See how to install

Files included (4)

  • SKILL.md4.5 KB
  • fixtures/01-missing-auth-mutation-happy.md1.3 KB
  • fixtures/02-delegated-auth-guard.md1.4 KB
  • golden/01-missing-auth-mutation-happy.md1.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Pattern declaration

Primary pattern: Reviewer Secondary patterns: Inversion Why: Server Action を「誰でも呼べる公開エンドポイント」と仮定し、認証・認可・入力検証の欠落をチェックリスト型で検査する。

Goal / 目的

  • 'use server' で公開される Server Action は 認証なしに誰でも呼べる公開 HTTP エンドポイントである、という前提に立つ。
  • mutation(DB の更新・削除・課金など)前に、セッション/認証と認可(リソース所有者確認)が検証されていない欠落を検出する。
  • formData や引数を検証せず DB へ直接渡す入力バリデーション欠如、クライアントから渡る ID をなりすまし可能なまま信頼する誤りを検出する。

Non-goals / 扱わないこと

  • client/server 境界判定(use client 誤用)は nextjs-app-router-boundary の領域。本スキルでは扱わない。
  • read-only の Server Action(mutation を伴わないもの)への認可指摘。
  • 認証ライブラリ・バリデーションライブラリの選定や設計全般。
  • CSRF / レート制限などインフラ層の防御(フレームワーク・基盤の責務)。

Pre-execution Gate / 実行前ゲート

このスキルは以下の条件がすべて満たされない限りNO_REVIEWを返す。

  • 差分に 'use server' 関数 / Server Action(actions.ts など)の追加・変更が含まれている
  • diff コンテキストが利用可能である

ゲート不成立時の出力: NO_REVIEW: nextjs-server-action-security — Server Action の変更なし

False-positive guards / 抑制条件

  • 認証チェックを共通ヘルパー(requireUser() / requireAuth() 等)に委譲しており、差分内にその呼び出しが見える場合は指摘しない。
  • 公開フォーム(問い合わせ・ニュースレター登録など、認証不要が要件上正当なもの)で、その旨がコメントで明記されている mutation は、認可指摘を質問に留める。
  • read-only の Server Action(mutation なし)は認可指摘の対象外。
  • 入力検証を共通ヘルパーやスキーマ(zod 等)へ委譲し、差分内でその呼び出しが見える場合は指摘しない。

Rule / ルール

  • mutation を行う Server Action は、処理前に認証(例: auth() / getServerSession() / requireUser() 等)でセッションを確認する。
  • mutation 対象がユーザー固有リソースなら、認可(リソース所有者がセッションユーザーと一致するか)を確認する。
  • formData / 引数は zod 等で検証してから利用する。型は信頼できない(Server Action の引数はクライアント由来)。
  • formData.get('userId') のようにクライアントから渡る ID を所有者として信頼しない。所有者はセッションから導出する。

Evidence / 根拠の取り方

  • 指摘は <file>:<line> で差分に紐づけ、mutation 呼び出しと認証/認可/検証の欠落箇所を併記する。
  • 抑制条件に該当しないこと(差分内にヘルパー呼び出しが見えないこと)を根拠として示す。

Output / 出力(短文版の推奨)

コメントは日本語で返す。

  • Finding: どの防御が欠落しているか(1文)
  • Impact: 不正な mutation / なりすまし / 不正入力の DB 反映 等
  • Fix: 認証チェック / 所有者確認 / zod 検証の最小修正案

Sources / 出典

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

<What this skill does>

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

画像・ボタン・フォーム要素に適切なアクセシブルネームがあるか確認する。

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

Ensure ADRs capture context, decision, alternatives, tradeoffs, and follow-ups in a way that prevents future drift.

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

敵対的分析手法を統合したレビューの entry skill。認知バイアス対策の3手法 (Pre-mortem / War Game / Logic Torturing)と、宣言・主張と実態の乖離を突く claim-vs-actual 検出3パターン(Self-Contradiction / Refactor-Claim Audit / Cross-File Leakage)へルーティングし、通常のレビューでは見えない設計の盲点・ 防御の穴・論理の弱点・宣言と実装のズレを可視化する。

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

Review changes to the Agent Skills import/export bridge for path safety, round-trip fidelity, and validation correctness.

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

Checks whether AI-assisted work defines review criteria, accessible context, explicit review loop, human judgment boundary, and feedback capture before delegating to an agent.

The English summary is being prepared. Showing the original description.

s977043/river-review7Updated Oct 23, 2026

See all skills by s977043

Report a problem with this skill