Bug 1821999 - [RHEL7.9] Do not log IMDSv2 token values into cloud-init.log
Summary: [RHEL7.9] Do not log IMDSv2 token values into cloud-init.log
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.9
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Eduardo Otubo
QA Contact: Frank Liang
Depends On:
Blocks: 1822343 1850456
TreeView+ depends on / blocked
Reported: 2020-04-08 03:29 UTC by Frank Liang
Modified: 2020-09-29 19:50 UTC (History)
13 users (show)

Fixed In Version: cloud-init-19.4-7.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1822343 (view as bug list)
Last Closed: 2020-09-29 19:48:41 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:3898 0 None None None 2020-09-29 19:50:43 UTC

Description Frank Liang 2020-04-08 03:29:42 UTC
After cloud-init added AWS IMDSv2 support, it saves token values in cloud-init.log. I am suggesting to backport the below patch to change this behavior.
commit 87cd040ed8fe7195cbb357ed3bbf53cd2a81436c
Author: Ryan Harper <ryan.harper>
Date:   Wed Feb 19 15:01:09 2020 -0600

    ec2: Do not log IMDSv2 token values, instead use REDACTED (#219)
    Instead of logging the token values used log the headers and replace the actual
    values with the string 'REDACTED'.  This allows users to examine cloud-init.log
    and see that the IMDSv2 token header is being used but avoids leaving the value
    used in the log file itself.

The current log is like this:
2020-04-07 09:49:34,693 - DataSourceEc2.py[DEBUG]: Fetching Ec2 IMDSv2 API Token
2020-04-07 09:49:34,693 - url_helper.py[DEBUG]: [0/1] open '' with {'url': '', 'headers': {'X-aws-ec2-metadata-token-ttl-seconds': '21600', 'User-Agent': 'Cloud-Init/19.4'}, 'allow_redirects': True, 'method': 'PUT', 'timeout': 1.0} configuration
2020-04-07 09:49:34,705 - url_helper.py[DEBUG]: Read from (200, 56b) after 1 attempts
2020-04-07 09:49:34,705 - DataSourceEc2.py[DEBUG]: Using metadata source: ''
2020-04-07 09:49:34,705 - url_helper.py[DEBUG]: [0/1] open '' with {'url': '', 'headers': {'X-aws-ec2-metadata-token': 'AQAEAKFXG-CkNfREz8EV84ZfvXwKeUOxK01GzrC5DgBd7Z7MzGrNLQ==', 'User-Agent': 'Cloud-Init/19.4'}, 'allow_redirects': True, 'method': 'GET'} configuration
2020-04-07 09:49:34,707 - url_helper.py[DEBUG]: Read from (200, 19b) after 1 attempts

Version-Release number of selected components (if applicable):

RHEL Version:

How reproducible:

Steps to Reproduce:
1. Start a RHEL-7.9  AMI on aws.
2. Check /var/log/cloud-init.log.

Actual results:
token value is saved
Expected results:
No token value saved

Additional info:
- N/A

Comment 19 errata-xmlrpc 2020-09-29 19:48:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: cloud-init security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.