Skip to content

02 · Foundations

Identifying IDOR Candidates

14 min readIDOR Hunting

Once you’ve mapped endpoints, your job is to identify which request parameters look like object references. Train your eye to spot identifiers wherever they’re hiding, they aren’t always called id.

Location Examples Notes
URL path /users/42/profile Most obvious
Query string ?orderId=9011 Easy to enumerate
Request body {"target_user": 42} Often missed
Custom header X-Account-Id: 42 SaaS multi-tenant clue
JWT claim "sub": 42, "tenant": 7 Decode and mutate
Cookie userid=42; tenant=7 Surprisingly common
Filename / S3 key /uploads/2024/u42/file.pdf Direct file IDOR
GraphQL variable { user(id: 42) { email } } Section 05
WebSocket message {"action":"subscribe","resource":42} Section 06
Nested JSON {"user":{"id":883}} The ID is inside an object, not a scalar
Buried in a file URL /files/avatars/1042/photo.jpg The path is the reference
Not a number me, alice, ABB-2024-0043 Usernames, order codes, booking refs

Tutorials say “look for ?id=.” That advice is ten years out of date. The same reference shows up under a costume. Swap the value, not the name you expected.

What it looks like What it often is
?id=123 user_id, uid, account, doc, file, ref, record
A bare number A UUID, or a number wearing a UUID’s clothes after you decode it
550e8400-e29b-41d4-a716-446655440000 Read the version nibble before you walk away. Details below.
/invoice/iW9n2mXqP4kL A hash or a hash prefix. Where it came from matters less than whether a second one, from your other account, swaps in.
A blob base64, base62, rot13, or a custom alphabet. ABB-2024-0043 is a structured code with a counter in it.
A JSON body A whole object: {"user":{"id":883}}. Edit the inner field.
A pretty URL /files/avatars/1042/photo.jpg
GraphQL query { user(id: 1042) { ssn } }. Section 05, including node(id:).
No digit at all A username, an order code, a booking reference, or the literal keyword me
An attribute you can type Email, phone, username, domain. The next subsection.

You do not need an id. The app resolves an object from a value you can type, and the uniqueness check is missing or raceable. Run every one of these against two accounts you own. Do not squat a real handle, and do not join a real tenant.

  • Email. POST /api/invite {"email":"b@example.com"}, POST /api/transfer {"to":"b@example.com"}, PATCH /api/users/me {"email":"b@example.com"}. If the app binds the address before it verifies ownership of the inbox, you merge the accounts or take one over.
  • Username or slug. PUT /api/profile {"username":"victim"}. If the old row is not released, every reference to that handle now points at you.
  • Phone, both directions. POST /api/verify {"phone":"<theirs>","userId":"<yours>"} sends the code to the phone and binds whichever userId you supply. The inverse is a read: POST /api/orders {"phone":"<theirs>"} returns their order history. The binding case is also in section 06. Prove both on numbers you control.
  • Domain auto-join. POST /api/orgs {"domain":"victim.example"}. If anyone whose email is on that domain is dropped into the tenant, you are in the company.
  • Invitation tokens. POST /api/invites/{token}/accept. If the token is not bound to the invited email, anyone with the link joins. If it is bound, change the email in the body and see whether the binding is enforced.
  • Merge. POST /api/merge {"source":"b@example.com"}. “Merge my accounts” is a write. A lot of them only check that a session exists.

The format of the identifier shapes how you attack it. The column that matters most is “predictable portion”, the part an attacker doesn’t have to guess. Ordered roughly from easiest to hardest:

Format Example Predictable portion & attack
Sequential int 1, 2, 3, … 9847 100%. Enumerate freely. Intruder Numbers or Turbo Intruder. Highest visible ID also leaks total record count.
Base64 int / JSON SW52b2ljZToxMDQy 0 bits of security, reversible encoding, not encryption. Decode, enumerate, re-encode (see below).
Hashids / Sqids NkK9dwLl2 Reversible obfuscation, not a hash. Leaked salt+alphabet ⇒ decode every ID. See the callout below.
MongoDB ObjectID 507f191e810c19729de860ea Only ~24 bits truly vary per process. One known same-process ID collapses the rest. Deep-dive below.
UUIDv1 (time+MAC) 6ba7b810-9dad-11d1-… Timestamp + constant MAC/clock_seq. The sandwich attack brute-forces the timestamp window. Deep-dive below.
Snowflake (Twitter/Discord) 175928847299117063 ms timestamp + small worker/sequence bits. Public decoders exist; narrow to a few thousand candidates in a time window.
UUIDv7 / ULID / KSUID 018f7a1c-3e4b-7d21-… 48-bit ms timestamp is non-secret. The random tail blocks a full walk. Rows created milliseconds apart sit in a small lexicographic band. Never use one as a secret token.
Hash-shaped (MD5/SHA-1) 5d41402abc4b2a76… Often md5(user_id) or md5(email). Hash your own known values; try common inputs.
Slug / username /u/alice-johnson Enumerate from OSINT, comments, mentions, member lists, @-handles.
base62 / custom alphabet iW9n2mXq Decode, increment, re-encode. Often a truncated MD5/SHA of a sequential int.
Structured code PO-2024-00451, CLM-88213, A9F3K2 Collect 20. Read length, charset, and where the counter sits. A9F3K2 may be base36 of an int.
UUIDv4 / nanoid / Stripe f47ac10b-58cc-4372-… 119-126 random bits when the generator is real. Collect a sample first: mt_rand and truncated hashes collapse. Otherwise hunt for leaks.

A hunter sees 7f3a9c1e-d29b-4b8a and mutters “GUIDs, moving on.” That is wrong about half the time. Encoding is a costume. Take it off: decode, increment, re-encode, send.

base64, base62, rot13, and the other costumes

Section titled “base64, base62, rot13, and the other costumes”

Decode, increment, re-encode (SHELL)

/api/v1/documents/WzEwNDJd
echo 'WzEwNDJd' | base64 -d # [1042]
echo -n '[1043]' | base64 # WzEwNDNd
# paste WzEwNDNd back into the path
# rot13 on an alphabetic token
python -c "import codecs; print(codecs.encode('token', 'rot13'))"

echo '[1043]' without -n base64s a trailing newline and will not match the app. Use -n.

base62 and base36 (PYTHON)

def b62_decode(s, alphabet="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"):
n = 0
for c in s:
n = n * 62 + alphabet.index(c)
return n
# If index() throws, the app used the other convention (a-z before A-Z).
print(int("A9F3K2", 36)) # base36 of a normal int. A blog post about "obfuscation" did not save them.

Crockford base32 drops I, L, O, and U. If the alphabet looks like that, decode it as Crockford, not as RFC 4648.

The version is one hex digit: the high nibble of the third group.

Where the version lives (UUID)

550e8400-e29b-41d4-a716-446655440000
^
# 1 = v1, 4 = v4, 7 = v7. The example above is v4.
  • v1 is a timestamp plus the MAC of the generating machine, plus a clock sequence. From one sample you can recover creation time, line records up in creation order, and enumerate objects created near yours. Every v1 from the same host shares a MAC prefix, which is also an infrastructure tell: those rows came from one machine. guidtool and sandwich do the prediction.
  • v4 is random. Respect a real cryptographically secure random number generator (CSPRNG). Do not respect the label. Collect about 50. Some “UUID” helpers are mt_rand or a truncated hash with a weak seed, and those collapse. If the sample looks uniform, stop guessing and go find a leak.
  • v7 is the one spreading through new codebases (RFC 9562). The high bits are a Unix millisecond timestamp, then randomness. It is not an incrementing counter. It is sortable. Two rows created milliseconds apart have IDs inside a small lexicographic range. That is time-neighbor enumeration, on systems that thought a UUID was the fix.

Twitter, Discord, and a lot of SaaS use a 64-bit snowflake: timestamp, then machine, then a per-millisecond sequence. Decode one and you have created_at without the API telling you. Two uses follow. Walk every ID in the time window of a known event (“orders created during the Black Friday hour”). Or start from your own ID and step through neighbors. Layouts differ. Twitter’s, which many copies still use, is:

Twitter-style snowflake (PYTHON)

snowflake = 175928847299117063
timestamp = snowflake >> 22 # ms since the generator's epoch
datacenter = (snowflake >> 17) & 0x1F # 5 bits. Some notes call this "machine id"
worker = (snowflake >> 12) & 0x1F # 5 bits. Easy to drop if you mask too early.
sequence = snowflake & 0xFFF # 0-4095, resets each millisecond

Discord and others move the epoch and sometimes the widths. Confirm the layout against two IDs whose created_at you already know, then script the window. An ID near 1690000000000000000 and its neighbors differ in those low bits in a way you can step.

Collect 20 or more IDs before you theorize. Look at length, charset, and structure. PO-2024-00451 and CLM-88213 are wearing their counter in public. A9F3K2 wants a base36 decode, a Crockford decode, or a hash-prefix check.

An 8-character token like iW9n2mXq is often the first 8 hex chars of MD5(str(n)) or SHA1(str(n)) for a sequential integer. Crack the scheme offline, against one ID you already own. Then you can name every ID in the range. That is how a “hard to guess, low severity” finding becomes “the attacker can address all 2 million rows.”

Offline scheme crack. No requests. (PYTHON)

