跳到正文
Skillpedia
安全7.6k · #13180

security

它能做什么

这项技能列出了应用数据、操作、路由、上传以及外部请求的安全规则。适合修改登录、数据库访问、文件上传,或服务器对用户提供的网址发起调用的开发者。

适用场景

  • ✓当你修改登录、权限或数据库访问代码的时候。
  • ✓当应用接收外部用户的上传或内容的时候。
  • ✓当服务器将要获取用户提供的网址的时候。

技能链接

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/security/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/security/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请确保用户只能看到自己的笔记,并在保存上传内容之前进行检查。”

每周 5 个新技能,1 分钟读完。

工作原理

技能要求智能体检查每一个输入,使用参数化查询,并按调用者的访问权限过滤每一次读取和写入;无法确认权限时,一律拒绝访问。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Security

Rule

Treat each action, route, query, and external request as a trust boundary. Validate inputs, check the caller's authority for every row, and fail closed when access cannot be established.

Validate input and queries

  • Define action inputs with a Zod schema; validate data from forms, URLs, providers, and files before using it.
  • Build database queries with Drizzle. For raw SQL, bind values as parameters; never concatenate user input into SQL text.
  • Keep large uploads and file contents in file storage. Store only their returned ids or URLs in SQL.

Authorize rows and actions

Choose a table's access model when designing its data:

Data Access model
Private user rows Store owner_email and filter every read and write by the current caller.
Organization-wide catalog Store org_id and scope action queries to the active org; gate restricted mutations by org or app role.
Team-shared or individually shareable resources Use ownableColumns(), register the resource type, and check access with the sharing helpers.
Child rows Check access to the parent before reading or changing children; add any child-specific rules in the action.

Do not make a team-wide catalog private by adding a per-user owner filter. For an organization-owned catalog, org_id without owner_email is valid: scoped database tools expose only the active organization's rows, while app actions still need their own org filter and authorization. For resources users can share, use these helpers:

  • Add accessFilter(table, sharesTable) to list and read-many queries.
  • Use resolveAccess(type, id) for an optional read by id, or assertAccess(type, id, role) before a read or write that requires access.
  • Use an action's authorize gate for role-wide restrictions. It decides who may call the operation; it does not replace row-level access checks.

Prefer actions for normal app data. A custom HTTP route is appropriate for protocols such as uploads, streaming, webhooks, OAuth callbacks, or public unauthenticated resources. An authenticated custom route must establish the session/request context and apply the same row-level access checks as an action.

Handle untrusted content and URLs

  • React escapes rendered text. Do not pass untrusted content to dangerouslySetInnerHTML, innerHTML, eval, or document.write.
  • Use ssrfSafeFetch from @agent-native/core/extensions/url-safety for server-side requests to user- or agent-controlled URLs. It checks private network destinations and redirects.
  • Treat provider error bodies and uploaded files as untrusted input. Return a useful, bounded error to the user without exposing internal details.

Protect credentials and consequential actions

Never put credential values in source, prompts, action arguments or results, application state, client bundles, logs, or error messages. Use the shared credential flow in the secrets skill.

For a genuinely high-consequence outward action, such as sending a message, charging a payment method, or publishing publicly, use needsApproval to ask the user to approve that call. Approval does not grant access: keep the normal authorize and row-level checks as well.

Related skills

  • actions — define validated operations shared by the agent and UI.
  • secrets — connect external services and resolve credentials safely.
  • sharing — configure access to shareable resources.
常见问题

如果无法确认访问权限会怎样?

技能要求采用失败即关闭的策略,也就是拒绝该请求。

大型上传文件应存放在哪里?

存放在文件存储中,数据库中只保留返回的 ID 或网址。

原始 SQL 应如何处理用户输入?

值必须作为参数传递,绝不能拼接到 SQL 文本中。

详情

作者的原始描述

Secure app data, actions, routes, and external input. Use when changing authentication, authorization, database access, uploads, untrusted content, or server-side requests to user-provided URLs.

repo: BuilderIO/agent-native

热度

GitHub 星标
7.6k
排名
#13180
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能