Bkend Securityのロゴ

Bkend Security

組織
ww-w-ai
bkend-security

bkend.ai security policies and encryption expert skill. Covers API key management (Public vs Secret), Row Level Security (RLS) with 4 roles (admin/user/guest/self), data encryption (Argon2id, AES-256-GCM, TLS 1.2+), and security best practices. Triggers: security, RLS, api key, encryption, RBAC, permissions, 보안, API 키, 암호화, 권한, 역할, 접근제어, セキュリティ, APIキー, 暗号化, 権限, ロール, 安全, API密钥, 加密, 权限, 角色, seguridad, clave API, cifrado, permisos, roles, securite, cle API, chiffrement, permissions, roles, Sicherheit, API-Schluessel, Verschluesselung, Berechtigungen, sicurezza, chiave API, crittografia, permessi, ruoli Do NOT use for: authentication flows (use bkend-auth), database operations (use bkend-data), infrastructure security (use security-architect agent)

概要

公開者ww-w-ai
リポジトリbkit-gemini
スキル名bkend-security
スター
66
フォーク
16
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    ww-w-aiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Bkend Security」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/ww-w-ai/bkit-gemini/tree/main/skills/bkend-security
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ww-w-ai/bkit-gemini.git /tmp/bkit-gemini
mkdir -p .claude/skills
cp -r /tmp/bkit-gemini/skills/bkend-security .claude/skills/bkend-security
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでBkend Securityを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にBkend Securityを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Bkend Securityは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

bkend-security: Security Policies & Encryption Expert Skill

1. Multi-Layer Security Model

bkend.ai implements a defense-in-depth security architecture with multiple layers of protection. Each layer operates independently so that a breach in one layer does not compromise the entire system.

Request Flow:

  Client Request
       |
       v
  [ TLS 1.2+ ]              Layer 1: Transport encryption
       |
       v
  [ API Key Validation ]     Layer 2: Identify client type (Public/Secret)
       |
       v
  [ JWT Authentication ]     Layer 3: Verify user identity and session
       |
       v
  [ Row Level Security ]     Layer 4: Enforce data access policies per role
       |
       v
  [ AES-256-GCM ]           Layer 5: Data encrypted at rest
       |
       v
  [ Database ]               Secured data store

Layer Summary

LayerTechnologyPurposeApplied At
1TLS 1.2+Encrypt data in transitNetwork edge
2API KeysIdentify and authorize client appsAPI gateway
3JWTAuthenticate individual usersAuth middleware
4RLSEnforce row-level data accessQuery engine
5AES-256-GCMEncrypt data at restStorage layer

2. API Keys

2.1 Key Format

All bkend.ai API keys follow a consistent format:

ak_<64 hexadecimal characters>
  • Prefix: ak_ identifies the string as a bkend.ai API key
  • Body: 64 hex characters (256 bits of entropy)
  • Total length: 67 characters

2.2 Key Storage

API keys are stored as SHA-256 one-way hashes. The original key value is never stored on bkend.ai servers.

Original key:  ak_a1b2c3d4e5f6...   (shown once at creation)
Stored hash:   sha256(ak_a1b2...)  = 9f86d081884c7d659a2feaa...

Implications:

  • Lost keys cannot be recovered; a new key must be generated
  • Key validation compares the SHA-256 hash of the submitted key against the stored hash
  • Even if the database is compromised, original keys cannot be derived from the hashes

2.3 Key Types: Public vs Secret

bkend.ai provides two types of API keys with different security properties.

PropertyPublic KeySecret Key
ExposureSafe to expose in client-side codeMust never be exposed to clients
RLS EnforcementAlways enforcedBypasses RLS (full access)
Use CaseWeb apps, mobile apps, SPAsServer-side code, admin scripts, CI/CD
PermissionsLimited by RLS role of the userFull read/write access to all data
Rate Limit100 requests/minute1000 requests/minute
CORSRestricted to allowed domainsNot subject to CORS

2.4 Key Creation

API keys can only be created through the bkend.ai Console:

  1. Navigate to Project Settings > API Keys
  2. Click Create New Key
  3. Select key type: Public or Secret
  4. Optionally set an expiration date
  5. Click Generate
  6. Copy the key immediately -- it is displayed only once

Warning: After closing the creation dialog, the key value can never be retrieved again. Store it securely in your environment variables or secret manager.

2.5 Key Usage in Requests

Include the API key in the X-API-Key header:

http
GET /api/v1/tables/users/data
Host: api.bkend.ai
X-API-Key: ak_a1b2c3d4e5f6...
Authorization: Bearer <jwt_token>
  • Public Key requests must also include a valid JWT token (from user authentication)
  • Secret Key requests can optionally include a JWT token; without one, the request runs with full admin access

3. Row Level Security (RLS)

3.1 Overview

Row Level Security (RLS) controls which records a user can access based on their role. RLS policies are defined per table, per operation (read, create, update, delete) in the bkend.ai Console.

3.2 Four Roles

