RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.9
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Eduardo Otubo
QA Contact: Frank Liang
URL:
Whiteboard:
Depends On:
Blocks: 1822343 1850456
TreeView+ depends on / blocked
 
Reported: 2020-04-08 03:29 UTC by Frank Liang
Modified: 2024-11-20 07:51 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)
Environment:
Last Closed: 2020-09-29 19:48:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
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 'http://169.254.169.254/latest/api/token' with {'url': 'http://169.254.169.254/latest/api/token', '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 http://169.254.169.254/latest/api/token (200, 56b) after 1 attempts
2020-04-07 09:49:34,705 - DataSourceEc2.py[DEBUG]: Using metadata source: 'http://169.254.169.254'
2020-04-07 09:49:34,705 - url_helper.py[DEBUG]: [0/1] open 'http://169.254.169.254/2016-09-02/meta-data/instance-id' with {'url': 'http://169.254.169.254/2016-09-02/meta-data/instance-id', '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 http://169.254.169.254/2016-09-02/meta-data/instance-id (200, 19b) after 1 attempts

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

RHEL Version:
RHEL-7.9(cloud-init-19.4-3.el7.x86_64)

How reproducible:
100%

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.

https://access.redhat.com/errata/RHSA-2020:3898


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