iris-contrib / iris-contrib/middleware

CSRF Failing due to Context.Request().URL not containing host

Open
#64 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
239
Forks
89
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Hello,
After playing with CSRF & HTTPS, it seems that Context.Request().URL is not correctly filled, hence failing the referrer check at that line:

			valid := sameOrigin(ctx.Request().URL, referer)

To Reproduce
Steps to reproduce the behavior:

  1. Print the Context.Request().URL.Scheme or .Host when inside a middleware

Expected behavior
We should get part of the URL depending on below schema:
scheme://host.domain:port/path/to/request

actually we're only getting the path part
/path/to/request

Screenshots
see attached screenshot if it helps
ctx.Request().URL showing the path
issue_csrf

trying to query ctx.Request().URL.Host
issue_csrf

Desktop (please complete the following information):

  • Client is running Windows 10,
  • Server is running Raspbian 10,

iris.Version

  • e.g. v12.2.0-alpha

Additional context
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the CSRF referrer check where sameOrigin(ctx.Request().URL, referer) is called, then reproduce the request while inspecting Context.Request().URL.Scheme and Host. Compare the observed URL with the expected scheme://host.domain:port/path/to/request form. Done means the URL contains the information required for the referrer check and the CSRF behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.