# Second-Order and Multi-Step IDOR
> IDORs where the foreign reference isn't used in the request that carries it. It's stored in session, workflow state, a schedule or a share, or it's honoured only at a later step. The object-level check happens (or is skipped) somewhere a single-request swap test never looks.
## How it works
Classic IDOR testing replays one request with a swapped ID. These variants break that model in three ways:
| Variant | Mechanism |
|---|---|
| **Second-order** | input is stored first, then later used to reference an object without re-checking ownership ([[raw/intigriti.com/idor-a-complete-guide-to-exploiting-advanced-idor-vulnerabilities-inti-2796|Intigriti]]) |
| **Multi-step** | early steps of a workflow are checked; a later step (review/submit/finalize) isn't ([[raw/weekly-bugbounty-content.beehiiv.com/broken-access-control-advanced-idor-exploitation-4163|Weekly Bug Bounty]]) |
| **Grant-lifetime** | access was legitimate when granted but isn't re-evaluated after revocation |
| **Reference leak across boundary** | a reference legitimately visible in one context is accepted by another endpoint with a stronger permission |
IDORs persist because ownership assumptions get reused across steps that weren't designed to connect ([[raw/aikido.dev/idor-vulnerability-explained-why-idor-persists-aikido-4382|Aikido]]).
## Techniques / patterns
### Stored reference trusted later
- **Scheduled export:** the schedule stores a user ID in an external scheduler; when it fires, it reads the ID from metadata and generates the export with no fresh check, so you can schedule an export of another account ([[raw/intigriti.com/idor-a-complete-guide-to-exploiting-advanced-idor-vulnerabilities-inti-2796|Intigriti]]).
- **Session seeded with a foreign ID (Bookly ≤28.2, CVE-2026-93399):** the unauthenticated `bookly_get_form_id` accepted an `order_id` and persisted it into a new booking session without proving that session created the order. A later action (`bookly_render_complete`) then disclosed the victim order's secret `bookly_order` token. The token unlocked `bookly_add_to_calendar` (disclosure) and `bookly_rollback_order` (deletion of unpaid bookings). The non-sequential token was meant to be the boundary; the session bridged the predictable ID to it ([[raw/sentrium.co.uk/critical-bookly-idor-booking-disclosure-and-deletion-13186|Sentrium]]).
- **Internal API path injection:** a front API reflected the user ID unvalidated into the path of an internal-only request; traversal (`../<otherId>`) fetched another user's data, and the internal API didn't receive the auth header. One endpoint did this; siblings URL-encoded first ([[raw/weekly-bugbounty-content.beehiiv.com/broken-access-control-advanced-idor-exploitation-4163|Weekly Bug Bounty]]).
- **Attach-to-own-object:** Habitat ≤1.7.1 (CVE-2026-130859) let `CreatePostController::addAttachmentsToPost()` claim other users' **unposted** uploads by sequential `attachmentId`, publishing them and removing them from the owner's draft ([[raw/github.com/habitat-idor-15024|Habitat]]). Same shape as body foreign-key BOLA in [[BOLA in APIs]].
### Workflow position
- Job application: autosave and submit are checked; the final review/submit endpoint isn't ([[raw/weekly-bugbounty-content.beehiiv.com/broken-access-control-advanced-idor-exploitation-4163|Weekly Bug Bounty]]).
- 5-step memorial wizard with enumerable step IDs, plus a backend that accepted the literal CSRF placeholder → anonymous hijack ([[raw/bblabs.es/wizard-takeover-ato-idor-csrf-lab-based-on-a-real-report-12598|bblabs Wizard Takeover]]).
- Write-then-read sequences: KYC financing drafts allowed cross-identity read, update, file attach/delete; submit reached the other draft's business rules. Scanners miss this because it needs two sessions and a write followed by a read ([[raw/siteguarding.com/bola-in-auto-financing-applications-case-study-15620|SiteGuarding]]).
### Grant lifetime and derived access
- **Frappe Document Follow** (CVE-2026-66000/66058/66059): three failures. Follow any document (object level), receive fields you can't read (field level), and keep getting change emails after permission is revoked (grant lifetime). Fixed in Frappe v16.23.0 / v15.112.0 ([[raw/robinroy.xyz/erpnext-s-document-follow-feature-exposed-unauthorized-data-11315|Robin Roy]]).
- **Removed member keeps reading:** a page ID captured while a member still returned private metadata and the member list after removal ([[raw/medium.com/the-user-was-removed-the-access-wasn-t-12436|The User Was Removed]]).
- **Shared container → private child:** a shared AI chat exposed a private skill UUID, and a secondary `POST /skills/{uuid}/diagram` returned its instructions ([[raw/medium.com/the-1000-idor-hiding-behind-a-shared-ai-chat-15473|shared AI chat]]); see [[IDOR in AI Applications]].
- **Parent/child mismatch:** GROWI checked the page but not that the revision belonged to it ([[raw/github.com/growi-idor-read-revisions-of-pages-you-cannot-view-12753|GROWI]]); TeamPass `update_folder` checked neither target nor new parent folder, allowing re-parenting of credential subtrees ([[raw/github.com/teampass-folder-re-parenting-authorization-bypass-15474|TeamPass]]).
### Stale state in the check itself
Provenance Blockchain's `AddAccess` let a caller who "controls 100% of supply" administer a marker, but read the supply from the marker struct, which stays 0 for non-fixed markers while the bank module holds the real count. Anyone could become admin of 82 live markers before v1.28.0 ([[raw/blog.trailofbits.com/state-divergence-enables-unauthorized-access-11712|Trail of Bits]]). The check ran, but against divergent state.
## Testing
- Follow every ID through the whole workflow: where it's stored, which later actions consume it, which tokens or secrets it unlocks.
- Swap IDs at every step, especially final/review/confirm and async consumers (exports, schedules, webhooks, notifications).
- Re-test with captured IDs after revocation, downgrade, removal from org, and after share links are disabled.
- For parent/child routes, pair your parent with a foreign child and a foreign parent with your child.
## Defenses
- Keep workflow identifiers in server-side session state rather than client parameters ([[raw/cheatsheetseries.owasp.org/idor-prevention-cheat-sheet-3064|OWASP IDOR Cheat Sheet]]).
- Re-authorize at consumption time (job execution, notification dispatch, final submit), not only at creation.
- Bind child objects to parents in the lookup (`WHERE revision.page_id = :page`).
- Make revocation invalidate derived grants (follows, subscriptions, cached share access).
- Evaluate authorization against the authoritative source of truth, not a cached or denormalized field ([[raw/blog.trailofbits.com/state-divergence-enables-unauthorized-access-11712|Trail of Bits]]).
## Related
- [[Insecure Direct Object Reference]]
- [[IDOR Testing Methodology]]
- [[BOLA in APIs]]
- [[IDOR in AI Applications]]
- [[Broken Access Control]]
- [[Server-Side Request Forgery]]
- [[Cross-Site Request Forgery]]
## Sources
- [[raw/intigriti.com/idor-a-complete-guide-to-exploiting-advanced-idor-vulnerabilities-inti-2796|IDOR: A Complete Guide to Exploiting Advanced IDOR Vulnerabilities]]
- [[raw/weekly-bugbounty-content.beehiiv.com/broken-access-control-advanced-idor-exploitation-4163|Broken Access Control: Advanced IDOR Exploitation]]
- [[raw/aikido.dev/idor-vulnerability-explained-why-idor-persists-aikido-4382|IDOR Vulnerability Explained: Why IDOR Persists]]
- [[raw/sentrium.co.uk/critical-bookly-idor-booking-disclosure-and-deletion-13186|Critical Bookly IDOR: booking disclosure and deletion]]
- [[raw/github.com/habitat-idor-15024|Habitat IDOR]]
- [[raw/bblabs.es/wizard-takeover-ato-idor-csrf-lab-based-on-a-real-report-12598|Wizard Takeover ATO (IDOR + CSRF) lab]]
- [[raw/siteguarding.com/bola-in-auto-financing-applications-case-study-15620|BOLA in auto financing applications: case study]]
- [[raw/robinroy.xyz/erpnext-s-document-follow-feature-exposed-unauthorized-data-11315|ERPNext's Document Follow feature exposed unauthorized data]]
- [[raw/medium.com/the-user-was-removed-the-access-wasn-t-12436|The User Was Removed. The Access Wasn't.]]
- [[raw/medium.com/the-1000-idor-hiding-behind-a-shared-ai-chat-15473|The $1000 IDOR Hiding Behind a Shared AI Chat]]
- [[raw/github.com/growi-idor-read-revisions-of-pages-you-cannot-view-12753|GROWI IDOR: read revisions of pages you cannot view]]
- [[raw/github.com/teampass-folder-re-parenting-authorization-bypass-15474|TeamPass folder re-parenting authorization bypass]]
- [[raw/blog.trailofbits.com/state-divergence-enables-unauthorized-access-11712|State divergence enables unauthorized access]]
- [[raw/cheatsheetseries.owasp.org/idor-prevention-cheat-sheet-3064|IDOR Prevention Cheat Sheet]]