import hashlib
known_id = "iW9n2mXq"
for i in range(100000):
if hashlib.md5(str(i).encode()).hexdigest()[:8] == known_id:
print("Scheme cracked. int ID is:", i)
break
# Then enumerate by hashing i+1, i+2, ... and request a handful, not the table.

If the ID is sha256(userId + salt) you cannot reverse a strong salt. You often don’t have to. The salt may be short, hardcoded, or empty, or the input space may be small. A list of addresses yields valid IDs when the ID is md5(email). Sources include a breach corpus, the marketing site’s customer logos, and the app’s own user search. That is credential-stuffing aimed at identifiers. Test the pattern on emails you control, then show the triager the scheme with those.

MongoDB ObjectID: why “random-looking” isn’t random

Section titled “MongoDB ObjectID: why “random-looking” isn’t random”

An ObjectID looks like 12 random bytes. It isn’t. Per the current spec it’s 4-byte timestamp + 5-byte per-process value + 3-byte counter:

507f191e810c19729de860ea, decomposed (DECODE)

507f191e # 4 bytes — unix timestamp (seconds). NOT secret: you know ~when a record was made.
810c19729d # 5 bytes — random per PROCESS. Constant for the whole server-process lifetime!
e860ea # 3 bytes — counter, +1 per ObjectID the process mints.

The trap: the 5-byte “random” middle is generated once when the process starts, not per document. So grab any single ObjectID from the same server process: your own account’s ID, or one leaked in a response or error. You now know those 40 bits for every ObjectID that process creates. Only a narrow timestamp window and a small counter delta remain to brute-force. A nominal 96-bit space shrinks to roughly 10³, 10⁶ candidates. andresriancho/mongo-objectid-predict automates exactly this.

A UUIDv1 is a 60-bit timestamp (100 ns ticks) + a clock sequence + the generator’s 48-bit MAC address. The MAC is constant, and many libraries fix the clock sequence per process. The only thing that changes between two UUIDs from the same server is the timestamp. The sandwich attack exploits this on flows where you can trigger UUID generation (e.g. password-reset tokens):

  1. Request a reset for your account → capture UUID T1 (the “bottom slice”).
  2. Request a reset for the victim (or wait for their action) → their token is minted between your two requests.
  3. Immediately request another reset for your account → capture UUID T2 (the “top slice”).
  4. Every valid timestamp lies between T1 and T2. Regenerate candidate UUIDs across that window and brute-force the reset link.

Tools that do the regeneration: guidtool, crazycat256/uuidtool, and Lupin-Holmes/sandwich. This turned several 2024-2025 password-reset flows into full account takeovers.

An opaque-looking token is often just an encoding. Before assuming an ID is unguessable, run it through the obvious decoders:

Is it actually random, or just wrapped? (DECODE)

Terminal window
# Base64 — GraphQL Relay global IDs love this shape
echo 'SW52b2ljZToxMDQy' | base64 -d # → "Invoice:1042" ⇒ try Invoice:1043
# JWT — the payload is only base64, readable by anyone holding the token
echo '<jwt>' | cut -d. -f2 | base64 -d # reveals sub / tenant_id / role claims
jwt_tool <jwt> -T # tamper claims; test alg:none & weak-secret
# Snowflake / ObjectID — decode the embedded timestamp to confirm the format

UUIDv4 doesn’t kill IDOR, it just moves the bug. The identifier still has to reach the attacker somehow. Look here:

  • Public-facing lists, comment threads, “members of this org” pages, “people who liked this,” activity feeds, these routinely leak UUIDs the app considers private
  • Search endpoints , /api/search?q=alice often returns the UUID alongside the displayname
  • Old API versions , /api/v1/users may still return a full enumerable list when /v2/ doesn’t
  • Webhooks and notifications, outbound notifications (Slack, email, mobile push) sometimes contain raw object IDs
  • Referer headers, when a user clicks a link out of your app, their object ID can leak in the Referer to an attacker-controlled URL
  • Error messages, verbose JSON errors sometimes echo back a target ID you weren’t authorized to know. User 10499 already claimed this coupon is the server telling you 10499 exists.
  • Embedded references, your own response contains {"referred_by":{"id":10499}}. That is a stranger’s ID, free.
  • List endpoints with the ownership filter missing , /api/orders returns yours, /api/orders?status=paid or /api/orders?limit=200 returns everyone’s. Same bug on /api/notifications?limit=100.
  • Search that is enumeration with a query box , /api/users/search?q=a, /api/users/search?q=john, GraphQL users(search:""){id}, /api/public/profiles/scroll, /api/chat/threads.
  • Document numbers, invoice #1042 is sometimes internal user 1042. It happens.
  • The marketing site, a testimonial that says Order #88413 shipped! is an ID you can feed to the API by hand.
  • Other tenants, section 06. A shared sequence means tenant A’s workspace:412 and tenant B’s workspace:413 are neighbors.

