Sh Kb Race Conditions logo

Sh Kb Race Conditions

Community
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.

Overview

Publisherdmdhrumilmistry
Repositorysecurity-harness
Skill namesh-kb-race-conditions
Stars
42
Forks
11
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dmdhrumilmistry on GitHub. Read the source before you install it.

Installation

Install the Sh Kb Race Conditions AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dmdhrumilmistry/security-harness/tree/main/plugins/security-harness/skills/sh-kb-race-conditions
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sh Kb Race Conditions in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sh Kb Race Conditions on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sh Kb Race Conditions is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Frequently asked questions

What does the Sh Kb Race Conditions AI skill do?

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.

Why use Sh Kb Race Conditions on TypingMind?

Because you install it once and use it with any model. Sh Kb Race Conditions is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sh Kb Race Conditions in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dmdhrumilmistry/security-harness/tree/main/plugins/security-harness/skills/sh-kb-race-conditions. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Sh Kb Race Conditions?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sh Kb Race Conditions?

As many as you like. As long as a model supports skills, you can use Sh Kb Race Conditions with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sh Kb Race Conditions AI skill free?

Yes. It is published on GitHub by dmdhrumilmistry under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