Skip to content

feat(aws): CQ Policies to Validate IMDSv2 Usage and Enforcement across EC2, Lightsail, and AMIs#2807

Merged
kodiakhq[bot] merged 5 commits intocloudquery:mainfrom
jsonpr:2646-queries-for-aws-imdsv2
Oct 14, 2022
Merged

feat(aws): CQ Policies to Validate IMDSv2 Usage and Enforcement across EC2, Lightsail, and AMIs#2807
kodiakhq[bot] merged 5 commits intocloudquery:mainfrom
jsonpr:2646-queries-for-aws-imdsv2

Conversation

@jsonpr
Copy link
Copy Markdown
Contributor

@jsonpr jsonpr commented Oct 13, 2022

Summary

To help customers with determining IMDSv2 usage and compliance, this PR includes a new policy and queries to consolidate results across the following 3 queries for IMDSv2:

  • IMDSv2 check for EC2 instances (existing)
  • IMDSv2 check for Lightsail instances (new)
  • IMDSv2 Requirement check for AMIs (new)

Validation of AMIs works for now. I'm following up with AWS on this check.

This is a standalone policy outside of frameworks and while it may not be the future location for useful queries and consolidation of queries, I left it as a standalone policy for now and we can revisit how to structure and organize future policies and queries like this.

This follows up our addition of IMDSv2 fields for Lightsail and AMIs (EC2 already existed) for the recent IMDSv2 AWS releases:

Tests include both positive and negative test cases for each of the checks above and validation in the aws_policy_results from running the IMDSv2 policy and validating in tables for aws_ec2_instances, aws_ec2_images, and aws_lightsail_instances.

#2646

@cq-bot cq-bot added the aws label Oct 13, 2022
@jsonpr jsonpr changed the title CQ Policies to Validate IMDSv2 Usage and Enforcement across EC2, Lightsail, and AMIs feat(aws): CQ Policies to Validate IMDSv2 Usage and Enforcement across EC2, Lightsail, and AMIs Oct 13, 2022
\ir foundational_security/policy.sql
\ir public_egress/policy.sql
\ir publicly_available/policy.sql
\ir imds_v2/policy.sql No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure if we want to run this policy on every invocation...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm open to either running it at invocation of the broader policies_v1 policy or standalone within imds_v2. Went back and forth on that decision and ultimately, I initially left it in under policies_v1/policy.sql for completeness of running the rest of the queries, including public_egress, publicly_available, etc.

Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

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

LGTM

@yevgenypats yevgenypats added the automerge Automatically merge once required checks pass label Oct 14, 2022
@kodiakhq kodiakhq bot merged commit 31d4f79 into cloudquery:main Oct 14, 2022
kodiakhq bot pushed a commit that referenced this pull request Oct 16, 2022
🤖 I have created a release *beep* *boop*
---


## [3.0.0](plugins-source-aws-v2.5.2...plugins-source-aws-v3.0.0) (2022-10-16)


### ⚠ BREAKING CHANGES

* More tag cleanup (#2837)

### Features

* **aws:** CQ Policies to Validate IMDSv2 Usage and Enforcement across EC2, Lightsail, and AMIs ([#2807](#2807)) ([31d4f79](31d4f79))
* **aws:** Glacier resources ([#2703](#2703)) ([34e9f61](34e9f61)), closes [#2583](#2583)


### Bug Fixes

* **aws:** Clean up tag fields ([#2776](#2776)) ([d071a0e](d071a0e))
* **deps:** Update plugin-sdk for aws to v0.13.8 ([#2848](#2848)) ([14e2571](14e2571))
* More tag cleanup ([#2837](#2837)) ([e781491](e781491)), closes [#2836](#2836)
* Update endpoints ([#2831](#2831)) ([a3b289c](a3b289c))
* Update endpoints ([#2890](#2890)) ([2d3b885](2d3b885))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
@jsonpr jsonpr deleted the 2646-queries-for-aws-imdsv2 branch February 9, 2023 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants