Masking proxy credentials from URL when displayed in system info#37934
Masking proxy credentials from URL when displayed in system info#37934thaJeztah merged 1 commit intomoby:masterfrom
Conversation
|
cc: @thaJeztah |
Codecov Report
@@ Coverage Diff @@
## master #37934 +/- ##
=========================================
Coverage ? 36.09%
=========================================
Files ? 610
Lines ? 45160
Branches ? 0
=========================================
Hits ? 16302
Misses ? 26621
Partials ? 2237 |
thaJeztah
left a comment
There was a problem hiding this comment.
Thanks! Left some comments inline.
While I can see the reason for masking this information (especially in the output of docker info), I have some concerns; this change could be a breaking change for those that use this information (for whatever reason; perhaps automation, or verifying daemon configuration). This information was added a long time ago (since #11125), so there's definitely a chance that people use this.
Masking this information in just docker info / the /info endpoint limits the exposure, but does not prevent this information from leaking in other ways (this config is obtained from their corresponding HTTP(S)_PROXY environment variables); also taking into account that someone with access to the API already effectively is "root" on the host.
Perhaps not an issue, but worth to double check if we anticipate this being a breaking change.
|
Oh, we should update the swagger file as well, and update the description for these fields, to describe that credentials are masked when using the endpoint; Lines 3760 to 3784 in 7bfec8c Also may warrant a mention in the API changelog https://github.com/moby/moby/blob/7bfec8cd80c5e2ce548cd7ccf63a35bf60d802d3/docs/api/version-history.md (although it's not versioned, so not sure how to best describe it there) |
yes, good catch, I will update the swagger |
|
I searched the moby code base and I don't see any place that reads the |
|
@thaJeztah Another note, while testing different URLs variations; The expectation here is that user should encode those type of strings when they configure HTTP(s) Proxy, otherwise, their dial will also fail as the core logic uses the same |
|
Also updated the swagger but not sure how to deal with the history file without having an API version |
Signed-off-by: Dani Louca <[email protected]>
|
It's green! merging |
Signed-off-by: Dani Louca [email protected]
If dockerd is configured to use a proxy https://docs.docker.com/config/daemon/systemd/#httphttps-proxy and if the proxy URL is configured for basic authentication, the
SystemInfo(ex:docker info) shows the full proxy URL, including the credentials.- What I did
This PR masks out the proxy username / password while building the info struct.
To make the solution robust, I used the golang
urlpackage to identify the credentials, replace them with asterisks, and rebuild the URL string.I opted not to use basic strings replacement as it will require to address a bunch of corner cases which makes the solution more complex .
- How I did it
- How to verify it
http://USER:[email protected]:80/by following https://docs.docker.com/config/daemon/systemd/#httphttps-proxydocker info | grep ProxyExpected Results:
Http Proxy: http://*********:*********@proxy.example.com:80/Actual Result:
Http Proxy: http://USER:[email protected]:80/- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)