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 audit issue logging by default peer address #1485

Merged
merged 9 commits into from
May 15, 2020
Merged

Fix audit issue logging by default peer address #1485

merged 9 commits into from
May 15, 2020

Conversation

pando85
Copy link
Contributor

@pando85 pando85 commented May 2, 2020

By default log format include remote address that is taken from headers.
This is very easy to replace making log untrusted.

Changing default log format value %a to peer address we are getting
this trusted data always. Also, remote address option is maintianed and
relegated to %{r}a value.

Related kanidm/kanidm#191.

pando85 and others added 2 commits May 2, 2020 21:40
By default log format include remote address that is taken from headers.
This is very easy to replace making log untrusted.

Changing default log format value `%a` to peer address we are getting
this trusted data always. Also, remote address option is maintianed and
relegated to `%{r}a` value.

Related  kanidm/kanidm#191.
@robjtede
Copy link
Member

robjtede commented May 3, 2020

So if I have this right, you take issue with the fact that the current %a replacement uses the derived "Client IP" which could be taken from X-Forwarded-For headers which are obviously easy to replace if your proxy is misconfigured (or you don't have a proxy and the header is being sent manually).

There's a couple bits of terminology I want to nail down, document, and be strict to use in the right places.

  • Client Address
  • Peer Address
  • Remote Address

Could you elaborate on the above so there is no confusion in reviewing? Might be worth adding doc comments to the ConnectionInfo fields to describe when and what they are populated with.

@codecov-io
Copy link

codecov-io commented May 3, 2020

Codecov Report

Merging #1485 into master will increase coverage by 0.07%.
The diff coverage is 89.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1485      +/-   ##
==========================================
+ Coverage   47.58%   47.66%   +0.07%     
==========================================
  Files         137      137              
  Lines       12925    12952      +27     
==========================================
+ Hits         6151     6174      +23     
- Misses       6774     6778       +4     
Impacted Files Coverage Δ
src/middleware/logger.rs 74.68% <88.88%> (+1.54%) ⬆️
src/info.rs 92.85% <89.47%> (-0.90%) ⬇️

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 92ce975...50407d3. Read the comment docs.

Change names to avoid naming confusions. I choose this accord to Nginx
variables and
[ngx_http_realip_module](https://nginx.org/en/docs/http/ngx_http_realip_module.html).

Add more specific documentation about security concerns of using Real IP
in logger.
@pando85
Copy link
Contributor Author

pando85 commented May 4, 2020

@robjtede thanks for your comment!
I tried to be more clear about IP meanings choosing Nginx style names.

@robjtede robjtede requested review from a team May 7, 2020 14:53
Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

I think this is a reasonable change, could you also update the changelog?

src/middleware/logger.rs Outdated Show resolved Hide resolved
@pando85
Copy link
Contributor Author

pando85 commented May 9, 2020

@JohnTitor both done.

Must I rebase all changes in one?

@pando85
Copy link
Contributor Author

pando85 commented May 14, 2020

Any update?

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

I missed this, sorry. Thanks!

@JohnTitor JohnTitor merged commit 4fc99d4 into actix:master May 15, 2020
@pando85 pando85 deleted the feature/log-source-ip branch May 15, 2020 06:51
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.

4 participants