Taskcluster web-server OAuth2 authorization codes are reusable and the exchange handler checks the wrong expiry column
The Taskcluster web-server's OAuth2 token-exchange handler never consumed authorization codes and checked the wrong expiry field, so a leaked code could be replayed to mint fresh bridge access tokens and then Taskcluster credentials in the original user's identity. The text claims this works well past the intended 10-minute code lifetime, bounded only by the client's requested expiry and a daily cleanup job.
Originally disclosed on HackerOne
- Fixed in 20 days
- Paid in 35 days
- Disclosed after 40 days
The Taskcluster web-server's OAuth2 token-exchange handler does not consume authorization codes and does not enforce the authorization-code expiry. A leaked authorization code can be replayed to mint additional bridge access tokens for the original user, well past the 10-minute window that RFC 6749 §4.1.2 requires.
Source-to-sink
Two bugs in services/web-server/src/servers/oauth2.js, both in the same handler at lines 165-199:
-
The exchange handler validates
redirect_uriand code existence, mints a bridge access token, and returns — it never deletes or otherwise consumes theauthorization_codesrow. RFC 6749 §4.1.2 requires single-use codes: "The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request..." -
The expiry check at line 66 reads
entry.client_details.expires, which is the requested lifetime of the resulting Taskcluster credentials (capped by the registered OAuth client'smaxExpires, e.g."1 year"in the test config). The authorization-code row's intended 10-minute lifetime (entry.expires, set at line 33 totaskcluster.fromNow('10 minutes')) is never checked at exchange time. Expired codes remain usable until the dailycleanup-expire-auth-codescron deletes them (services/web-server/procs.yml:20-24).
The same expiry-column mismatch repeats in the bridge-token-to-credentials handler at oauth2.js:318-375 (/login/oauth/credentials), which checks entry.client_details.expires rather than the access-token row's entry.expires.
Reproduction (end-to-end PoC)
End-to-end PoC reproduces against unmodified Taskcluster source at commit 246cb765672da1fdc1b7e6901002725bf0e50090 (default branch main). The test case extends the existing services/web-server/test/third_party_test.js and runs via the project's existing Mocha test infrastructure:
$ source ~/.nvm/nvm.sh && nvm use 24.15.0
$ cd taskcluster && yarn install
$ docker compose up -d postgres
$ docker exec taskcluster-postgres-1 psql -U postgres -c "CREATE DATABASE \"taskcluster-test\";"
$ cd services/web-server
$ TEST_DB_URL=postgresql://postgres@localhost:5432/taskcluster-test NODE_ENV=test \
yarn mocha --grep "TC-002" test/third_party_test.js
Result:
services/web-server/test/third_party_test.js
unit
✔ TC-002 (PoC): authorization code is reusable in violation of RFC 6749 §4.1.2
1 passing
The test:
- Authorizes a code through
GET /login/oauth/authorizeusing thetest-code-whitelistedregistered client that ships inservices/web-server/config.yml. - Exchanges the code through
POST /login/oauth/token(asserts 200, token A). - Replays the same code through
POST /login/oauth/token(asserts 200, token B,token A != token B— the RFC 6749 §4.1.2 violation). - Calls
GET /login/oauth/credentialswithAuthorization: Bearer <token B>(asserts 200, Taskcluster credentials withclientId+accessTokenin the original user's identity).
The full test patch and Mocha pass log are attached.
Remediation
Consume the authorization code atomically during token exchange. Add a DB function such as consume_authorization_code(code, client_id, redirect_uri) that performs a single statement equivalent to:
DELETE FROM authorization_codes
WHERE code = code_in
AND client_id = client_id_in
AND redirect_uri = redirect_uri_in
AND expires > now()
RETURNING code, client_id, redirect_uri, identity, identity_provider_id, expires, client_details;
Use the returned row as the only gate for creating an access token. Apply the same fix to /login/oauth/credentials: check the access-token row's top-level entry.expires rather than entry.client_details.expires.
Optionally, store a back-reference from access tokens to the originating authorization code and revoke or invalidate already-minted tokens if replay is detected, matching RFC 6749's "SHOULD revoke" clause in §4.1.2.
Duplicate / advisory checks (performed 2026-05-14)
- GitHub Security Advisories on
taskcluster/taskcluster:gh api repos/taskcluster/taskcluster/security-advisoriesreturns[]. - Mozilla Foundation Security Advisories index: no matching entry for taskcluster or OAuth code reuse.
- HackerOne disclosed reports mentioning "taskcluster" globally: 3 (#2915647 Netlify token in CI logs, #2221404 RCE via task env variable, #2696294 private emails leaked). None cover OAuth2 authorization-code reuse or expiry-mismatch.
Impact
With a captured authorization code (referer in narrow conditions, redirect-page logs, TLS-inspecting proxy, browser-history access on the redirect page), the attacker can:
- Replay
POST /login/oauth/tokento mint a fresh OAuth bridge access token bound to the original user'sidentity,identity_provider_id, and consented scope set. - Call
GET /login/oauth/credentialswith that bridge token to receive Taskcluster credentials in the original user's identity. The auth service'screate_clientbehavior (db/versions/0041.yml:343-404) returns the existing client's access token when called within a 15-minute idempotency window; outside that window the bridge token can still mint credentials if the attacker is the first to convert the bridge token to credentials. - Replay arbitrarily often within the practical window bounded by (a)
client_details.expiresand (b) the daily cleanup cron. With the documented default ofmaxExpiresup to 1 year andauthorizationCodeExpirationDelay: '- 10 minutes', the window extends to many hours past the intended 10-minute code lifetime.
For firefox-ci-tc.services.mozilla.com, the resulting Taskcluster credentials carry the user's Firefox-CI scopes, which directly impacts the Firefox build CI integrity boundary. A Taskcluster identity that holds Firefox-CI scopes (e.g. mozilla-employee roles) is a privileged role; replay of a code authorized by such an identity is a meaningful integrity exposure on a Critical Site asset.
The local PoC demonstrates the full chain — authorize → first exchange → replay exchange → credentials conversion — succeeds end-to-end with no error.
Context
Taskcluster is Mozilla's task execution platform, and its web-server component exposes an OAuth2 login flow so that external identity providers can be bridged into Taskcluster credentials. The flow follows the familiar authorization-code pattern: a user is sent to GET /login/oauth/authorize, consents, and receives an authorization code; the client then exchanges that code at POST /login/oauth/token for a bridge access token; finally the bridge token is converted into Taskcluster credentials at GET /login/oauth/credentials.
The report concerns firefox-ci-tc.services.mozilla.com, the Firefox-CI deployment of Taskcluster. The relevant code lives in services/web-server/src/servers/oauth2.js. Two defects sit in the same token-exchange handler, at lines 165-199, and a third instance of the same mistake appears in the credentials handler at lines 318-375.
Setup
The proof of concept runs against unmodified Taskcluster source at commit [redacted] on the default branch main. It extends the existing test file services/web-server/test/third_party_test.js and runs through the project's existing Mocha infrastructure. The prerequisites are Node 24.15.0 via nvm, a local Postgres started with Docker Compose, and a test database created inside that container.
$ source ~/.nvm/nvm.sh && nvm use 24.15.0
$ cd taskcluster && yarn install
$ docker compose up -d postgres
$ docker exec taskcluster-postgres-1 psql -U postgres -c "CREATE DATABASE \"taskcluster-test\";"
$ cd services/web-server
$ TEST_DB_URL=postgresql://postgres@localhost:5432/taskcluster-test NODE_ENV=test \
yarn mocha --grep "TC-002" test/third_party_test.js
The test uses the test-code-whitelisted registered OAuth client that ships in services/web-server/config.yml.
Finding it
The researcher read the exchange handler and saw that it validates redirect_uri and the existence of the code, mints a bridge access token, and returns. It never deletes or otherwise consumes the authorization_codes row. That contradicts RFC 6749 §4.1.2, which requires single-use codes:
The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request...
The second defect is an expiry check against the wrong column. The check at line 66 reads entry.client_details.expires, which is the requested lifetime of the resulting Taskcluster credentials, capped by the registered OAuth client's maxExpires (for example "1 year" in the test config). The authorization-code row's intended 10-minute lifetime is stored in entry.expires, set at line 33 to taskcluster.fromNow('10 minutes'), and that value is never consulted at exchange time. Expired codes therefore remain usable until the daily cleanup-expire-auth-codes cron deletes them, defined at services/web-server/procs.yml:20-24.
The same expiry-column mismatch repeats in the bridge-token-to-credentials handler at oauth2.js:318-375 (/login/oauth/credentials), which checks entry.client_details.expires rather than the access-token row's entry.expires.
Exploitation
The PoC is a Mocha test that drives the full chain against the test database. Running it produces:
services/web-server/test/third_party_test.js
unit
✔ TC-002 (PoC): authorization code is reusable in violation of RFC 6749 §4.1.2
1 passing
Step 1: obtain an authorization code
The test authorizes a code through GET /login/oauth/authorize using the test-code-whitelisted registered client from services/web-server/config.yml. This is the consent step of the flow; the result is an authorization code.
Step 2: first exchange
The code is exchanged through POST /login/oauth/token. The test asserts a 200 response and records the returned bridge access token as token A.
Step 3: replay the same code
The identical code is sent through POST /login/oauth/token a second time. The test asserts 200 and records token B, and asserts that token A != token B. A second successful exchange of a code that should already be spent is the RFC 6749 §4.1.2 violation: the server neither consumed the row nor denied the replay.
Step 4: convert the replayed token to credentials
The test calls GET /login/oauth/credentials with the replayed bridge token:
Authorization: Bearer <token B>
It asserts 200 and Taskcluster credentials containing clientId and accessToken in the original user's identity. The local PoC demonstrates the chain authorize, first exchange, replay exchange, credentials conversion succeeds end to end with no error.
The full test patch and the Mocha pass log were attached to the report.
Root cause
There are two independent mistakes in the exchange handler, plus a repeat of the second one elsewhere.
- No consumption of the code. The handler checks that the code exists and that
redirect_urimatches, then mints a token. Nothing marks theauthorization_codesrow as used, so every replay of the same code mints another bridge token for the same user. - Wrong expiry column. The expiry check reads
entry.client_details.expires, the lifetime of the credentials being requested (bounded by the client'smaxExpires), instead ofentry.expires, the 10-minute lifetime of the code itself. The code's real expiry is only enforced indirectly, when the dailycleanup-expire-auth-codescron removes the row. - Same mismatch in the credentials handler.
/login/oauth/credentialschecksentry.client_details.expiresrather than the access-token row'sentry.expires, so the bridge token's own lifetime is not what gates conversion.
Existing defences did not help because neither the single-use requirement nor the code lifetime was enforced at the point where the code is redeemed. The scheduled deletion leaves a window that extends to many hours past the intended 10-minute lifetime.
Impact
An attacker who captures an authorization code can replay POST /login/oauth/token to mint fresh bridge access tokens bound to the original user's identity, identity_provider_id and consented scope set. With such a token they can call GET /login/oauth/credentials and receive Taskcluster credentials in the original user's identity.
The auth service's create_client behaviour (db/versions/0041.yml:343-404) returns the existing client's access token when called within a 15-minute idempotency window; outside that window the bridge token can still mint credentials if the attacker is the first to convert the bridge token to credentials.
Replay is possible arbitrarily often within a practical window bounded by two things: the value of client_details.expires and the daily cleanup cron. With the documented default of maxExpires up to 1 year and authorizationCodeExpirationDelay: '- 10 minutes', that window extends to many hours past the intended 10-minute code lifetime.
Capturing the code in the first place requires one of several narrow conditions, as the report lists them: a referer leak, logs on the redirect page, a TLS-inspecting proxy, or access to browser history on the redirect page.
For firefox-ci-tc.services.mozilla.com, the resulting credentials carry the user's Firefox-CI scopes, which directly affects the Firefox build CI integrity boundary. A Taskcluster identity holding Firefox-CI scopes, such as mozilla-employee roles, is a privileged role, so replaying a code authorized by such an identity is a meaningful integrity exposure on a Critical Site asset.
Fix
The recommendation is to consume the authorization code atomically during token exchange. Add a database function such as consume_authorization_code(code, client_id, redirect_uri) that performs a single statement equivalent to:
DELETE FROM authorization_codes
WHERE code = code_in
AND client_id = client_id_in
AND redirect_uri = redirect_uri_in
AND expires > now()
RETURNING code, client_id, redirect_uri, identity, identity_provider_id, expires, client_details;
The returned row should be the only gate for creating an access token, so a second attempt finds nothing to return and is denied. Apply the same correction to /login/oauth/credentials: check the access-token row's top-level entry.expires rather than entry.client_details.expires.
Optionally, store a back-reference from access tokens to the originating authorization code and revoke or invalidate already-minted tokens when replay is detected, matching RFC 6749's "SHOULD revoke" clause in §4.1.2.
Variants to test
- Other OAuth2 handlers in the same service. Look for any redemption path that reads a row and then acts on it without a conditional delete or an atomic update. A positive result is two successful redemptions of the same value, with different outputs.
- Expiry checks that read a nested field. Wherever a handler compares
something.client_details.expiresor a similarly nested value, check whether the row's own top-level expiry is what should have been compared. A positive result is a value that still works after its documented lifetime has passed. - Cleanup-cron-only enforcement. If the only thing that removes short-lived secrets is a periodic job, test whether the secret survives past its stated lifetime. A positive result is a successful use of the secret between its nominal expiry and the next cleanup run.
- Idempotency windows in credential minting. The 15-minute
create_clientwindow described here is worth probing on other deployments: check whether a token converted once can be converted again, and whether the second conversion returns the same or a new credential set.
Hunting notes
This class of bug hides in the gap between what a specification requires and what a handler actually enforces. The exchange endpoint is a good place to look because it is short, does the security-relevant work, and is easy to read in full. Signals during recon include OAuth2 endpoints that return a token on every call with the same code, and code paths where an expiry is read from a nested object rather than the row itself. The researcher showed impact by building an end-to-end test inside the project's own test suite, running it against unmodified source at a pinned commit, and asserting each step: 200 on the first exchange, 200 on the replay with a different token, and 200 on the credentials conversion in the original user's identity.
What happened, in plain words
Taskcluster is a system Mozilla uses to run jobs automatically, for example the many steps that go into building Firefox. People log in to it through a web page, and that login is handled by a piece of software called the web-server. The web-server lets an outside login provider (think "log in with Google" style) vouch for who you are, and then hands you a pass that Taskcluster understands.
The login works in three steps, and the report calls this the "authorization-code flow". First, you are sent to a page where you agree to log in. Second, the system gives your browser a short string of characters called an authorization code. Third, your browser sends that code back to the server, and the server swaps it for a longer-lived pass called a bridge access token. That token can then be turned into the actual Taskcluster credentials, the username-and-password-like pair that lets you run jobs.
The security rule for this kind of code is simple and is written down in a public standard called RFC 6749: a code may be used once. If someone tries to use it a second time, the server must refuse. The code is also supposed to expire after a short time, ten minutes in this system.
The researcher found that the Taskcluster web-server breaks both rules. It hands out a fresh token every time the same code is presented, and it never checks the code's own ten-minute expiry. So if an attacker gets hold of a code, for example from a log file or a proxy that inspects traffic, they can keep replaying it and keep getting new tokens for the original user, long after the code should have died. Those tokens can then be turned into real Taskcluster credentials, which for the Firefox-CI deployment carry the user's build permissions.
The report is a bug bounty report: a security researcher found the problem, wrote a test that proves it, and reported it to Mozilla.
Background: the pieces involved
Before the details, here are the ideas you need. Each one is explained from scratch.
- API (Application Programming Interface): a way for one program to talk to another over the network. When your browser loads a page, it is asking a server for a document. When a program asks a server for data or an action, it is calling an API. The server publishes a list of addresses (called endpoints) that accept requests, for example
/login/oauth/token. - HTTP request: the message a browser or program sends to a server. It has a method (such as
GETto fetch something orPOSTto send something), a path (the endpoint), optional headers (extra information such as who you are), and sometimes a body (data you are sending). - Token: a short string that stands in for proof of identity or permission, like a cloakroom ticket. You show the ticket, you get your coat; you do not need to prove who you are again. A token is valuable: anyone who has it can act as its owner until it expires.
- OAuth2: a standard way for one website to let another website act on your behalf without sharing your password. The "authorization-code flow" is its most common pattern: you consent, you get a code, the code is swapped for a token.
- Authorization code: the one-time voucher in that flow. It is short-lived on purpose, because it travels through the browser where it might be seen.
- Bridge access token: in this system, the intermediate token you get after swapping the code. It is not yet a Taskcluster credential, but it can be converted into one.
- Credentials: the actual key pair (a
clientIdand anaccessToken) that Taskcluster accepts when you ask it to run a job. - Scope: a permission, such as "may start builds for Firefox". A token carries a set of scopes that were agreed to at login.
- Expiry: the moment after which something is no longer valid. A code that expires after ten minutes should be useless after ten minutes.
- Replay: sending the same message again. In security, a "capture-replay" attack means an attacker records a valid message and sends it again later to get the same effect.
- Cron job: a task a computer runs on a schedule, for example once a day. It is not instant; it waits for its next run.
- Database row: a database stores information in tables, like a spreadsheet. Each line is a row. Here, each authorization code is a row in a table called
authorization_codes. - Column: a field in that table, for example
expiresorclient_details. - Commit: a saved snapshot of a code project. The report pins one exact snapshot so the test is reproducible.
- Mocha: a tool for running automated tests in JavaScript projects. A test is a small program that checks whether the software behaves as expected.
- Proof of concept (PoC): a small demonstration that proves a bug is real, without causing harm.
- RFC 6749: the official document that describes how OAuth2 should work. Section 4.1.2 is the part about authorization codes.
Context: what Taskcluster is and where the bug lives
Taskcluster is Mozilla's task execution platform: it runs jobs. Its web-server component exposes an OAuth2 login flow so that outside identity providers can be bridged into Taskcluster credentials. The flow follows the familiar authorization-code pattern:
- A user is sent to
GET /login/oauth/authorizeand consents. - The user receives an authorization code.
- The client exchanges that code at
POST /login/oauth/tokenfor a bridge access token. - The bridge token is converted into Taskcluster credentials at
GET /login/oauth/credentials.
The report concerns firefox-ci-tc.services.mozilla.com, the Firefox-CI deployment of Taskcluster. The relevant code lives in services/web-server/src/servers/oauth2.js. Two defects sit in the same token-exchange handler, at lines 165-199, and a third instance of the same mistake appears in the credentials handler at lines 318-375.
In plain terms: the file oauth2.js is where the login logic is written. A "handler" is the piece of code that runs when a particular endpoint is called. The exchange handler is the code that runs when someone calls /login/oauth/token. Two separate mistakes are in it, and the same kind of mistake appears again in the handler for /login/oauth/credentials.
Setup: how the researcher reproduced it
The proof of concept runs against unmodified Taskcluster source at commit [redacted] on the default branch main. "Unmodified" matters: the researcher did not change the product to make the bug appear. It extends the existing test file services/web-server/test/third_party_test.js and runs through the project's existing Mocha infrastructure. The prerequisites are Node 24.15.0 via nvm, a local Postgres started with Docker Compose, and a test database created inside that container.
Here is what those tools are, briefly. Node is the program that runs JavaScript outside a browser; nvm is a tool that switches between Node versions. Postgres is a database server. Docker Compose starts pre-packaged software (here, Postgres) in an isolated container so it does not interfere with your computer. yarn installs the libraries the project depends on.
$ source ~/.nvm/nvm.sh && nvm use 24.15.0
$ cd taskcluster && yarn install
$ docker compose up -d postgres
$ docker exec taskcluster-postgres-1 psql -U postgres -c "CREATE DATABASE \"taskcluster-test\";"
$ cd services/web-server
$ TEST_DB_URL=postgresql://postgres@localhost:5432/taskcluster-test NODE_ENV=test \
yarn mocha --grep "TC-002" test/third_party_test.js
Line by line:
source ~/.nvm/nvm.sh && nvm use 24.15.0loads the nvm helper script into the current shell and switches to Node version 24.15.0, the version the project expects. Using the wrong version can cause confusing failures, so the version is pinned.cd taskcluster && yarn installmoves into the project folder and downloads all the libraries the project needs. Without this, nothing can run.docker compose up -d postgresstarts a Postgres database in the background (-dmeans detached, so the terminal is not blocked). The test needs a database to store codes and tokens.docker exec taskcluster-postgres-1 psql -U postgres -c "CREATE DATABASE \"taskcluster-test\";"runs a command inside the running database container.psqlis the Postgres command-line client,-U postgressays to connect as thepostgresuser, and-cpasses a single SQL statement. That statement creates an empty database calledtaskcluster-test, so the test starts from a clean slate and cannot damage real data.cd services/web-servermoves into the web-server part of the project, where the test lives.- The last command sets two environment variables and runs Mocha.
TEST_DB_URL=postgresql://postgres@localhost:5432/taskcluster-testtells the test where the database is (on the local machine, port 5432, databasetaskcluster-test).NODE_ENV=testtells the code it is running in test mode.yarn mocha --grep "TC-002" test/third_party_test.jsruns the Mocha test runner on the filetest/third_party_test.js, but only the test whose name containsTC-002, so the researcher does not have to wait for the whole suite.
The test uses the test-code-whitelisted registered OAuth client that ships in services/web-server/config.yml.
Finding it: reading the code
The researcher read the exchange handler and saw that it validates redirect_uri and the existence of the code, mints a bridge access token, and returns. It never deletes or otherwise consumes the authorization_codes row. That contradicts RFC 6749 §4.1.2, which requires single-use codes:
The client MUST NOT use the authorization code more than once. If an authorization code is used more than once, the authorization server MUST deny the request...
What this means: redirect_uri is the address the browser should be sent back to after login. Checking it is a good thing, because it stops a code being delivered to the wrong place. But checking that the code exists and that the address matches is not the same as marking the code as used. The row stays in the database, so the same code can be presented again and again. The standard says the server must refuse the second attempt; this server does not.
The second defect is an expiry check against the wrong column. The check at line 66 reads entry.client_details.expires, which is the requested lifetime of the resulting Taskcluster credentials, capped by the registered OAuth client's maxExpires (for example "1 year" in the test config). The authorization-code row's intended 10-minute lifetime is stored in entry.expires, set at line 33 to taskcluster.fromNow('10 minutes'), and that value is never consulted at exchange time. Expired codes therefore remain usable until the daily cleanup-expire-auth-codes cron deletes them, defined at services/web-server/procs.yml:20-24.
In plain words: the database row for a code has two different expiry values. One says how long the code itself lives (ten minutes). The other says how long the credentials you are asking for should live (up to a year). The code checks the second one when it should check the first. So a code that should have died after ten minutes keeps working, and the only thing that eventually removes it is a cleanup job that runs once a day. That means the practical lifetime is measured in hours, not minutes.
The same expiry-column mismatch repeats in the bridge-token-to-credentials handler at oauth2.js:318-375 (/login/oauth/credentials), which checks entry.client_details.expires rather than the access-token row's entry.expires. The same confusion between "how long the thing I am asking for lasts" and "how long the thing I am holding lasts" appears a second time.
Exploitation: proving it end to end
The PoC is a Mocha test that drives the full chain against the test database. Running it produces:
services/web-server/test/third_party_test.js
unit
✔ TC-002 (PoC): authorization code is reusable in violation of RFC 6749 §4.1.2
1 passing
This output is the test runner saying: the file third_party_test.js was run, the group called unit was entered, the test named TC-002 (PoC): authorization code is reusable in violation of RFC 6749 §4.1.2 passed (the tick), and one test passed in total. A passing test here means the bad behaviour was observed, because the test is written to assert that the replay succeeds.
Step 1: obtain an authorization code
The test authorizes a code through GET /login/oauth/authorize using the test-code-whitelisted registered client from services/web-server/config.yml. This is the consent step of the flow; the result is an authorization code.
Why this step: you cannot test what happens to a code without a code. Using the built-in test client means the test does not depend on a real outside login provider, so it runs the same way on any machine.
Step 2: first exchange
The code is exchanged through POST /login/oauth/token. The test asserts a 200 response and records the returned bridge access token as token A.
Why this step: this is the legitimate use of the code. A 200 is the HTTP status code for "OK", so the test is checking that the normal path works before trying anything unusual. Token A is kept so it can be compared with what comes next.
Step 3: replay the same code
The identical code is sent through POST /login/oauth/token a second time. The test asserts 200 and records token B, and asserts that token A != token B. A second successful exchange of a code that should already be spent is the RFC 6749 §4.1.2 violation: the server neither consumed the row nor denied the replay.
Why this step: this is the heart of the bug. If the server followed the standard, the second request would be refused, probably with an error status. Instead it returns 200 and a different token. The comparison token A != token B rules out the server simply handing back the same token again; it is genuinely minting a new one from a code that should be dead.
Step 4: convert the replayed token to credentials
The test calls GET /login/oauth/credentials with the replayed bridge token:
Authorization: Bearer <token B>
This is an HTTP header. Authorization is the header name servers use to receive proof of identity. Bearer is the scheme name, meaning "whoever bears (carries) this token is treated as its owner". <token B> is a placeholder for the token obtained in the previous step; the real value is a long string. The header is the digital equivalent of showing the cloakroom ticket.
It asserts 200 and Taskcluster credentials containing clientId and accessToken in the original user's identity. The local PoC demonstrates the chain authorize, first exchange, replay exchange, credentials conversion succeeds end to end with no error.
Why this step matters: a bridge token on its own is not the prize. The prize is the Taskcluster credential pair, because that is what actually lets someone run jobs. The test proves that a token minted from a replayed code converts into credentials belonging to the original user, with no error along the way.
The full test patch and the Mocha pass log were attached to the report.
Root cause: why it happens
There are two independent mistakes in the exchange handler, plus a repeat of the second one elsewhere.
- No consumption of the code. The handler checks that the code exists and that
redirect_urimatches, then mints a token. Nothing marks theauthorization_codesrow as used, so every replay of the same code mints another bridge token for the same user. Think of a shop that checks your voucher is genuine but never punches a hole in it, so you can use it all day. - Wrong expiry column. The expiry check reads
entry.client_details.expires, the lifetime of the credentials being requested (bounded by the client'smaxExpires), instead ofentry.expires, the 10-minute lifetime of the code itself. The code's real expiry is only enforced indirectly, when the dailycleanup-expire-auth-codescron removes the row. It is like a bouncer checking the closing time of the bar instead of the expiry date on your ticket. - Same mismatch in the credentials handler.
/login/oauth/credentialschecksentry.client_details.expiresrather than the access-token row'sentry.expires, so the bridge token's own lifetime is not what gates conversion.
Existing defences did not help because neither the single-use requirement nor the code lifetime was enforced at the point where the code is redeemed. The scheduled deletion leaves a window that extends to many hours past the intended 10-minute lifetime. A scheduled cleanup is a safety net, not a lock: between runs, anything that should have expired is still there.
Impact: what an attacker could do
An attacker who captures an authorization code can replay POST /login/oauth/token to mint fresh bridge access tokens bound to the original user's identity, identity_provider_id and consented scope set. With such a token they can call GET /login/oauth/credentials and receive Taskcluster credentials in the original user's identity.
In plain words: the attacker does not need the user's password. A single captured code is enough to keep producing tokens, and those tokens become real credentials that act as the victim.
The auth service's create_client behaviour (db/versions/0041.yml:343-404) returns the existing client's access token when called within a 15-minute idempotency window; outside that window the bridge token can still mint credentials if the attacker is the first to convert the bridge token to credentials. "Idempotency" means doing the same operation twice has the same effect as doing it once; here, for fifteen minutes, converting the same token again returns the same credential rather than a new one. After that window, the first person to convert the token gets credentials, which is why timing matters to an attacker.
Replay is possible arbitrarily often within a practical window bounded by two things: the value of client_details.expires and the daily cleanup cron. With the documented default of maxExpires up to 1 year and authorizationCodeExpirationDelay: '- 10 minutes', that window extends to many hours past the intended 10-minute code lifetime.
Capturing the code in the first place requires one of several narrow conditions, as the report lists them: a referer leak, logs on the redirect page, a TLS-inspecting proxy, or access to browser history on the redirect page. Briefly: a referer leak is when a browser tells the next website which page you came from, and that address accidentally contains the code. Logs on the redirect page means the code ends up written into a server's log file. A TLS-inspecting proxy is a middlebox that decrypts and re-encrypts secure traffic, for example in a corporate network, and can therefore see the code. Browser history can contain the full address, code included, if the code appeared in the address bar. None of these is trivial, which is why the report calls them narrow.
For firefox-ci-tc.services.mozilla.com, the resulting credentials carry the user's Firefox-CI scopes, which directly affects the Firefox build CI integrity boundary. A Taskcluster identity holding Firefox-CI scopes, such as mozilla-employee roles, is a privileged role, so replaying a code authorized by such an identity is a meaningful integrity exposure on a Critical Site asset. "Integrity" here means trustworthiness: if someone can act as a build engineer, they may be able to influence what gets built and shipped, not merely read data.
Fix: how to close it
The recommendation is to consume the authorization code atomically during token exchange. "Atomically" means as a single indivisible step: either the code is found, deleted and returned, or nothing happens. That prevents two simultaneous requests from both succeeding. Add a database function such as consume_authorization_code(code, client_id, redirect_uri) that performs a single statement equivalent to:
DELETE FROM authorization_codes
WHERE code = code_in
AND client_id = client_id_in
AND redirect_uri = redirect_uri_in
AND expires > now()
RETURNING code, client_id, redirect_uri, identity, identity_provider_id, expires, client_details;
Line by line:
DELETE FROM authorization_codessays: remove a row from the table that stores authorization codes.WHERE code = code_inrestricts the deletion to the row whose code matches the one supplied.AND client_id = client_id_inadds that the client must match too, so a code issued to one application cannot be redeemed by another.AND redirect_uri = redirect_uri_inadds that the return address must match, preserving the existing check.AND expires > now()adds that the row must not already be expired, so an old code is not accepted even if it is still present.RETURNING code, client_id, redirect_uri, identity, identity_provider_id, expires, client_details;makes the database hand back the deleted row's contents. This is the clever part: the delete and the read happen in one operation, so there is no gap in which a second request could slip through.
The returned row should be the only gate for creating an access token, so a second attempt finds nothing to return and is denied. Apply the same correction to /login/oauth/credentials: check the access-token row's top-level entry.expires rather than entry.client_details.expires.
Optionally, store a back-reference from access tokens to the originating authorization code and revoke or invalidate already-minted tokens when replay is detected, matching RFC 6749's "SHOULD revoke" clause in §4.1.2. A back-reference is simply a note in the token's row saying which code created it, so the system can find and cancel tokens if it later sees the same code used twice.
Variants to test: where else to look
- Other OAuth2 handlers in the same service. Look for any redemption path that reads a row and then acts on it without a conditional delete or an atomic update. A positive result is two successful redemptions of the same value, with different outputs. In everyday terms: any place that checks a voucher but does not cancel it.
- Expiry checks that read a nested field. Wherever a handler compares
something.client_details.expiresor a similarly nested value, check whether the row's own top-level expiry is what should have been compared. A positive result is a value that still works after its documented lifetime has passed. - Cleanup-cron-only enforcement. If the only thing that removes short-lived secrets is a periodic job, test whether the secret survives past its stated lifetime. A positive result is a successful use of the secret between its nominal expiry and the next cleanup run.
- Idempotency windows in credential minting. The 15-minute
create_clientwindow described here is worth probing on other deployments: check whether a token converted once can be converted again, and whether the second conversion returns the same or a new credential set.
Hunting notes: how to find bugs like this
This class of bug hides in the gap between what a specification requires and what a handler actually enforces. The exchange endpoint is a good place to look because it is short, does the security-relevant work, and is easy to read in full. Signals during recon include OAuth2 endpoints that return a token on every call with the same code, and code paths where an expiry is read from a nested object rather than the row itself. The researcher showed impact by building an end-to-end test inside the project's own test suite, running it against unmodified source at a pinned commit, and asserting each step: 200 on the first exchange, 200 on the replay with a different token, and 200 on the credentials conversion in the original user's identity.
Glossary
- API (Application Programming Interface): a defined way for one program to ask another program to do something over a network.
- Endpoint: a specific address on a server that accepts requests, such as
/login/oauth/token. - HTTP request: the message a browser or program sends to a server, with a method, a path, headers and sometimes a body.
- GET: an HTTP method used to fetch something.
- POST: an HTTP method used to send data and trigger an action.
- Header: extra information attached to an HTTP request, such as who is making it.
- Status code 200: the HTTP code meaning the request succeeded.
- Token: a string that stands in for proof of identity or permission, like a cloakroom ticket.
- OAuth2: a standard for letting one site act on your behalf without sharing your password.
- Authorization-code flow: the common OAuth2 pattern of consent, code, then token exchange.
- Authorization code: a short-lived, single-use voucher issued during that flow.
- Bridge access token: the intermediate token this system issues after exchanging a code, before it becomes Taskcluster credentials.
- Credentials: the
clientIdandaccessTokenpair Taskcluster accepts when running jobs. - Scope: a permission carried by a token, such as the right to start builds.
- Replay: sending a valid message again to get the same effect a second time.
- Capture-replay: an attack where a valid message is recorded and then resent by an attacker.
- Cron job: a task a computer runs automatically on a schedule.
- Database row: one line in a database table, holding one record.
- Column: a named field in a database table, such as
expires. - Commit: a saved snapshot of a code project, identified by a long hash.
- Mocha: a tool for running automated JavaScript tests.
- Proof of concept (PoC): a small demonstration that proves a bug is real.
- RFC 6749: the official specification for OAuth2; section 4.1.2 covers authorization codes.
- Node: the program that runs JavaScript outside a browser.
- nvm: a tool for switching between Node versions.
- Postgres: a database server.
- Docker Compose: a tool that starts packaged software in isolated containers.
- Container: a self-contained environment holding a program and its dependencies.
- yarn: a tool that installs a JavaScript project's libraries.
- Environment variable: a named value passed to a program when it starts, such as the database address.
redirect_uri: the address the browser is sent back to after login.- Idempotency: the property that doing the same operation twice has the same effect as doing it once.
- Atomic: done as a single indivisible step, so nothing can happen halfway through.
- Referer leak: when a browser reveals the previous page's address to the next site, accidentally exposing data in it.
- TLS-inspecting proxy: a middlebox that decrypts and re-encrypts secure traffic, and can therefore read it.
- Integrity: the property of data or systems being trustworthy and unaltered; an integrity exposure means an attacker could influence what is built or shipped.
- Privileged role: an account or identity with powerful permissions, such as
mozilla-employee. - Critical Site asset: a system whose compromise would seriously affect the organisation.
- Revoke: to cancel a token so it no longer works.