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

fix double url encoding in path #51

Merged
merged 3 commits into from
Feb 8, 2023
Merged

Conversation

tarunKoyalwar
Copy link
Member

Proposed Changes

  • Bump utils v0.0.4 -> v0.0.7
  • Adds .Prepare() method which applies a hot patch that prevents double url encoding

closes #50

@tarunKoyalwar
Copy link
Member Author

Current Patch

If path contains url encoded chars -> decode them and pass it to http.Request -> http.Request internally re-encodes them

EdgeCase

  • integrity of percent encoding payload is not guaranteed since encoding is done internally (rarecase)

What is Percent Encoding ??

  • in url encoding . if special character (ex: space or =) that are reserved in RFC are found it converts them to %xx this is url encoding
  • in percent encoding . all characters (even if they are not reserved ) are converted to %xx
    Ex: A is not a reserved character but in percent encoding it is written as %41 .
  • so if url is scanme.sh/%41 integrity is not preserved and is converted to scanme.sh/A
  • Above mentioned is a rare case but normal payloads like
    scanme.sh/%20%2e%0a remains the same (edited)

Note

  • payload integrity is only guaranteed in unsafe raw requests

@tarunKoyalwar tarunKoyalwar self-assigned this Feb 6, 2023
@tarunKoyalwar
Copy link
Member Author

$ https://scanme.sh/%00/path?param=true

GET /%00/path?param=true HTTP/1.1
Host: scanme.sh
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip

Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - Few suggestions:

  • If the .Prepare() should be called before sending the request out, we should probably make a note in the README.md
  • Unrelated to this PR: move the example into a go file and add the link to it in the readme (eventually adding the prepare method if necessary)

@Mzack9999 Mzack9999 merged commit ebd3857 into main Feb 8, 2023
@Mzack9999 Mzack9999 deleted the issue-50-double-encoding branch February 8, 2023 20:47
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

Successfully merging this pull request may close these issues.

avoid double url encoding in path
2 participants