Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

nextblock-security

БесплатноБез исполняемых скриптовНе проверен

NextBlock's security gate. Use before finishing ANY change that touches a migration, RLS policy, GRANT/REVOKE, Postgres function or trigger, the post-apply…

nextblock-cmsот nextblock-cms★ 20 звёзд на GitHub

Об этом скилле

NextBlock security gate

Every item below is a real hole that shipped at least once (2026-10-17 → 10-21). The automated gates catch most of them; the checklist covers what they cannot see. A change is not done until the gates pass and every checklist line that applies has been answered.

1. Run the gates

npm run security:check        # service-role boundary, migration lint, grant-pass lockstep (~5 s)
npx vitest run <paths you touched>

For a migration, a policy, a grant, or anything in GRANTS_SQL, also:

npm run db:migrate:check      # read-only; the new file must be listed as pending
# replay every migration into a disposable local database, then the posture gate:
SUPABASE_PROJECT_ID=nextblock-ci npx supabase start --workdir libs/db/src -x realtime,storage-api,imgproxy,kong,mailpit,postgrest,postgres-meta,studio,edge-runtime,logflare,vector,supavisor
npm run security:db-posture -- --db-url postgresql://postgres:[email protected]:54322/postgres
npx supabase stop --workdir libs/db/src --no-backup

security:db-posture runs the post-apply grant pass first (every deploy does) and fails on any FAIL or skipped assertion; it refuses non-local hosts. Never run it, or security-verify.sql, against production. CI (.github/workflows/security.yml) runs all of this on every push and PR, but run it before handing work back: CI only reports after the push.

A Stop hook (.Codex/settings.json → tools/scripts/Codex-security-stop-hook.mjs) runs security:check whenever a turn ends with code changes and sends you back if it fails. Fix the cause; never weaken a check, add an allowlist entry or a grandfather entry to make it pass without saying so to the user.

2. Checklist

Server actions and routes

  • Every exported function of a 'use server' file is a public POST endpoint, reachable from any route (proxy.ts only gates /cms URLs). It authenticates and authorizes itself BEFORE any read: requireCmsAdmin() / requireCmsStaff() (lib/auth/cms-actor.ts), requireEcomAdmin() / requireEcomStaff() (libs/ecommerce/.../require-ecom-role.ts), Cortex requireActorRole.
  • Never trust an id, price, role, owner or token from the client. Re-derive ownership on the server (order access tokens: order-access-token.ts; UCP carts: access_token_hash).
  • A payment provider's browser callback is attacker-controlled. Verify every id it names with the provider's API before storing it, and never let it set a product, plan or paid state (evaluateFreemiusCheckoutLicense: a guest could attach any license to their order and read its key). A page that reveals a secret (license key) re-checks that it belongs to the order.
  • A helper that returns the service-role client enforces the enrolled second factor, not just the role: server actions never pass the CMS layout's 2FA redirect. Use getCmsActor(); the ecommerce lib uses the gate the app registers (lib/auth/second-factor-gate.ts).
  • A route handler that mutates with cookies needs the same checks; cron routes check their secret with a timing-safe compare.

Service-role client (bypasses every RLS policy)

  • A module that builds, hands out or keys it imports 'server-only'; the key is read only by lib/setup/service-key.ts; import types from server modules with import type; no secret behind NEXT_PUBLIC_ or next.config.js env. Gate: service-role-boundary.test.ts.
  • Under the service role RLS is not a boundary: the in-code role check IS the authorization.

RLS policies

  • Every policy names its roles (TO authenticated …); one without TO also applies to anon.
  • No USING (true) / WITH CHECK (true) for anon/authenticated on a table holding users, orders, coupons, licenses, tokens, revisions, settings, 2FA, carts or messages.
  • An authorization column (profiles.role) is pinned by column grants first (02025), then WITH CHECK and a trigger. A self-service FOR UPDATE policy covers every granted column.
  • ADMIN branches on orders, profiles (other rows), site_settings secret tier and the commerce tables use is_admin_mfa() (aal2 when a factor is enrolled, 02023); CMS screens read those rows with the service role after the in-code check, never through the cookie client.
  • Draft/scheduled/archived rows and their children (media, stock, categories) stay staff-only.

Grants (decide whether a role may touch a table at all; RLS decides which rows)

  • New table: ENABLE ROW LEVEL SECURITY, GRANT SELECT … TO anon only if publicly readable, writes to authenticated, service_role only. anon holds no write grant anywhere (02025).
  • Any revoke from anon/authenticated that the blanket grants of GRANTS_SQL hand back goes into API_ROLE_REVOKE_SQL in BOTH apps/nextblock/tools/lib/migrate-core.mjs and apps/nextblock/lib/setup/schema-apply.ts, or the next deploy undoes it (02013 → 02024, 02022 → 02025). Gates: migration-grants.test.ts, migrate-core.test.mjs, the po
Полный SKILL.md на GitHub

Установить nextblock-security в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл nextblock-security?

NextBlock's security gate. Use before finishing ANY change that touches a migration, RLS policy, GRANT/REVOKE, Postgres function or trigger, the post-apply grant pass, auth/2FA/roles, a server action ('use server'), an API route handler, the service-role client, uploads or server-side fetches of user URLs, webhooks, checkout/pricing/coupons/orders, Cortex tools or the MCP server, rendered HTML, or anything a 'use client' component imports. Runs the automated gates and walks the checklist of every vulnerability class found in the 2026-10 red-team.

Как установить скилл nextblock-security?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл nextblock-security запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить nextblock-security с