agent-security-hardening
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
Race condition / TOCTOU playbook — limit overrun (one-time codes used twice, gift cards spent twice), single-packet attack (last-byte sync) to force parallel processing, and state-confusion races (file upload + read, order before payment). Use when timing-sensitive logic could be abused — one-time codes, coupons/gift cards, balance or limit checks, double-spend.
Confirm the target is in scope for stress-style testing (multiple parallel requests can look like abuse). Then identify the candidate operation.
Execution rule: capture a real request for the operation and replay that request with concrete cookies/body values. Never write literal placeholders such as <sess> to files; ask once if a session or replayable request is missing.
safe.png, then race a swap to evil.svg before AV scans)Modern servers buffer HTTP/2 frames. The classic trick: send N requests where each is fully serialized except the last byte. Then in a single TCP write, flush the final byte of all N. The server receives them effectively simultaneously and dispatches them in parallel — bypassing nearly all software-side rate limiting.
You can do this with a small Go/Python script. Skeleton (Python, HTTP/2):
import asyncio, ssl
import httpx
async def main():
transport = httpx.AsyncHTTPTransport(http2=True)
async with httpx.AsyncClient(transport=transport, verify=False) as c:
# Build N partial requests, then race the last byte.
# In practice: use turbo-intruder or a Go h2 client for byte-level control.
...
asyncio.run(main())
For the highest-fidelity version, use Burp Suite's Turbo Intruder (race-single-packet-attack.py template) — it's the de facto tool. The shell tool can run it if installed.
If HTTP/2 isn't available, fire N requests over a single keep-alive connection back-to-back without waiting for responses:
# 50 parallel uses of the same coupon code
seq 50 | xargs -P 50 -I{} curl -s -X POST https://target/redeem \
-H 'Cookie: session=<sess>' \
-d 'code=GIFT100'
Less reliable than single-packet but often enough.
For each candidate operation, measure the invariant twice:
If invariant differs by more than 1× the per-request delta, you have a race. Example: gift card worth $50, used 5× before lockout → $250 credit. Confirmed.
Time-Of-Check / Time-Of-Use bugs:
If you see any of these, the race probably isn't winnable — refocus:
SELECT ... FOR UPDATE / explicit row lock.version field that's CAS'd.UNIQUE (user_id, code_id) constraint with ON CONFLICT DO NOTHING.Required for a credible finding:
N=50, mean=20ms apart).A race with no measurable impact (e.g., creates a second pending order that the next cron job dedupes) is info at best.
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
DIDietrichGebert/ponytail162k5,405 new stars in the last 7 days
DIDietrichGebert/ponytail162k5,405 new stars in the last 7 days
DIDietrichGebert/ponytail162k5,405 new stars in the last 7 days
GAgarrytan/gstack136k883 new stars in the last 7 days
Harden code against the OWASP Top 10: input handling, authentication, sessions and dependencies.
ADaddyosmani/agent-skills106k3,628 new stars in the last 7 days