Do not add auth and cookie header when redirecting
cdenneen opened this issue · 2 comments
Since archive is implementing it's own HTTP client PuppetX::Bodeco::Util
for http downloads then the fix for PUP-11188 (puppetlabs/puppet@9a8d3ef) needs to be implemented here as well or need to move away from this library in favor of the default Puppet::Network::HTTP
.
The underlying problem in an example is JFrog Cloud will redirect authenticated header/cookie information from the session to the s3 bucket for download. The s3 bucket only needs the Signature that JFrog will provide based on the storage configuration it has not the session/auth from the client -> JFrog part.
Passing this info on from the client auth is potentially a security risk but causes the client to fail to download due to more than one auth being sent:
Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified
puppet-archive/lib/puppet_x/bodeco/util.rb
Lines 86 to 118 in 2f4cb0f
since generate_request
is request.basic_auth(@username, @password) if @username && @password
regardless if the initial request or a redirect the username/password is getting passed on to the redirection which leads to potential leak of credentials but larger issue is any redirect to something like an s3 bucket will have a signature in the redirect and can't have additional basic auth or causes the Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified
error.