IMDSv2 in yum (Amazon Linux 2)

0

Hi,

We're trying to track down and eliminate usage of the old instance metadata service (IMDSv1) on our instances so that we can set the metadata options to require HTTP tokens going forward. Using newer AMIs or updating packages like cloud-init takes care of most of it, but there was still one stubborn case coming from yum.

We have installed yum-3.4.3-158.amzn2.0.4.noarch which seems to be the latest available.
In /usr/lib/python2.7/site-packages/yum/yumRepo.py, in function _get_instance_info it is requesting the INSTANCE_IDENTITY_URI without first generating a token and providing the X-aws-ec2-metadata-token header.

Does anyone know if there is an updated version that supports IMDSv2? Or somewhere I could contribute a patch? Or any other workaround?

Thanks!
-cw

질문됨 4년 전703회 조회
3개 답변
0
수락된 답변

Hi chadawagner, thanks for the report.

Switching your instances to IMDSv2-only will not break yum, since this is an optional code path that has a fallback.

If you want, you can disable this code by setting report_instanceid=no in /etc/yum.repos.d/amzn2-core.repo, which should cause yum to avoid making requests without tokens. We'll work on an update to yum to fix this.

Thanks for using Amazon Linux!

답변함 4년 전
0

Thanks! I won't worry about it then, good to know. I'll turn off the instance reporting so that I can continue to monitor the MetadataNoToken metric in CloudWatch.

답변함 4년 전
0

Hi,
Unfortunately the "report_instanceid=no" setting doesn't seem to be disabling it. I'll go ahead and patch my local yumRepo.py file to disable the tokenless queries.

Edit: oops, I had missed the amzn2-graphics.repo config file on GPU instance. That ought to do it...

Edited by: chadawagner on Aug 12, 2020 10:05 PM

답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