Example Security Lake queries for Security Hub findings - Amazon Security Lake

Example Security Lake queries for Security Hub findings

Security Hub provides you with a comprehensive view of your security state in AWS and helps you check your environment against security industry standards and best practices. Security Hub produces findings for security checks and receives findings from third-party services.

Here are some example queries of Security Hub findings:

New findings with severity greater than or equal to MEDIUM in the last 7 days

SELECT time, finding, severity FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0_findings WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) AND severity_id >= 3 AND state_id = 1 ORDER BY time DESC LIMIT 25

Duplicate findings in the last 7 days

SELECT finding.uid, MAX(time) AS time, ARBITRARY(region) AS region, ARBITRARY(accountid) AS accountid, ARBITRARY(finding) AS finding, ARBITRARY(vulnerabilities) AS vulnerabilities FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) GROUP BY finding.uid LIMIT 25

All non-informational findings in the last 7 days

SELECT time, finding.title, finding, severity FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE severity != 'Informational' and eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) LIMIT 25

Findings where the resource is an Amazon S3 bucket (no time restriction)

SELECT * FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE any_match(resources, element -> element.type = 'amzn-s3-demo-bucket') LIMIT 25

Findings with a Common Vulnerability Scoring System (CVSS) score greater than 1 (no time restriction)

SELECT * FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE any_match(vulnerabilities, element -> element.cve.cvss.base_score > 1.0) LIMIT 25

Findings that match Common Vulnerabilities and Exposures (CVE) CVE-0000-0000 (no time restriction)

SELECT * FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE any_match(vulnerabilities, element -> element.cve.uid = 'CVE-0000-0000') LIMIT 25

Count of products that are sending findings from Security Hub in the last 7 days

SELECT metadata.product.feature.name, count(*) FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) GROUP BY metadata.product.feature.name ORDER BY metadata.product.feature.name DESC LIMIT 25

Count of resource types in findings in the last 7 days

SELECT count(*), resource.type FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 CROSS JOIN UNNEST(resources) as st(resource) WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) GROUP BY resource.type LIMIT 25

Vulnerable packages from findings in the last 7 days

SELECT vulnerability FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0, UNNEST(vulnerabilities) as t(vulnerability) WHERE vulnerabilities is not null LIMIT 25

Findings that have changed in the last 7 days

SELECT finding.uid, finding.created_time, finding.first_seen_time, finding.last_seen_time, finding.modified_time, finding.title, state FROM amazon_security_lake_glue_db_us_east_1.amazon_security_lake_table_us_east_1_sh_findings_1_0 WHERE eventDay BETWEEN cast(date_format(current_timestamp - INTERVAL '7' day, '%Y%m%d%H') as varchar) and cast(date_format(current_timestamp - INTERVAL '0' day, '%Y%m%d%H') as varchar) LIMIT 25