Skip to content

oauth2-redirect-verifier value聽#1079

Open

Description

@alexdigdir

馃挰 Question here

I am a bit concerned about potential security issues and so I am wondering if the "oauth2-code-verifier" is the hashed version (code challenge) of the plain text Code Verifier?

It it IS hashed, I guess there is no security issue...?
If it is NOT hashed, then it seems like it does not fulfill Oauth2 protocol...? (Im not claiming necessarily, Im asking)
Ref.:
https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#name-authorization-code-grant

Image

Your Environment

  • node version: 22
  • fastify version: 7.8.0
  • os: Linux (docker container running on Mac)

Activity

  1. changed the title [-]Help[/-] [+]oauth2-redirect-verifier value[/+] on Feb 6, 2025
  2. metcoder95 commented on Feb 7, 2025

    @metcoder95
    Member

    Hi @alexdigdir, I'm not fully understanding what are you asking exactly.
    Are you seeking to know if the oauth2-redirect-verifier value has potential security issues?

    Can you elaborate what exactly are you asking for?

  3. alexdigdir commented on Feb 7, 2025

    @alexdigdir
    Author

    Hey @metcoder95

    Certaintly!

    We have a SPA with a backend-for-frontend (BFF) that acts as an OAuth2 client, translating the OIDC provider鈥檚 ID token into a session (via cookies) between the BFF (/api/*) and the SPA.
    Currently, we use @fastify/session with @fastify/oauth2 and @fastify/cookie, but there's an issue:
    Flow:

    1. The SPA checks authentication via the BFF. If unauthenticated, it redirects to the BFF鈥檚 login route (startRedirectPath in OAuthPluginOptions).
    2. The user is redirected to the OIDC provider for login.
    3. On success, the OIDC provider redirects to callbackUri (BFF), which:
    • Extracts the token via getAccessTokenFromAuthorizationCodeFlow
    • Stores it in the session (@fastify/session + connect-redis)
    • Redirects the user back to the SPA with a session cookie

    However, oauth2-code-verifier and oauth2-redirect-state are also set, raising concerns about potential security risks. If they are only needed between the BFF and SPA, we may be able to remove them.
    Given this setup, should we be using @fastify/secure-session instead of @fastify/session for what we are trying to achieve here?

  4. metcoder95 commented on Feb 9, 2025

    @metcoder95
    Member

    There should not be big major concerns towards these headers as they are used for session management rather than actual exchange of the information.

    By default they are set as httpOnly, which will cause browsers to not make it accessible to your SPA.

    If your SPA does not requires cross site cookie sharing, setting the sameSite: 'Strict' will cause the browser to hint the browser only sent back all these cookies if request are sent to the same origin of your SPA.

    Wether use secure-session or session depends on the level of management you want on your session state. I'd recommend to always seek for secure-session unless strict requirement of otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions