mcpField
N
nextjs-secure-bff

nextjs-secure-bff

github.com/xirothedev安全259 次安装23 周前更新
代码仓库

关于 nextjs-secure-bff

面向 Next.js 后端边界安全审查的技能,适用于 Route Handlers、Server Actions、代理端点及 Webhook。它按优先级提供规则文件和示例,重点检查授权、输入验证与输出过滤。

主要功能

  1. 01审查公开入口与后端边界
  2. 02检查身份验证和授权
  3. 03验证 Webhook 输入
  4. 04控制代理请求头与输出
  5. 05按需加载规则和代码示例

适用场景

  1. 01审查 Next.js Route Handlers 的安全性
  2. 02检查修改数据的 Server Actions 授权
  3. 03保护代理端点和 Webhook
  4. 04减少客户端数据及序列化结果泄露

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/xirothedev/skills --skill nextjs-secure-bff

安装后在 Claude Code 中输入/nextjs-secure-bff确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

AGENTS.md
metadata.json
test-cases.json
dataset/api/proxy-headers/
correct.ts
incorrect.ts
notes.md
dataset/api/route-boundaries/
correct.ts
incorrect.ts
notes.md
dataset/api/webhook-validation/
correct.ts
incorrect.ts
notes.md
dataset/security/dal-dto/
correct.tsx
incorrect.tsx
notes.md
dataset/security/env-server-only/
correct.ts
incorrect.ts
notes.md
dataset/security/server-action-authz/
correct.ts
incorrect.tsx
notes.md
references/
_sections.md
api-proxy-headers.md
api-route-boundaries.md
api-webhook-validation.md
security-dal-dto.md
security-env-server-only.md
security-server-action-authz.md
sources/
inventory.json

详细介绍

Next.js 安全 BFF

当 Next.js 充当公共后端边界,而不仅仅是渲染层时,请使用此技能。将 Route Handlers、Proxy 和 Server Actions 视为可从外部访问的入口,并按常规后端安全要求进行审查。

适用场景

在以下情况下使用此技能:

  • 编写或审查 app/**/route.ts、proxy.ts、Webhook 处理程序、回调 URL 或 BFF 代理端点
  • 设计会修改数据或依赖已认证用户的 Server Actions
  • 将数据库、密钥或内部 API 访问移入 Next.js 应用
  • 审核传递给 Client Components 的数据是否已精简且安全
  • 调试通过标头、序列化的 Action 结果、日志或宽泛的 DTO 导致的数据泄露

按需加载

从此文件开始。仅在任务需要时加载详细文件:

references/_sections.md
references/api-route-boundaries.md
references/security-server-action-authz.md
references/security-dal-dto.md
references/security-env-server-only.md
references/api-webhook-validation.md
references/api-proxy-headers.md
dataset/security/server-action-authz/correct.ts
sources/inventory.json

每个规则文件都包含:

  • 该模式的重要性
  • 错误和正确的示例
  • 包含更大型 TypeScript/TSX 示例的数据集路径
  • 官方来源参考

规则类别优先级

按优先级数字从低到高解决冲突。优先级相同时,依次优先考虑安全、API 和运维。

优先级类别影响前缀
1安全与授权严重security-
2公共 API 边界严重api-
3运维与运行时控制高ops-

来源政策

对于框架语义,优先参考 Next.js 官方文档。对于身份验证库,在此技能明确 Next.js 安全边界后,遵循该库的官方适配器文档。不要复制社区提供的 Webhook、代理或 Server Action 代码片段,除非它们会验证输入、重新授权调用方并过滤输出。

评论

支持 Markdown