Skip to content
Account takeover Write-up Intermediate

Github Organization Takeover By Claiming Owner Invitation

GitHub allowed a new account to accept an organisation owner invitation without verifying the email address, and the invitation token was shown on the organisation page. An attacker could register with the invitee's email, accept the invitation first, and take control of the organisation.

absshax Follow

Published on abss.me

Bounty$5,000 View original

Through github.com one can create an organization within their personal account and invite team members. I was hard on checking for any account privilege escalations here.

Abss (@absshax), on abss.me

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

GitHub organisations let a personal account group repositories and people together. Through github.com you can create an organisation inside your personal account and invite team members to it. The invitation feature is the part that matters here: only a team maintainer or the owner can invite people, and the invitee can either be an existing GitHub user or someone who is new to GitHub.

When the invitee is new to GitHub, the invitation has to be sent to their email address only. When they already have an account, the inviter can pick their username and send the invitation. In both cases the inviter also chooses the privilege the invitee will get, and the owner has complete control over the organisation.

Inviting owner
Inviting owner From the original on abss.me

The screenshot shows the invitation form with the privilege selector for the invitee.

Setup

The researcher created an organisation on github.com and started probing it for account privilege escalations. No special tooling is described: the work was done through the normal web interface, with a personal account that could create an organisation and act as its owner, plus the ability to register new GitHub accounts.

The precondition for the attack is an organisation that has invited a new owner through their email address, meaning the invitee is not yet a GitHub user and would normally have to create an account to accept.

Finding it

While testing the invitation flow, the researcher sent an invitation and then, instead of following the intended path of basic email invitation > account creation + accepting invitation, created a new GitHub account using the invitee's email address.

On the github.com/org_name page the invitation was displayed to this new account.

Web Invitation
Web Invitation From the original on abss.me

That display on its own is normal, since GitHub shows invitations that way. What stood out was that the account had been created without completing email verification, which meant anyone could be impersonating the invitee. The open question was whether the invitation shown on the page was only a client-side display notification, or whether it was backed by a real endpoint carrying the invitation token.

Exploitation

Step 1: Send an owner invitation to an email address

As the organisation owner, invite a person who is not yet a GitHub user, using their email address, and grant the owner privilege. The invitation is delivered by email.

Step 2: Register an account with the invitee's email

Create a new GitHub account using that same email address, without verifying the email. Because the invitation could be accepted without verification, the attacker could claim it before the real invitee did.

Step 3: Load the organisation page

Visit github.com/org_name while signed in as the unverified account. The pending invitation is displayed there, and the page exposes the invitation token.

Step 4: Accept the invitation

The researcher expected the displayed invitation to be a client-side notification only. It was not: accepting it worked against the real endpoint, and the account joined the organisation as the new owner.

Accept Invitation
Accept Invitation From the original on abss.me

The screenshot shows the invitation being accepted and the account joining the organisation as the new owner.

Root cause

The design relied on control of the invited email address as proof of identity, but two checks were missing:

  1. The account could be created without verifying the email, so an attacker could register an account with an address they did not own.
  2. The invitation acceptance endpoint did not check whether the invitee's email had been verified before letting the account claim the invitation.

On top of that, the web invitation was displayed on github.com/org_name without any checks and revealed the invitation token, so the unverified account could see and use it. The combination of an owner-level invitation, the absence of email verification, and the absence of a verification check before accepting the invitation is what allowed the takeover.

Impact

A malicious user who knows that an organisation has invited a new owner by email can register an account with the invitee's address, accept the invitation before the real owner does, and gain control over the organisation while impersonating the invitee. The attack requires the organisation to have sent an owner invitation to an email address that does not yet belong to a GitHub account, and it must be completed before the legitimate invitee accepts. The researcher notes that similar bugs were found afterwards.

Fix

The report does not describe the change that was made. The checks that would close the gap are enforcing email verification before an invitation can be accepted, and not exposing the invitation token on the organisation page to an unverified account.

Variants to test

  • Invite a new owner by email on another platform and register the address without verifying it, then load the organisation or team page. A positive result is a pending invitation with a usable token shown to the unverified account.
  • Accept an invitation from an unverified account and observe whether the join succeeds. A positive result is membership, especially with owner or admin privileges, granted without verification.
  • Check whether invitation tokens are exposed in page source, API responses or client-side state on organisation pages. A positive result is a token that can be submitted to the acceptance endpoint.
  • Test invitations to other privileged roles, such as maintainer or admin, to see whether the same missing verification check applies.
  • Test whether an existing account can change its email to an invited address without verification and then claim the invitation.

Timeline

  • Bug reported: Nov 8th 2017
  • Bug resolved, bounty and swag: $5000, Nov 16th 2017

The report's TL;DR says it was reported on Nov 17, 2017, while its timeline gives Nov 8th 2017.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

What happened, in plain words

GitHub lets you create an organisation: a shared space where a group of people keep their code projects (repositories) together under one name. An organisation has an owner, the person with full control over it, and the owner can invite other people to join.

This report is about a flaw in that invitation process. If an organisation invited a brand new owner by email, and that person did not yet have a GitHub account, an attacker could create a GitHub account using the invited email address without ever proving they owned that email. GitHub then showed the pending invitation to that fake account, and the fake account could accept it and become the new owner of the organisation.

The researcher sums it up as three things coming together:

  • An invitation to owner from the organisation.
  • No email verification.
  • No check on email verification prior to accepting invitation.

This bug was one of the researcher's very first bugs.

The invitation feature

Through github.com you can create an organisation within your personal account and invite team members. The researcher was looking hard for any account privilege escalations here. A privilege escalation means getting more power on a system than you were given: for example, joining a group as an ordinary member and ending up as its owner.

While browsing github.com, the researcher created an organisation and started testing. Only the team maintainer or the owner can invite people to the organisation. When sending the invite, the invitee could either be an existing GitHub user or someone who is new to GitHub.

If the user is new to GitHub then the invitation has to be sent via their email only. If they are already a GitHub user there is an option to choose their username and then send the invitation.

As shown below, the inviter can also choose the privilege of the invitee and send the invitation. The owner has complete control over the organisation.

Inviting owner
Inviting owner From the original on abss.me

The screenshot shows the invitation form, including the selector for the privilege the invitee will receive.

Setting up the test

The researcher created an organisation on github.com and started probing it for account privilege escalations. No special tooling is described: everything was done through the normal web interface, with a personal account that could create an organisation and act as its owner, plus the ability to register new GitHub accounts.

The precondition for the attack is an organisation that has invited a new owner through their email address, meaning the invitee is not yet a GitHub user and would normally have to create an account to accept.

Finding it

While testing the invitation flow, the researcher sent an invitation and then, instead of following the intended path of basic email invitation > account creation + accepting invitation, created a new GitHub account using the invitee's email address.

On the github.com/org_name page the invitation was displayed to this new account.

Web Invitation
Web Invitation From the original on abss.me

That display on its own is normal, since GitHub shows invitations that way. What stood out was that the account had been created without completing email verification, which meant anyone could be impersonating the invitee. The open question was whether the invitation shown on the page was only a client-side display notification, or whether it was backed by a real endpoint carrying the invitation token.

Exploitation

Step 1: Send an owner invitation to an email address

As the organisation owner, invite a person who is not yet a GitHub user, using their email address, and grant the owner privilege. The invitation is delivered by email.

Step 2: Register an account with the invitee's email

Create a new GitHub account using that same email address, without verifying the email. Because the invitation could be accepted without verification, the attacker could claim it before the real invitee did.

Step 3: Load the organisation page

Visit github.com/org_name while signed in as the unverified account. The pending invitation is displayed there, and the page exposes the invitation token.

Step 4: Accept the invitation

The researcher expected the displayed invitation to be a client-side notification only. It was not: accepting it worked against the real endpoint, and the account joined the organisation as the new owner.

Accept Invitation
Accept Invitation From the original on abss.me

The screenshot shows the invitation being accepted and the account joining the organisation as the new owner.

Root cause

The design relied on control of the invited email address as proof of identity, but two checks were missing:

  1. The account could be created without verifying the email, so an attacker could register an account with an address they did not own.
  2. The invitation acceptance endpoint did not check whether the invitee's email had been verified before letting the account claim the invitation.

On top of that, the web invitation was displayed on github.com/org_name without any checks and revealed the invitation token, so the unverified account could see and use it. The combination of an owner-level invitation, the absence of email verification, and the absence of a verification check before accepting the invitation is what allowed the takeover.

Impact

A malicious user who knows that an organisation has invited a new owner by email can register an account with the invitee's address, accept the invitation before the real owner does, and gain control over the organisation while impersonating the invitee. The attack requires the organisation to have sent an owner invitation to an email address that does not yet belong to a GitHub account, and it must be completed before the legitimate invitee accepts. The researcher notes that similar bugs were found afterwards.

Fix

The report does not describe the change that was made. The checks that would close the gap are enforcing email verification before an invitation can be accepted, and not exposing the invitation token on the organisation page to an unverified account.

Variants to test

  • Invite a new owner by email on another platform and register the address without verifying it, then load the organisation or team page. A positive result is a pending invitation with a usable token shown to the unverified account.
  • Accept an invitation from an unverified account and observe whether the join succeeds. A positive result is membership, especially with owner or admin privileges, granted without verification.
  • Check whether invitation tokens are exposed in page source, API responses or client-side state on organisation pages. A positive result is a token that can be submitted to the acceptance endpoint.
  • Test invitations to other privileged roles, such as maintainer or admin, to see whether the same missing verification check applies.
  • Test whether an existing account can change its email to an invited address without verification and then claim the invitation.

Timeline

  • Bug reported: Nov 8th 2017
  • Bug resolved, bounty and swag: $5000, Nov 16th 2017

The report's TL;DR says it was reported on Nov 17, 2017, while its timeline gives Nov 8th 2017.

Glossary

  • Organisation: a shared GitHub space where a group keeps repositories and members together under one name.
  • Repository: a project's folder of files and its history, hosted on GitHub.
  • Owner: the person with complete control over an organisation.
  • Maintainer: a team member with management rights over a team.
  • Invitation: a message offering someone a place in an organisation, sent by email or to an existing username.
  • Invitee: the person being invited.
  • Privilege: the level of power an account has, such as member, maintainer or owner.
  • Privilege escalation: gaining more power on a system than you were granted.
  • Account takeover: gaining control of someone else's account or role.
  • Email verification: proving you own an email address, usually by clicking a link sent to it.
  • Impersonation: pretending to be another person or account.
  • Endpoint: a specific address on a server that performs an action when contacted.
  • Token: a secret string that proves an action is authorised, like a claim ticket.
  • Client-side: happening in the browser rather than on the server.
  • API: a way for programs to talk to a service directly, without the web page.
  • Page source: the raw HTML a browser receives before rendering a page.
  • Bounty: a payment a company makes for a valid security report.
  • Swag: company merchandise given as a thank-you.

More from GitHub

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.