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

Query string encoding bug #24

Closed
IDGuy opened this issue May 29, 2014 · 2 comments
Closed

Query string encoding bug #24

IDGuy opened this issue May 29, 2014 · 2 comments

Comments

@IDGuy
Copy link

IDGuy commented May 29, 2014

I believe there is an issue with the RemoveBewitFromQuery method.

Using the example URL below which contains encoded characters in the query string:

http://www.example.org/test?path=%2Fmovie%2Fcomedy%2F2014

The Hawk.GetBewit method will compute the MAC using the encoded path and query string above. No issues there.

However the Hawk.AuthenticateBewit method when calculating the MAC removes the bewit. In doing so it recreates the query string which removes the encoding so the MAC ends up using an un-encoded path and query string i.e.

test?path=/movie/comedy/2014

This results in a different MAC and therefore a "Bad mac" SecurityException is thrown.

The issue relates to the code below:
Hawk.cs > RemoveBewitFromQuery()
var resultingQuery = string.Join("&", parsedQueryString.Cast().Select(e => e + "=" + parsedQueryString[e]).ToArray());

Changing this to:
var resultingQuery = parsedQueryString.ToString();

Resolves the issue.

@pcibraro
Copy link
Owner

I need to find a better way to parse the query string. parsedQueryString.ToString() does not resolve the problem as HttpUtility.ParseQueryString is lowering all the letters in the URL as well.

pcibraro pushed a commit that referenced this issue May 29, 2014
@pcibraro
Copy link
Owner

Fixed

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

No branches or pull requests

2 participants