Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Verify ec2 instance identity doc before using meta-data service #69

Merged
merged 3 commits into from
Aug 20, 2020
Merged

fix(core): Verify ec2 instance identity doc before using meta-data service #69

merged 3 commits into from
Aug 20, 2020

Conversation

ddneilson
Copy link
Contributor

Before using the data from an EC2 instance identity document we should be verifying that the identity document is authentic. This change adds that check.

Testing

Testing was done by deploying an app containing:

    const availabilityZone = props.vpc.availabilityZones[0];

    const ebs = new ec2.Volume(this, 'Ebs', {
      availabilityZone,
      size: cdk.Size.gibibytes(10),
    });

    const fs = new efs.FileSystem(this, 'Efs', {
      vpc: props.vpc,
      removalPolicy: cdk.RemovalPolicy.DESTROY,
    });

    const bastion = new ec2.BastionHostLinux(this, 'Bastion', {
      vpc: props.vpc,
      availabilityZone,
      instanceType: new ec2.InstanceType('t3.small'),
    });

    const mountEbs = new rfdk.MountableBlockVolume(this, {
      blockVolume: ebs,
    });
    const mountEfs = new rfdk.MountableEfs(this, {
      filesystem: fs,
    });

    mountEbs.mountToLinuxInstance(bastion.instance, {
      location: '/mnt/ebs',
    });
    mountEfs.mountToLinuxInstance(bastion.instance, {
      location: '/mnt/efs',
    });

and then checking the cloud-init-output.log on the instance to ensure that the scripts ran correctly to completion.

Also tested the metadata utilities themselves by copying the scripting over to both an AL2 & Ubuntu EC2 instance.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Copy link
Contributor

@grbartel grbartel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just a couple of small comments.

grbartel
grbartel previously approved these changes Aug 19, 2020
Copy link
Contributor

@grbartel grbartel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Contributor

@jusiskin jusiskin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor suggestions here. Otherwise an important security improvement - great work!

@jusiskin jusiskin merged commit 789207c into aws:mainline Aug 20, 2020
@jusiskin jusiskin changed the title fix(core): Verify ec2 instance identity doc before using fix(core): Verify ec2 instance identity doc before using meta-data service Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants