[Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata suppor…#28285
[Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata suppor…#28285francescayeye merged 6 commits intoelastic:masterfrom francescayeye:Libbeat-Security-Enable-IMDSv2-support
Conversation
|
This pull request does not have a backport label. Could you fix it @aspacca? 🙏
NOTE: |
|
Pinging @elastic/integrations (Team:Integrations) |
|
This pull request does not have a backport label. Could you fix it @aspacca? 🙏
NOTE: |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
|
This pull request is now in conflicts. Could you fix it? 🙏 |
kaiyan-sheng
left a comment
There was a problem hiding this comment.
Overall looks good to me, just several small comments.
| const ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" | ||
| const ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" | ||
| const ec2InstanceIMDSv2TokenTTLValue = "21600" | ||
| const ec2InstanceIMDSv2TokenURI = "/latest/api/token" |
There was a problem hiding this comment.
| const ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
| const ( | |
| ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" | |
| ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
| ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" | |
| ec2InstanceIMDSv2TokenTTLValue = "21600" | |
| ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
| ) |
| "net/http" | ||
|
|
||
| "github.com/elastic/beats/v7/libbeat/logp" | ||
|
|
There was a problem hiding this comment.
remove the empty space
|
|
||
| tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS) | ||
| if err != nil { | ||
| logger.Warnf("error while getting IMDSv2 token: %s. No token in the metadata request will be used.", err) |
There was a problem hiding this comment.
| logger.Warnf("error while getting IMDSv2 token: %s. No token in the metadata request will be used.", err) | |
| logger.Warnf("error when load TLS config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) |
There was a problem hiding this comment.
All the warning log messages are the same in the function. What do you think about adding more detail in the warning messages?
elastic#28285) * [Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata support on aws
…t on aws
Enanchment
What does this PR do?
Fetches IMDSv2 token in
add_cloud_metadataprocessor for AWS and send it with the proper header to the identity url requestWhy is it important?
It adds support for IMDSv2 on AWS enforcing security standard
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
How to test this PR locally
Run any beat built from this adding
add_cloud_metadataprocessor an an EC2 instance with only IMDSv2 enabled and ensure that metadata request doesn't fail with a 401Related issues
Closes #22101
Use cases
Screenshots
Logs