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

Support secure cookie for csrf-token #3839

Merged
merged 2 commits into from
May 21, 2018

Conversation

AleksandrBulyshchenko
Copy link
Contributor

Fixes #1734

Currently SetCookie for csrf has secure hardcodded to false.
This passes security argument to cookie creation and set it by COOKIE_SECURE config var.

@thehowl
Copy link
Contributor

thehowl commented Apr 23, 2018

Thank you for your pull request! And thanks for spotting the problem - I created #3833 yesterday (perhaps you didn't see it?). In any case, we should not modify vendor dependencies directly - we should try to modify the upstream repo first then pull it on Gitea (and Unknwon seems to be in the part of the year where he's actually active on the internet, so if you make PRs they have a chance to be merged).

Can you please do it on that repo and then pull the changes with Govendor?

@bkcsoft bkcsoft added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 23, 2018
@lafriks
Copy link
Member

lafriks commented Apr 23, 2018

Yes, first PR in go-macron should be submitted and only than when it's merged we can do govendor fetch to update dependency from upstream

@AleksandrBulyshchenko
Copy link
Contributor Author

@thehowl,
Sorry for the mess.

Can you please do it on that repo and then pull the changes with Govendor?

I've created go-macaron/csrf#7

@lunny lunny added this to the 1.5.0 milestone Apr 24, 2018
@lunny lunny added the topic/security Something leaks user information or is otherwise vulnerable. Should be fixed! label Apr 24, 2018
@thehowl
Copy link
Contributor

thehowl commented Apr 29, 2018

@AleksandrBulyshchenko upstream PR seems to have been merged. Can you update deps with govendor on this PR?

Many thanks!

@AleksandrBulyshchenko
Copy link
Contributor Author

@thehowl,
I've updated the PR with fetched go-macaron/csrf

But as I can see build verification has failed - probably it requires projects in GOPATH on build server to be in sync.

@lafriks
Copy link
Member

lafriks commented Apr 30, 2018

did you use govendor fetch github.com/go-macaron/csrf?

@AleksandrBulyshchenko
Copy link
Contributor Author

@lafriks,

did you use govendor fetch github.com/go-macaron/csrf?

yes, exactly

@techknowlogick
Copy link
Member

@AleksandrBulyshchenko The project is now using dep to manage dependencies. Could you update this PR to match? If you are unable (perhaps you don't have time) let us know and we can submit a new PR on your behalf.

cc: @sapk

Update github.com/go-macaron/csrf with dep to revision 503617c6b372
to fix issue of csrf-token security.

This update includes following commits:
- Add support for the Cookie HttpOnly flag
- Support secure mode for csrf cookie

Signed-off-by: Aleksandr Bulyshchenko <[email protected]>
@AleksandrBulyshchenko
Copy link
Contributor Author

  • Rebased onto master.
  • Updated github.com/go-macaron/csrf with dep instead of govendor.

@bkcsoft bkcsoft added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 21, 2018
@codecov-io
Copy link

Codecov Report

Merging #3839 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3839      +/-   ##
==========================================
+ Coverage   20.05%   20.06%   +<.01%     
==========================================
  Files         153      153              
  Lines       30344    30122     -222     
==========================================
- Hits         6086     6044      -42     
+ Misses      23345    23168     -177     
+ Partials      913      910       -3
Impacted Files Coverage Δ
models/issue_assignees.go 27.84% <0%> (-4.18%) ⬇️
models/issue_user.go 72% <0%> (-0.73%) ⬇️
models/user.go 23.58% <0%> (-0.33%) ⬇️
models/issue_milestone.go 56.5% <0%> (-0.28%) ⬇️
models/release.go 0% <0%> (ø) ⬆️
routers/user/profile.go 0% <0%> (ø) ⬆️
models/webhook_slack.go 0% <0%> (ø) ⬆️
models/webhook_dingtalk.go 0% <0%> (ø) ⬆️
models/repo.go 17.89% <0%> (+0.04%) ⬆️
models/pull.go 17.27% <0%> (+0.09%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31067c0...c8d7625. Read the comment docs.

@bkcsoft bkcsoft added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 21, 2018
@lafriks lafriks merged commit ee878e3 into go-gitea:master May 21, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/security Something leaks user information or is otherwise vulnerable. Should be fixed!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COOKIE_SECURE doesn't flag _csrf cookie as 'Secure'
7 participants