RoleDescriptionData AccessTypical Use
adminFull access to all dataAll records, all operationsAdmin dashboards, CMS
userAccess to own data via createdBy matchRecords where createdBy == userIdUser profiles, user content
guestAccess to public data onlyRecords where isPublic == truePublic pages, catalogs
selfAccess to own profile record onlySingle record where _id == userIdProfile viewing/editing

3.3 Role Resolution

The user's role is determined from the JWT token at request time:

JWT Payload:
{
  "sub": "user_abc123",
  "role": "user",
  "orgId": "org_xyz",
  "iat": 1700000000,
  "exp": 1700003600
}
  • The role field in the JWT determines which RLS policies are applied
  • If no JWT is provided (Secret Key only), the request operates as admin
  • Roles are assigned during user registration or by an admin via the Console

3.4 RLS Policy Configuration

RLS policies are configured per table in the bkend.ai Console:

  1. Navigate to Tables > select a table > Security tab
  2. For each operation (Read, Create, Update, Delete), configure access per role:

Example: posts Table

Operationadminuserguestself
ReadAllOwn + publicPublic onlyN/A
CreateAllOwn onlyDeniedN/A
UpdateAllOwn only (createdBy)DeniedN/A
DeleteAllOwn only (createdBy)DeniedN/A

Example: profiles Table

Operationadminuserguestself
ReadAllAllPublic onlyOwn only
CreateAllDeniedDeniedOwn only
UpdateAllDeniedDeniedOwn only
DeleteAllDeniedDeniedDenied

3.5 RLS Filter Injection

When RLS is active, the system automatically injects filter conditions into database queries:

User request:       GET /api/v1/tables/posts/data
User role:          user
User ID:            user_abc123

Injected filter:    { "createdBy": "user_abc123" }
Effective query:    db.posts.find({ ...userFilter, "createdBy": "user_abc123" })

This injection is transparent to the client and cannot be overridden.

3.6 RLS with Secret Key

When a request uses a Secret Key without a JWT token:

  • RLS is completely bypassed
  • The request has full admin-level access to all data
  • This is by design for server-side administration scripts

Important: Never use a Secret Key in client-side code. Use Public Key + JWT for all client-facing applications.


4. Data Encryption

4.1 At Rest

ComponentEncryption MethodKey Management
MongoDB AtlasAES-256 encryptionAWS KMS managed keys
S3 StorageServer-side encryptionAWS SSE-S3 managed keys
BackupsAES-256 encryptionSeparate backup encryption keys

All data stored in bkend.ai infrastructure is encrypted at rest using AES-256. Encryption keys are managed through AWS Key Management Service (KMS) and are rotated automatically.

4.2 In Transit

PropertyValue
Minimum TLS VersionTLS 1.2
Preferred TLS VersionTLS 1.3
HSTSEnabled (max-age=31536000)
Certificate AuthorityLet's Encrypt / AWS ACM
Cipher SuitesModern suites only (no RC4, 3DES, SHA-1)

All API communication is encrypted with TLS 1.2 or higher. HTTP requests are automatically redirected to HTTPS. HSTS headers ensure browsers always use HTTPS.

4.3 Password Hashing

User passwords are hashed using Argon2id, the winner of the Password Hashing Competition and recommended by OWASP.

ParameterValueRationale
AlgorithmArgon2idHybrid resistance to side-channel and GPU attacks
Memory Cost64 MiBHigh memory usage deters GPU cracking
Iterations3Balanced computation time
Parallelism4 threadsUtilizes multi-core CPUs
Salt Length16 bytesUnique per password
Hash Length32 bytes256-bit output

Why Argon2id:

  • Memory-hard: requires significant RAM, making GPU/ASIC attacks expensive
  • Hybrid variant: combines Argon2i (side-channel resistance) and Argon2d (GPU resistance)
  • Configurable parameters allow tuning for the target hardware

4.4 API Key Hashing

API keys are hashed using SHA-256 one-way hash:

Input:  ak_a1b2c3d4e5f6...  (67 characters)
Output: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
  • One-way: the original key cannot be derived from the hash
  • Deterministic: the same key always produces the same hash (for validation)
  • Fast: efficient for per-request validation

5. Environment Security

5.1 Separate Keys per Environment

Each environment (dev, staging, prod) has its own set of API keys:

Project: my-app
├── dev
│   ├── Public Key:  ak_dev_...
│   └── Secret Key:  ak_dev_secret_...
├── staging
│   ├── Public Key:  ak_staging_...
│   └── Secret Key:  ak_staging_secret_...
└── prod
    ├── Public Key:  ak_prod_...
    └── Secret Key:  ak_prod_secret_...

Keys from one environment cannot access data in another environment. This prevents accidental data leaks between environments.

5.2 Environment Variable Management

Store API keys and sensitive configuration in environment variables, never in source code:

bash
# .env.development
BKEND_API_URL=https://api-client.bkend.ai
BKEND_PUBLIC_KEY=ak_dev_...
BKEND_SECRET_KEY=ak_dev_secret_...

# .env.production
BKEND_API_URL=https://api-client.bkend.ai
BKEND_PUBLIC_KEY=ak_prod_...
BKEND_SECRET_KEY=ak_prod_secret_...

