# Trivial C# Random Exploitation

C# Random() seeded by TickCount generated password reset tokens; two requests in same millisecond yield identical tokens, enabling account takeover.

- Payout: Research
- Severity: critical
- Program: C# Random
- Credited: Doyensec
- Disclosed: 2025-08-18
- Write-up quality: 8/10
- Original: https://blog.doyensec.com/2025/08/19/trivial-exploit-on-C-random.html
- Library page: https://bugbountylibrary.com/r/blog%3Ablog-doyensec-com-2025-08-19-trivial-exploit-on-c-random-html
- Tags: domain:web impact:ato kind:research platform:research sev:critical tech:dotnet technique:race-window technique:source-review vuln:account-takeover vuln:crypto

**Target:** HTTP/2 web service password reset endpoint
**Root cause:** Password reset tokens generated using new Random().Next(min,max) without a cryptographic seed; default seed is Environment.TickCount with 1ms resolution, so requests in the same millisecond produce identical tokens.
**Steps:**
1. Create two test accounts on the target.
2. Use Burp Repeater groups to send password reset requests for both accounts in a single packet (HTTP/2 single packet attack).
3. Check email for duplicate reset tokens; repeat until round-trip time difference ≤1ms.
4. Once duplicate tokens observed, send reset requests for attacker account and victim account in same 1ms window.
5. Use the token received for attacker account to reset victim account password.
**How found:** Observed password reset tokens generated from custom encoding of Random().Next(min,max). Recognized default seed is Environment.TickCount with 1ms resolution. Hypothesized that simultaneous requests could yield identical tokens. Verified with two test accounts using Burp single packet attack, monitoring round-trip time differences.
**Exploitation:** Attacker sends simultaneous password reset requests for their own account and victim's account using HTTP/2 single packet attack. If both requests hit the same TickCount millisecond, identical tokens are generated. Attacker receives their token via email and uses it to reset victim's password, achieving account takeover.
**Insight:** When testing password reset or token generation, check if tokens are time-seeded PRNG outputs. Use HTTP/2 single packet attack to send simultaneous requests and compare tokens; a 1ms window can cause collisions. Test with two controlled accounts first to avoid false positives from database race conditions.
