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

Error response doesn't follow spec #8

Closed
danielchatfield opened this issue Jan 7, 2016 · 3 comments
Closed

Error response doesn't follow spec #8

danielchatfield opened this issue Jan 7, 2016 · 3 comments
Assignees
Labels
bug Something is not working.
Milestone

Comments

@danielchatfield
Copy link

I appreciate this is still under heavy development and this is likely just not implemented yet but thought I'd add it here so that it doesn't get lost, library looks really good so far.

As per the spec:

If the request fails due to a missing, invalid, or mismatching
redirection URI, or if the client identifier is missing or invalid,
the authorization server SHOULD inform the resource owner of the
error and MUST NOT automatically redirect the user-agent to the
invalid redirection URI.

Currently the redirect uri is used for all errors except a missing redirect_uri. Potential attack could be a redirect_uri of javascript:evil(); to perform XSS.

@aeneasr
Copy link
Member

aeneasr commented Jan 8, 2016

Nice catch :) But you can be sure that all of AuthorizeRequest's parameters are already validated. This for example is covered here and more specifically here.

But due to your inquiry I found another issue where in fact the AuthorizeRequest will be nil if an error occurs in NewAuthorizeRequest and fosite will most likely panic in WriteAuthError due to a nil pointer. Looks like NewAuthorizeRequest must always return a non-nil value for AuthorizeRequest

@danielchatfield
Copy link
Author

They are validated but then that method returns an error which as per the README is passed to WriteAuthorizeError which then uses the redirect_uri despite it potentially being the reason why validation failed.

authorizeRequest, err := oauth2.NewAuthorizeRequest(ctx, r)
    if err != nil {
       oauth2.WriteAuthorizeError(rw, req, err)
       return
    }

@aeneasr
Copy link
Member

aeneasr commented Jan 8, 2016

Ha! Got it, nice catch!

This should do, right? ErrInvalidRequest is thrown when the redirect uri is invalid:

    if ar.GetRedirectURI().String() == "" || err == ErrInvalidRequest {
        pkg.WriteJSON(rw, rfcerr)
        return
    }

It might be smarter and more transparent making validation explicit:

    if !ar.HasValidRedirectURL() {
        pkg.WriteJSON(rw, rfcerr)
        return
    }

As promised, check the Hall of Fame

@aeneasr aeneasr added the bug Something is not working. label Jan 8, 2016
@aeneasr aeneasr added this to the v0 milestone Jan 8, 2016
@aeneasr aeneasr self-assigned this Jan 8, 2016
@aeneasr aeneasr closed this as completed in 38bacd3 Jan 8, 2016
budougumi0617 added a commit to budougumi0617/fosite that referenced this issue May 10, 2019
Closes ory#8 and introduces shift to new token logic proposed in ory#11
juguhan pushed a commit to juguhan/fosite that referenced this issue Oct 10, 2023
chore: upgrade go-jose dependency
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

2 participants