Sh Kb Race Conditionsのロゴ

Sh Kb Race Conditions

コミュニティ
dmdhrumilmistry
sh-kb-race-conditions

Knowledge base for finding race conditions and TOCTOU flaws - concurrent requests exploiting non-atomic check-then-act logic (double-spend, limit bypass, balance manipulation, file TOCTOU). Use when hunting concurrency/business-logic race bugs. CWE-362/367/366, OWASP A04:2021-Insecure Design.

概要

公開者dmdhrumilmistry
リポジトリsecurity-harness
スキル名sh-kb-race-conditions
スター
42
フォーク
11
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

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

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dmdhrumilmistry/security-harness.git /tmp/security-harness
mkdir -p .claude/skills
cp -r /tmp/security-harness/plugins/security-harness/skills/sh-kb-race-conditions .claude/skills/sh-kb-race-conditions
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Race Conditions & TOCTOU - Hunter Knowledge Base

A gap between checking a condition and acting on it lets concurrent requests slip through: spend a coupon twice, withdraw more than the balance, bypass a rate/quota limit, or swap a file between check and use. These are logic bugs - reason about interleavings, not just about a dangerous sink.

Classic patterns to hunt

  • Check-then-act on shared state without a lock/transaction/atomic op: read balance -> if enough -> subtract; check "coupon unused" -> mark used; check "invite not redeemed" -> redeem.
  • Limit/quota bypass: "only once" / "max N" enforced by a non-atomic read+increment; parallel requests all pass the check before any writes.
  • Financial double-spend: withdraw/transfer/refund without row locking or a DB constraint.
  • TOCTOU on filesystem (CWE-367): os.path.exists/access() then open(); symlink swapped in between.
  • Idempotency gaps: ret/replay of a request causes duplicate side effects (no idempotency key).
  • Auth/session races: token validated then state changes; concurrent login/session mutation.

Sinks / patterns (grep targets)

Non-atomic sequences: a SELECT/read followed by an UPDATE/write of the same field without a transaction, SELECT ... FOR UPDATE, optimistic-lock version, or atomic DB op. Grep near money/credits/quota/inventory: balance|credit|quota|limit|coupon|voucher|stock|inventory|redeem|withdraw|transfer. Filesystem: os.path.exists|access\(|stat\( shortly before open(. Look for absence of with transaction, SELECT FOR UPDATE, lock, Mutex, atomic, unique constraints.

Detection recipe

  1. Identify state-changing operations on shared/limited resources from codebase-map.json.
  2. For each, read the handler: is the check-and-act atomic? (single UPDATE with a WHERE guard, DB constraint, row lock, or app-level lock?) If it's read-then-write across statements with no lock, flag.
  3. Note whether the endpoint is reachable concurrently (most HTTP handlers are).

PoC / evidence

  • Describe the interleaving: "N parallel POST /redeem requests, all read used=false before any writes used=true, so all N succeed." Show the non-atomic code path.
  • Practical PoC: fire many concurrent identical requests (e.g. 20-50 in parallel) and observe the invariant broken (balance negative, coupon used twice). Often needs-runtime to fully confirm.
  • Tightening the race window: naive parallel requests over separate TCP connections suffer network jitter that can hide a narrow window. Over HTTP/2, a "single-packet attack" (send 20-30 request streams in one TCP packet so the server receives them effectively simultaneously) removes that jitter; over HTTP/1.1 a "last-byte sync" (send all but the final byte of each request, then release the final bytes together) achieves the same effect. Tools: Burp Repeater's parallel "group" send, or Turbo Intruder (engine=Engine.BURP2, concurrentConnections=1). When racing multiple different endpoints (e.g. check-balance vs. spend), pre-warm each connection with a throwaway request first so backend processing times align, since cross-endpoint timing skew is a common reason an otherwise-real race fails to trigger.

False-positive filters

  • The critical section is atomic: single UPDATE ... SET x=x-1 WHERE x>0 (check in the WHERE), DB unique constraint / SELECT ... FOR UPDATE, optimistic locking (version column), INSERT ... ON CONFLICT, or an explicit lock/mutex/serializable transaction covering check+act.
  • The resource isn't shared across requests, or the operation is naturally idempotent.
  • A single-writer queue / actor serializes the operation.

CWE / OWASP / severity

CWE-362 (race), CWE-367 (TOCTOU), CWE-366. OWASP A04:2021 (Insecure Design). Financial/limit bypass -> high/critical by value; filesystem TOCTOU -> high if it leads to privilege gain.

Chaining hints

Race to bypass a spend/limit -> monetary loss; combine with access-control (race a permission change); TOCTOU file swap -> path-traversal/privilege escalation. Often amplifies an otherwise-bounded feature.

Mitigation

Make check-and-act atomic: guard in the UPDATE WHERE, use DB constraints/unique indexes, row locking (SELECT ... FOR UPDATE) or optimistic locking, serializable transactions, idempotency keys for retried mutations, and atomic counters for quotas. Avoid exists-then-open; open directly and handle errors.

よくある質問

AIスキル「Sh Kb Race Conditions」では何ができますか?

Knowledge base for finding race conditions and TOCTOU flaws - concurrent requests exploiting non-atomic check-then-act logic (double-spend, limit bypass, balance manipulation, file TOCTOU). Use when hunting concurrency/business-logic race bugs. CWE-362/367/366, OWASP A04:2021-Insecure Design.

TypingMindでSh Kb Race Conditionsを使うメリットは何ですか?

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

TypingMindにSh Kb Race Conditionsをインストールするにはどうすればよいですか?

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

Sh Kb Race Conditionsを使えるAIモデルはどれですか?

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

Sh Kb Race Conditionsで使えるAIモデルの数に制限はありますか?

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

AIスキル「Sh Kb Race Conditions」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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