Sub topic 7
What Security Hub does
This chapter assumes you can run AWS CLI commands, read JSON, and know what GuardDuty findings are from the earlier chapters. It builds the working model of AWS Security Hub and lists the mistakes people make most often with it.
The role of Security Hub
GuardDuty answers the question "is something suspicious happening?" Security Hub answers a different one: "what is the security state of my accounts, and where do I look first?" It does this with three functions.
- Aggregation. It collects findings from AWS services such as GuardDuty, Amazon Inspector, Amazon Macie, IAM Access Analyzer, and AWS Firewall Manager. It also collects findings from supported partner products.
- Posture checks. It runs automated checks, called controls, against your resource configurations. Examples are "S3 buckets should block public access" and "root user should have MFA enabled". Each failed check becomes a finding.
- Triage and routing. It normalizes every finding to a common schema, lets you filter, group, and update findings, and publishes them to Amazon EventBridge for automation.
Security Hub does not detect threats itself. It stores, scores, and routes what other sources produce, and it generates its own findings only for configuration checks.
AWS has expanded and renamed parts of this service over time. The configuration-checking capability is called AWS Security Hub CSPM (cloud security posture management) in current documentation. The aws securityhub CLI commands in this chapter work with it. Check the current console and documentation for which capabilities your account has.
How data flows
Integrated AWS services send findings automatically once both the source service and Security Hub are enabled in the same Region. Partner products usually need a product subscription or an integration you configure.
Anatomy of a Security Hub finding
Every finding, whatever its source, is stored in the same schema. Security Hub has historically used the AWS Security Finding Format (ASFF), and a later chapter covers it in detail. These fields matter for day-to-day work:
| Field | Meaning | Typical values |
|---|---|---|
| `ProductName` | Which service or product produced the finding | `GuardDuty`, `Inspector`, `Security Hub` |
| `Severity.Label` | Normalized severity | `INFORMATIONAL`, `LOW`, `MEDIUM`, `HIGH`, `CRITICAL` |
| `Compliance.Status` | Result of a control check (control findings only) | `PASSED`, `FAILED`, `WARNING`, `NOT_AVAILABLE` |
| `RecordState` | Whether the finding is current | `ACTIVE`, `ARCHIVED` |
| `Workflow.Status` | Where the finding is in your triage process | `NEW`, `NOTIFIED`, `SUPPRESSED`, `RESOLVED` |
| `Resources` | The affected resource ID and type | An instance ARN, a bucket ARN |
RecordState and Workflow.Status are separate on purpose. The source service controls RecordState. For example, a control finding becomes ARCHIVED when the resource is deleted or the control is disabled. You control Workflow.Status to record your own triage decisions.
GuardDuty's own severity is a number from 1 to 10. Security Hub maps it to a normalized label and a 0–100 score so that findings from different tools can be sorted together. Do not expect the numbers to match, because a GuardDuty 8.0 appears in Security Hub with a HIGH label and a different numeric value.
Controls and the AWS Config dependency
Posture checks come from security standards. A standard is a named set of controls, such as the AWS Foundational Security Best Practices standard. The next chapter covers standards in depth. Mechanically, a control check evaluates a resource either on a periodic schedule or when its configuration changes. Most controls use AWS Config rules that Security Hub creates and manages for you.
This leads to the most common setup problem. AWS Config resource recording must be on in each account and Region where you want control findings. If it is off, Security Hub can still receive GuardDuty findings, but the control checks report no data or fail to run. Fix this before you debug anything else.
Enabling and verifying
Enable Security Hub with the default standards, then list what is turned on:
aws securityhub enable-security-hub --enable-default-standards
aws securityhub get-enabled-standards --query 'StandardsSubscriptions[].[StandardsArn,StandardsStatus]' --output tableStandardsStatus moves from PENDING to READY while the initial checks are provisioned. Initial findings can take some time to appear, so an empty result right after enabling does not mean a problem.
Querying findings
get-findings takes a --filters JSON document. Each key is a field name, and each value is a list of conditions. This example returns active, failed, critical control findings:
aws securityhub get-findings \
--filters '{
"RecordState": [{"Value":"ACTIVE","Comparison":"EQUALS"}],
"ComplianceStatus": [{"Value":"FAILED","Comparison":"EQUALS"}],
"SeverityLabel": [{"Value":"CRITICAL","Comparison":"EQUALS"}]
}' \
--max-items 5 \
--query 'Findings[].[Title,Severity.Label,Resources[0].Id]' \
--output tableConditions within one key are combined with OR. Different keys are combined with AND. Using the same filter name twice in the JSON does not work, so put all the values for one field in one list.
To see where your findings come from, count active findings by product with boto3:
import boto3
from collections import Counter
client = boto3.client("securityhub")
paginator = client.get_paginator("get_findings")
filters = {
"RecordState": [{"Value": "ACTIVE", "Comparison": "EQUALS"}],
}
counts = Counter()
for page in paginator.paginate(Filters=filters):
for finding in page["Findings"]:
counts[finding.get("ProductName", "unknown")] += 1
for product, total in counts.most_common():
print(f"{product}: {total}")This uses the credentials and Region from your environment. On a large account it makes many API calls, so run it with a narrower filter when you only need a sample.
Working findings through a workflow
Triage means recording a decision on each finding. You do this with batch-update-findings, which identifies findings by both Id and ProductArn:
FINDING=$(aws securityhub get-findings \
--filters '{"ProductName":[{"Value":"GuardDuty","Comparison":"EQUALS"}],"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' \
--max-items 1 \
--query 'Findings[0].[Id,ProductArn]' --output text)
FINDING_ID=$(echo "$FINDING" | cut -f1)
PRODUCT_ARN=$(echo "$FINDING" | cut -f2)
aws securityhub batch-update-findings \
--finding-identifiers "Id=$FINDING_ID,ProductArn=$PRODUCT_ARN" \
--workflow '{"Status":"NOTIFIED"}' \
--note '{"Text":"Escalated to on-call","UpdatedBy":"secops"}'The response lists ProcessedFindings and UnprocessedFindings. Always check the second list, because a malformed identifier does not raise an error for the whole call.
Insights, automation rules, and custom actions
Security Hub gives you three ways to handle findings at scale.
- Insights are saved groupings, such as "failed controls by resource type". They help you see where problems concentrate.
- Automation rules update findings automatically when they arrive. A rule can raise severity for findings on production accounts, or set
Workflow.Statusfor known cases. Rules run in order and apply to new and updated findings. - Custom actions add a button in the console that sends selected findings to EventBridge. They suit human-approved remediation.
Findings that Security Hub imports are also sent to EventBridge, with the detail type Security Hub Findings - Imported. A later chapter builds on this. A rule that matches GuardDuty events directly and a rule that matches Security Hub events see the same threat, so pick one path per use case. Otherwise a single finding triggers two responses.
Regions and accounts
Security Hub is a Regional service. Each Region has its own findings store, so an account with workloads in three Regions has three separate views unless you configure cross-Region aggregation. With aggregation, you choose one aggregation Region, and findings from linked Regions are copied there. Updates to the copies, such as workflow changes, flow back to the source Region. The multi-account chapter covers delegated administrators.
Common errors
- Control findings never appear. AWS Config recording is off in that account or Region, or the standard is still
PENDING. - GuardDuty findings are missing from Security Hub. The two services must be enabled in the same Region, and Security Hub must be enabled in the account where you query.
- A filter returns nothing. Field names are case-sensitive, and
Comparisonmust be one ofEQUALS,PREFIX,NOT_EQUALS, orPREFIX_NOT_EQUALSfor strings. - Duplicate alerts. Both a GuardDuty and a Security Hub EventBridge rule point at the same target.
- Old counts after a fix. Control findings update on the next check. Allow time before assuming the fix failed.
Exercise
A teammate enables Security Hub in us-east-1 and sees GuardDuty findings, but the "failed controls" list is empty and the standards show READY. What should you check first, and why?
Show answer
Check that AWS Config resource recording is enabled in that account and Region. Most control checks rely on AWS Config rules and the configuration data Config records. Without recording, Security Hub still imports GuardDuty findings, because those arrive from GuardDuty directly, but the control checks cannot evaluate resources. Also confirm that enough time has passed since the standards became READY for the first evaluation to finish.
Exercise
You run batch-update-findings and set Workflow.Status to RESOLVED on a failed S3 control finding without fixing the bucket. A day later, is the finding likely to stay resolved? Explain.
Show answer
No. Workflow.Status records your triage decision, but the control check still evaluates the bucket. If the bucket remains noncompliant, Security Hub updates the finding with a FAILED compliance result, and it typically returns to NEW workflow status. The only lasting fix is correcting the configuration, or disabling the control if the check does not apply to you.