Rules:

  • Add .env* to .gitignore to prevent committing secrets (Note: In Gemini CLI v0.36.0+, .gitignore is write-protected by sandbox governance. Add entries manually.)
  • Use a secret manager (AWS Secrets Manager, Vault, etc.) for production deployments
  • Never log environment variables containing keys or tokens

5.3 Domain Allowlist for CORS

Configure allowed domains per environment to prevent unauthorized cross-origin requests:

dev:      http://localhost:3000, http://localhost:5173
staging:  https://staging.myapp.com
prod:     https://myapp.com, https://www.myapp.com
  • Only Public Key requests are subject to CORS restrictions
  • Secret Key requests bypass CORS (server-to-server only)
  • Wildcard domains (*.myapp.com) are supported but not recommended for production

6. Security Best Practices

1. Never Expose Secret Key in Client Code

The Secret Key bypasses all RLS policies and grants full admin access. It must only be used in server-side code.

WRONG:
  <script>
    const API_KEY = "ak_secret_...";  // Visible to anyone inspecting the page
  </script>

RIGHT:
  // Server-side only (Node.js, Python, etc.)
  const API_KEY = process.env.BKEND_SECRET_KEY;

2. Use httpOnly Cookies for Token Storage

Store JWT tokens in httpOnly cookies to prevent XSS attacks from accessing them:

http
Set-Cookie: token=eyJhbGc...; HttpOnly; Secure; SameSite=Strict; Path=/
  • HttpOnly: prevents JavaScript access to the cookie
  • Secure: cookie is only sent over HTTPS
  • SameSite=Strict: prevents CSRF attacks

Avoid: storing tokens in localStorage or sessionStorage where they are accessible to JavaScript.

3. Enable MFA for Admin Accounts

Multi-Factor Authentication adds a second verification step for admin users:

  1. Navigate to Organization Settings > Security
  2. Enable Require MFA for admins
  3. Admin users will be prompted to set up TOTP (authenticator app) on next login

4. Set Appropriate RLS Policies per Table

Review and configure RLS policies for every table:

  • Use the principle of least privilege
  • Default to denied and explicitly grant access
  • Test policies by impersonating different roles in the Console

5. Rotate API Keys Periodically

Regular key rotation limits the impact of a compromised key:

  • Recommended rotation: every 90 days for production keys
  • Process: create a new key, update all consumers, then revoke the old key
  • Zero-downtime: maintain two active keys during the transition period

6. Use Environment-Specific Keys

Never share keys across environments:

  • Development keys should only access development data
  • Production keys should be stored in a secret manager
  • Staging keys should use production-like security but with test data

7. Validate All User Input Server-Side

Never trust client-side validation alone:

  • Validate data types, lengths, and formats on the server
  • Use bkend.ai field-level validation rules (min, max, pattern, required)
  • Sanitize user input to prevent injection attacks

8. Use HTTPS-Only for All API Calls

All bkend.ai API endpoints enforce HTTPS:

  • HTTP requests are automatically redirected to HTTPS (301)
  • HSTS headers prevent downgrade attacks
  • Ensure your application code always uses https:// URLs
  • Configure your CDN/proxy to enforce HTTPS at the edge

Quick Reference Card

API Key Header

http
X-API-Key: ak_<64 hex characters>

RLS Role Summary

RoleAccess LevelKey Requirement
adminAll recordsSecret Key or JWT
userOwn records (createdBy)Public Key + JWT
guestPublic records onlyPublic Key
selfOwn profile onlyPublic Key + JWT

Encryption Summary

Data TypeAlgorithmKey Size
Data at restAES-256-GCM256-bit
Data in transitTLS 1.2+256-bit
PasswordsArgon2id256-bit
API keysSHA-256256-bit

Security Checklist

  • Secret Key stored in environment variables only
  • JWT tokens stored in httpOnly cookies
  • MFA enabled for admin accounts
  • RLS policies configured for all tables
  • API keys rotated within the last 90 days
  • Environment-specific keys in use
  • Server-side input validation enabled
  • All API calls use HTTPS

よくある質問

AIスキル「Bkend Security」では何ができますか?

bkend.ai security policies and encryption expert skill. Covers API key management (Public vs Secret), Row Level Security (RLS) with 4 roles (admin/user/guest/self), data encryption (Argon2id, AES-256-GCM, TLS 1.2+), and security best practices. Triggers: security, RLS, api key, encryption, RBAC, permissions, 보안, API 키, 암호화, 권한, 역할, 접근제어, セキュリティ, APIキー, 暗号化, 権限, ロール, 安全, API密钥, 加密, 权限, 角色, seguridad, clave API, cifrado, permisos, roles, securite, cle API, chiffrement, permissions, roles, Sicherheit, API-Schluessel, Verschluesselung, Berechtigungen, sicurezza, chiave API, crittografia, permes...

TypingMindでBkend Securityを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Bkend Securityはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにBkend Securityをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/ww-w-ai/bkit-gemini/tree/main/skills/bkend-securityを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Bkend Securityを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Bkend Securityで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもBkend Securityを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Bkend Security」は無料ですか?

はい。ww-w-aiがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