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.
1---2name: security3description: >-4 Secure app data, actions, routes, and external input. Use when changing5 authentication, authorization, database access, uploads, untrusted content,6 or server-side requests to user-provided URLs.7scope: dev8metadata:9 source: https://skillmd.com/skills/builderio/security10---1112# Security1314## Rule1516Treat each action, route, query, and external request as a trust boundary.17Validate inputs, check the caller's authority for every row, and fail closed18when access cannot be established.1920## Validate input and queries2122- Define action inputs with a Zod `schema`; validate data from forms, URLs,23 providers, and files before using it.24- Build database queries with Drizzle. For raw SQL, bind values as parameters;25 never concatenate user input into SQL text.26- Keep large uploads and file contents in file storage. Store only their27 returned ids or URLs in SQL.2829## Authorize rows and actions3031Choose a table's access model when designing its data:3233| Data | Access model |34| --- | --- |35| Private user rows | Store `owner_email` and filter every read and write by the current caller. |36| Organization-wide catalog | Store `org_id` and scope action queries to the active org; gate restricted mutations by org or app role. |37| Team-shared or individually shareable resources | Use `ownableColumns()`, register the resource type, and check access with the sharing helpers. |38| Child rows | Check access to the parent before reading or changing children; add any child-specific rules in the action. |3940Do not make a team-wide catalog private by adding a per-user owner filter. For41an organization-owned catalog, `org_id` without `owner_email` is valid: scoped42database tools expose only the active organization's rows, while app actions43still need their own org filter and authorization. For resources users can44share, use these helpers:4546- Add `accessFilter(table, sharesTable)` to list and read-many queries.47- Use `resolveAccess(type, id)` for an optional read by id, or48 `assertAccess(type, id, role)` before a read or write that requires access.49- Use an action's `authorize` gate for role-wide restrictions. It decides who50 may call the operation; it does not replace row-level access checks.5152Prefer actions for normal app data. A custom HTTP route is appropriate for53protocols such as uploads, streaming, webhooks, OAuth callbacks, or public54unauthenticated resources. An authenticated custom route must establish the55session/request context and apply the same row-level access checks as an action.5657## Handle untrusted content and URLs5859- React escapes rendered text. Do not pass untrusted content to60 `dangerouslySetInnerHTML`, `innerHTML`, `eval`, or `document.write`.61- Use `ssrfSafeFetch` from `@agent-native/core/extensions/url-safety` for62 server-side requests to user- or agent-controlled URLs. It checks private63 network destinations and redirects.64- Treat provider error bodies and uploaded files as untrusted input. Return a65 useful, bounded error to the user without exposing internal details.6667## Protect credentials and consequential actions6869Never put credential values in source, prompts, action arguments or results,70application state, client bundles, logs, or error messages. Use the shared71credential flow in the `secrets` skill.7273For a genuinely high-consequence outward action, such as sending a message,74charging a payment method, or publishing publicly, use `needsApproval` to ask75the user to approve that call. Approval does not grant access: keep the normal76`authorize` and row-level checks as well.7778## Related skills7980- `actions` — define validated operations shared by the agent and UI.81- `secrets` — connect external services and resolve credentials safely.82- `sharing` — configure access to shareable resources.