Hello,
I was going to open an issue on GitHub, but the issue template directed me here.
I'm very new to Logstash, but noticed something concerning tonight and wanted to ask if the community is aware of this. On failed attempts to hit S3, Logstash is echoing my AWS credentials to the output stream.
I am running a simple pipeline to import data from AWS S3 and move it into an Elasticsearch cluster. I have an input block similar to this:
input {
s3 {
access_key_id => "${S3_KEY}"
secret_access_key => "${S3_SECRET}"
region => "us-east-1"
bucket => "${BUCKET_NAME}"
interval => 2
codec => "json"
}
}
I am using environment variables to configure this pipeline. While running, I hit an error because some of the files in that bucket have different security settings than I'd expected. This error is 100% my fault and not a bug I am reporting, but I was surprised to see a message like this in the Logstash output:
[2018-03-18T21:14:04,592][ERROR][logstash.pipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::S3 access_key_id=>"MY_ACCESS_KEY", secret_access_key=>"MY_SECRET_KEY", region=>"us-east-1", bucket=>"BUCKET_NAME", interval=>2, codec=><LogStash::Codecs::JSON id=>"json_31c4beff-0d8c-4cbe-b7b6-efb3aaa2b927", enable_metric=>true, charset=>"UTF-8">, id=>"c763ef7921e0bae8eb2e63f686735aa3846e7d644f317ee589d7123646c3e831", enable_metric=>true, delete=>false, temporary_directory=>"/var/folders/ww/6m7gkcds5sn_5b3bgl6_d3xcpm028j/T/logstash">
Error: Access Denied
Exception: Aws::S3::Errors::AccessDenied
In the output above, I've manually added the literal text MY_ACCESS_KEY
, MY_SECRET_KEY
, and BUCKET_NAME
so I am not disclosing too much in this post. However...my keys were printed in the actual output!
Printing literal credentials to stdout is a security risk. Can someone explain to me why the pipeline is evaluated before being printed (instead of printing the literal text in the Logstash config)? I tried looking through the code but couldn't quite understand how the string interpolation there is working.
Thanks very much!
-James