The private-token is retracted from the GitLab rails application logs, however it is still contained in NGINX and gitlab-workhorse logs. Can we enable scrubbing of the private token in these logs as well.
This is a security related issue for GitLab.com and Logging to https://log.gitlap.com/app/kibana (marked as confidential for that reason)
I think the real issue here is that we allow these private tokens to be passed as query parameters. That means they can get logged anywhere along the chain. (On gitlab.com that also means HAproxy, for instance.)
Scrubbing these tokens in gitlab-workhorse is doable but it will probably not be pretty. I think the only reasonable way to hide these tokens from NGINX access logs is to stop logging query strings altogether. That would then also be the preferred solution in gitlab-workhorse.
I think the only sane option, if we want this, is to not print the query string in the log at all, both in NGINX and gitlab-workhorse. Which of course does not help any HTTP load balancers higher up the chain (such as HAProxy on gitlab.com).
I can, but I'm on another security issue at the moment so it'll have to wait until that's finished. I'll leave it unassigned but TODO until then, in case someone else wants to grab it in the meantime.
This has come up again as part of the Risk Assessment and is one of the top 10 priorities. I've added this issue to the Risk Assessment as a course of action.
Nick Thomaschanged title from Allow filtering of private-token in NIGNX and gitlab-workhorse to Allow filtering of private-token in NGINX and gitlab-workhorse
changed title from Allow filtering of private-token in NIGNX and gitlab-workhorse to Allow filtering of private-token in NGINX and gitlab-workhorse
We log net/http.RequestURI in a number of places; these can be replaced with Path.
We also log the HTTP Referer header in a few places; it's possible these could include the private token. I'll change those to log the referer without a query string.
I agree with @jacobvosmaer-gitlab that we should stop using the private token in query strings more generally. Its security characteristics are very poor. However, it's still worth cleaning the logs at present, I think.
@nick.thomas Agreed on the token use in query strings. I'd prefer if we didn't completely strip the query strings from referrers and request logs unless it's the only way to do it. There might be useful stuff in there. Is it possible to replace the token with [token] like we do with the Rails logs? Or is it worth the effort?
@briann It's definitely possible, including in NGINX, but I question whether it's worthwhile. Do we often make use of the query strings in debugging sessions?
Essentially, we'd just run a replace of /[\?&]private-token=.*/ on the string before outputting it. It's not very expensive.
Are there other query-string parameters that might be sensitive?
@nick.thomas The CSRF/authenticity_token shows up in request logs a lot and should be considered sensitive.
I just want to make sure that the query string is logged somewhere, with the appropriate filtering. We do use it for security purposes and probably debugging as well. If that's only in NGINX and not anywhere else that's fine. The referrer field is nice to have as well but also doesn't need to be saved in more than one place.
NGINX turns out to be much more difficult to filter, so I propose we just remove the query string from referer and request. We'll have them (filtered) in the workhorse logs.
We're tracking NGINX elsewhere and !165 (merged) is merged, so let's close this.
@briann are you OK for us to mark this issue as non-confidential now? Or do we need to wait until we've got this deployed to gitlab.com and purged historic kibana data?