Logo: Sh Kb Race Conditions

Sh Kb Race Conditions

Communautéit
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.

Iwwersiicht

Editeurdmdhrumilmistry
Repositorysecurity-harness
Skill-Nummsh-kb-race-conditions
Stären
42
Forks
11
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    dmdhrumilmistry huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Sh Kb Race Conditions an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/dmdhrumilmistry/security-harness/tree/main/plugins/security-harness/skills/sh-kb-race-conditions
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Sh Kb Race Conditions an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Sh Kb Race Conditions automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Sh Kb Race Conditions net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Sh Kb Race Conditions op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Sh Kb Race Conditions besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Sh Kb Race Conditions an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/dmdhrumilmistry/security-harness/tree/main/plugins/security-harness/skills/sh-kb-race-conditions an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Sh Kb Race Conditions benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Sh Kb Race Conditions benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Sh Kb Race Conditions domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Sh Kb Race Conditions gratis?

Jo. dmdhrumilmistry huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