Files are the objects hunters skip. The URL is the identifier.

Change the number in the URL (GET)

GET /cdn/invoices/1042.pdf # yours
GET /cdn/invoices/1043.pdf # somebody else's. It is just a URL.
GET /s3-bucket-name/file.xlsx # "guessable URL" has been the control for 20 years. It still fails.

Supabase, Firebase, Hasura, Appwrite, PocketBase, and Directus ship a client-side data layer. The request is GET /rest/v1/invoices?id=eq.1042. The anon key is in the JavaScript bundle on purpose. Row-level security (RLS), or the product’s equivalent rules, is the only check between the browser and every row. When that policy is missing, one request reads the table, not one record.

Pull the project coordinates out of the bundle first (SHELL)

Terminal window
# Supabase URL and anon JWT
grep -oE 'https://[a-z0-9]+\.supabase\.co|eyJhbGciOi[^"]+' main.js
# Firebase project
grep -oE '"projectId":"[^"]+"|"apiKey":"[^"]+"|"authDomain":"[^"]+"' main.js

On Supabase and PostgREST, walk the failures in the order they actually show up:

  1. RLS off on one table. GET /rest/v1/<table>?select=* with the anon key returns every row.
  2. USING (true). A policy exists, it passes review, and it authorizes everyone.
  3. auth.role() = 'authenticated' where the policy should have been auth.uid() = user_id. Any logged-in user reads every row.
  4. A write policy with no WITH CHECK. PATCH your own row and set role, tenant_id, is_admin, or credits. The read policy never sees the write.
  5. The view and the function. A view runs with the view owner’s rights unless security_invoker = true. A SECURITY DEFINER function exposed at /rest/v1/rpc/<fn> does privileged work with whatever check the function author remembered to write. Often that is none.

PostgREST filter injection. The client library parameterizes most filters. .or(), .filter(), and .not() take raw PostgREST syntax. If the app interpolates a query string into one of them, , ( ) and . change the expression tree. The PostgREST docs say the operator and the value are used as-is, so the app must sanitize them. n8n shipped this bug twice: one request read, updated, or deleted every row.

Intended filter, then the widened one (HTTP)

// the app builds this from q
supabase.from('items').select('*')
.or(`title.ilike.*${q}*,description.ilike.*${q}*`)
GET /rest/v1/items?select=*&or=(title.ilike.*x*,description.ilike.*x*),id.gt.0

The trailing ,id.gt.0 is a second condition the developer did not write. The filter that was supposed to search titles now matches the table.

Firebase: rules are not filters. A rule is a proof the query must satisfy. It is not a WHERE clause the server applies for you. allow read: if resource.data.ownerId == request.auth.uid rejects a list unless the query itself constrains ownerId. The “fix” that shows up next is a collection-group rule:

Every invoices subcollection, every parent, every tenant (RULES)

match /{path=**}/invoices/{doc} {
allow read: if request.auth != null;
}

collectionGroup('invoices') then reaches every subcollection with that name. The same shape is the default an AI scaffolder writes: allow read: if request.auth != null. Any signed-in user reads everything the rule covers.

Hasura. The session is a set of x-hasura-* variables: x-hasura-role, x-hasura-user-id, x-hasura-org-id. If the server accepts those headers from the client instead of only from a verified JWT, you set your own role. Send x-hasura-role: admin on every request once. If the admin secret has leaked, row permissions are gone.

AI-scaffolded apps are the fresh supply. In January 2025, researchers reported 170+ Lovable-generated apps with readable production databases. The data included names, emails, phones, and payment data. RLS was off or set to a permissive default. The scaffold ships the frontend in minutes and the policy last.

Detection pass. Five rows, then stop. (SHELL)

Terminal window
# 1. What does PostgREST expose?
curl -s "https://<project>.supabase.co/rest/v1/" -H "apikey: $ANON"
# 2. Read a table as anon
curl -s "https://<project>.supabase.co/rest/v1/invoices?select=*&limit=5" \
-H "apikey: $ANON"
# 3. Read B's row as A
curl -s "https://<project>.supabase.co/rest/v1/invoices?id=eq.<B_ID>&select=*" \
-H "apikey: $ANON" -H "Authorization: Bearer $A_TOKEN"
# 4. Prove a write on B, an account you own
curl -s -X PATCH "https://<project>.supabase.co/rest/v1/profiles?id=eq.<B_ID>" \
-H "apikey: $ANON" -H "Authorization: Bearer $A_TOKEN" \
-H "Content-Type: application/json" -d '{"role":"admin"}'

Next step: test each candidate with two accounts and the four-identity diff.

Connections3 backlinks · 2 outgoingFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

IDOR HuntingFor educational and authorized bug bounty use only.