data-isolation-and-lifecycle
БесплатноБез исполняемых скриптовНе проверенUse when the diff stores, caches, indexes, exports, imports, migrates, soft-deletes or revokes access-controlled or multi-tenant data - policy vs query…
от makifbaysal★ 123 звезды на GitHubОб этом скилле
Data Isolation and Lifecycle
Overview
Endpoint checks protect one door. Data has many copies — a cache entry, a search document, a thumbnail, an export file, a log line, a backup, a queued job — and each copy has its own reader and its own retention. Isolation fails where a copy forgets who owns the data, or where a deleted or revoked record keeps working.
Core principle: pick one protected record the diff touches and follow it through every write, read, copy and state change. At each edge, name the code that enforces its owner. A tenant column is not that code.
1. A Tenant Field Is Not Isolation (CWE-639, CWE-863)
The owner column exists; the question is which query, policy or key enforces it on this path.
- Bypass clients: Supabase's service-role key or a Postgres role with
BYPASSRLSused in a request handler; a "system" repository that skips the tenant filter, called from a user-facing path. - Unscoped escapes: GORM
Unscoped()(it also drops the soft-delete filter), Railsunscoped, a Django manager that is not the filtered default, Hibernate filters that do not apply to native queries, Prisma middleware that a raw query skips. - Policy and query disagree: row-level security on the table but the new view, function (
SECURITY DEFINER), materialized view or aggregate reads around it; a join that brings in rows of another tenant through an unscoped relation.
-- ❌ SECURITY DEFINER runs as the function's owner; a table owner bypasses RLS
-- (unless FORCE ROW LEVEL SECURITY is set), so the caller's policy never applies
CREATE FUNCTION project_stats(p uuid) RETURNS TABLE(...) LANGUAGE sql SECURITY DEFINER
AS $$ SELECT ... FROM tasks WHERE project_id = p $$;
-- ✅ SECURITY INVOKER (the default), or filter on the caller's tenant inside the function
2. Keys and Namespaces Without the Tenant
Two principals collide on one logical key even though their records have separate owners:
- cache keys built from a user-chosen name (
report:+ name) or from an id that is only unique per tenant; - object-storage keys from the uploaded filename (
uploads/avatar.png) — one tenant overwrites or reads another's; - search document ids, deduplication keys, idempotency keys and lock names without the tenant;
- globally unique constraints that let one tenant squat or probe another tenant's slug, email or domain.
// ❌ every org shares one key space
key := fmt.Sprintf("dashboard:%s", req.Name)
// ✅
key := fmt.Sprintf("org:%s:dashboard:%s", auth.OrgID(ctx), req.Name)
3. Signed URLs and Shared Links
- A presigned URL that allows more than the issuer could do:
PUTwhereGETwas meant, a key prefix instead of one object, a content type the client chooses, a week of validity for a one-time download. - A share token that unlocks a folder when it was issued for one file, or keeps working after the item was unshared or its ACL changed.
- A link id that is the object id, so any authenticated user with the id gets the object (access-control-and-idor).
4. Derived Copies That Forget the ACL
- Search and vector indexes: the filter is applied at ingestion but not at query time, or permission changes never reach the index (llm-and-agent-security §6 for embeddings and context caches).
- Caches: a private response cached under a key without the user; an ACL change that does not invalidate the cached decision or object.
- Previews and thumbnails: generated into a public bucket or behind a guessable path while the original is private.
- Logs, traces, analytics, crash reports: private content or credentials sent to a store with a broader audience or tenant mixing (secrets-and-crypto-review for the credential case).
- Notifications and emails: a digest built from the list of everything, not the list the recipient may see.
5. Export, Backup, Import, Restore
- Export scope: each item is authorized after selection, not only the request; deleted, draft and private fields are excluded; the download of the finished file is authorized again (the export id is not a bearer token).
- Import and restore: archive contents are untrusted input. Owner ids, roles, statuses and foreign keys from the file are rewritten to the importer's scope; an import that can overwrite existing records checks write access to each one.
- Restore and undo: restoring a snapshot can bring back a removed membership, a revoked key or a permission that current policy no longer allows — re-authorize restored state.
6. Migrations and Backfills
-- ❌ the new column makes every existing document public
ALTER TABLE documents ADD COLUMN is_public boolean NOT NULL DEFAULT true;
-- ✅ existing rows keep their current exposure; new rows opt in
ALTER TABLE documents ADD COLUMN is_public boolean NOT NULL DEFAULT false;
Also: a backfill that assigns orphaned rows to a default organization; a nullable new tenant_id read with OR tenant_id IS NULL (every tenant sees the le
Установить data-isolation-and-lifecycle в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл data-isolation-and-lifecycle?
Use when the diff stores, caches, indexes, exports, imports, migrates, soft-deletes or revokes access-controlled or multi-tenant data - policy vs query disagreement, bypass clients, tenant-less cache and object keys, signed links, derived copies (search, cache, logs, analytics), export/restore scope, migration defaults, and stale access after delete or revoke
Как установить скилл data-isolation-and-lifecycle?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл data-isolation-and-lifecycle запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic