Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Handling of Scopes with Special Character "|" in scp Claim #3829

Open
5 tasks done
Ajayn84 opened this issue Sep 2, 2024 · 2 comments
Open
5 tasks done
Labels
bug Something is not working.

Comments

@Ajayn84
Copy link

Ajayn84 commented Sep 2, 2024

Preflight checklist

Ory Network Project

No response

Describe the bug

When using a scope that includes the special character "|" (e.g., A|B), we expect the scp claim in the access token to contain the scope as a single string, i.e.,["A|B"]. However, the actual result is that the scope is split into separate elements, resulting in
["A", "B"]
Note: The scopes in the access token are returned fine i.e as ["A|B"] for client credentails grant type.
But when the grant type is "authorization_code" and there is a consent flow involved, it gives scope in access token as ["A", "B"]

Reproducing the bug

  1. Create a client having scope with the special character "|", such as "A|B".
  2. Perform oauth2 login with hydra , which involves consent flow
  3. Request an access token with this scope.
  4. Inspect the scp claim in the generated access token.

Relevant log output

No response

Relevant configuration

No response

Version

2.2

On which operating system are you observing this issue?

None

In which environment are you deploying?

Docker

Additional Context

Looking at the scopes stored in hydra_client table, the scopes are stored space separated, but in hydra_oauth2_access table these are stored using "|", might be resulting into this issue

@Ajayn84 Ajayn84 added the bug Something is not working. label Sep 2, 2024
@Ajayn84
Copy link
Author

Ajayn84 commented Sep 19, 2024

After a bit of digging, have found the issue to be during persisting the scopes in some tables we are using "|" (pipe) as the delimiter. below are the code references

Scopes: strings.Join(r.GetRequestedScopes(), "|"),
and
RequestedScope: stringsx.Splitx(r.Scopes, "|"),

If we escape and unescape using some logic like below , then it might resolve this issue
image
image
image

@Ajayn84
Copy link
Author

Ajayn84 commented Sep 24, 2024

Based on inputs from slack channel from @tacurran ,have used url escape and unescape, which does resolve the issue
image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant