Security findings: GuardDuty, Security Hub, Inspector, Access Analyzer and the advisors
AWS has a service for each kind of "something is wrong", and on call you meet their output as findings: GuardDuty watches behaviour (someone is brute-forcing SSH, an instance's credentials are used from outside AWS), Inspector watches software (this instance runs an openssl with a known CVE), IAM Access Analyzer watches access (this bucket can be read by another account), Security Hub checks configuration against standards (CIS, AWS Foundational Security Best Practices) and gathers everyone's findings in one format, Trusted Advisor and Compute Optimizer advise on cost, limits and size. Turning them on is easy; the work is reading a finding, deciding what it means, and routing the important ones to a person.
Need to know: GuardDuty is enabled per Region with one detector, and reads CloudTrail management events, VPC Flow Logs and DNS logs by itself - you do not turn those on for it. Finding types read as ThreatPurpose:ResourceType/ThreatFamily.DetectionMechanism!Artifact, and severity is a number: Low 1-3.9, Medium 4-6.9, High 7-8.9, Critical 9+. Security Hub uses the AWS Security Finding Format (ASFF) for everything it holds, needs AWS Config recording to evaluate its controls, and every finding has a workflow status (NEW, NOTIFIED, RESOLVED, SUPPRESSED) that is yours to manage. In an organization each of these services has a delegated administrator account that sees every member account.
GuardDuty
GuardDuty has been on in this Region for three days, and the lab's instance has had SSH open to the internet for some of that:
$ cd ~/oncall-lab/labs/aws/try4
$ D=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text); aws guardduty get-detector --detector-id $D --query '[Status,FindingPublishingFrequency]' --output text
ENABLED SIX_HOURS
$ aws guardduty create-detector --enable
aws: [ERROR]: An error occurred (BadRequestException) when calling the CreateDetector operation: The request is rejected because a detector already exists for the current account.
Additional error details:
Type: InvalidInputException
$ aws guardduty list-findings --detector-id $D --query 'length(FindingIds)'
2
$ aws guardduty get-findings --detector-id $D --finding-ids $(aws guardduty list-findings --detector-id $D --query FindingIds --output text) --query 'Findings[].[Type,Severity,Resource.InstanceDetails.InstanceId,Service.Count]' --output table
-----------------------------------------------------------------------------
| GetFindings |
+---------------------------------------+----+-----------------------+------+
| UnauthorizedAccess:EC2/SSHBruteForce | 2 | i-0e51940f154311175 | 214 |
| Recon:EC2/PortProbeUnprotectedPort | 2 | i-0e51940f154311175 | 37 |
+---------------------------------------+----+-----------------------+------+
Read one in full - the parts that matter are the resource (what is affected), the action (what happened, from where), and count / first seen / last seen (is it still going on?):
$ F=$(aws guardduty list-findings --detector-id $D --finding-criteria '{"Criterion":{"type":{"Eq":["UnauthorizedAccess:EC2/SSHBruteForce"]}}}' --query 'FindingIds[0]' --output text)
$ aws guardduty get-findings --detector-id $D --finding-ids $F --query 'Findings[0].{title: Title, port: Service.Action.NetworkConnectionAction.LocalPortDetails.Port, remote: Service.Action.NetworkConnectionAction.RemoteIpDetails.IpAddressV4, direction: Service.Action.NetworkConnectionAction.ConnectionDirection, first: Service.EventFirstSeen, last: Service.EventLastSeen}' --output yaml
title: 198.51.100.77 is performing SSH brute force attacks against i-0e51940f154311175.
port: 22
remote: 198.51.100.77
direction: INBOUND
first: '2026-09-22T15:00:03.000Z'
last: '2026-09-22T18:00:03.000Z'
Brute-force against an open port is Low: the internet does this to every open port, and the finding is really telling you the port is open. The fix is the security group, not the attacker. High findings are the ones to page on - CryptoCurrency:EC2/BitcoinTool.B!DNS (an instance mining), Backdoor:EC2/C&CActivity.B!DNS (talking to a command-and-control server), UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS (an instance role's temporary credentials used from somewhere that is not that instance). An incident later in this chapter is exactly that last one.
To see what each type looks like before it happens to you, generate samples (marked [SAMPLE] in the title), and archive what you have dealt with:
$ aws guardduty create-sample-findings --detector-id $D --finding-types 'CryptoCurrency:EC2/BitcoinTool.B!DNS'
$ aws guardduty get-findings-statistics --detector-id $D --finding-statistic-types COUNT_BY_SEVERITY --query FindingStatistics.CountBySeverity
{
"2.0": 2,
"8.0": 1
}
$ aws guardduty archive-findings --detector-id $D --finding-ids $(aws guardduty list-findings --detector-id $D --finding-criteria '{"Criterion":{"service.additionalInfo.sample":{"Eq":["true"]}}}' --query FindingIds --output text)
$ aws guardduty list-findings --detector-id $D --finding-criteria '{"Criterion":{"service.archived":{"Eq":["false"]}}}' --query 'length(FindingIds)'
2
Every finding also goes to EventBridge as source: aws.guardduty, detail-type: GuardDuty Finding - a rule matching {"detail": {"severity": [{"numeric": [">=", 7]}]}} that targets the on-call topic is the standard "page on High and Critical" setup.
Security Hub: one place, one format
Security Hub runs controls (S3.8, EC2.19, IAM.4, CloudTrail.1 ...) from the standards you enable, using AWS Config's recorded configuration, and imports findings from GuardDuty, Inspector, Access Analyzer, Macie and partner tools:
$ aws securityhub describe-hub
aws: [ERROR]: An error occurred (InvalidAccessException) when calling the DescribeHub operation: Account 111122223333 is not subscribed to AWS Security Hub
$ aws securityhub enable-security-hub --enable-default-standards
$ aws securityhub get-enabled-standards --query 'StandardsSubscriptions[].[StandardsArn,StandardsStatus]' --output text
arn:aws:securityhub:eu-central-1::standards/aws-foundational-security-best-practices/v/1.0.0 READY
arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/1.2.0 READY
$ sleep 5; aws securityhub get-findings --filters '{"ComplianceStatus":[{"Value":"FAILED","Comparison":"EQUALS"}],"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' --query 'Findings[].[Compliance.SecurityControlId,Severity.Label,Title]' --output text | sort -u | head -8
CloudTrail.1 HIGH CloudTrail should be enabled and configured with at least one multi-Region trail that includes read and write management events
EC2.19 CRITICAL Security groups should not allow unrestricted access to ports with high risk
EC2.2 HIGH VPC default security groups should not allow inbound or outbound traffic
EC2.7 MEDIUM EBS default encryption should be enabled
S3.1 MEDIUM S3 general purpose buckets should have block public access settings enabled
(The lesson's setup turned on AWS Config, as the previous lesson did by hand: without it, Security Hub has no resources to check and fails Config.1 instead.) Fix one and watch the finding resolve itself - a PASSED control finding moves to workflow RESOLVED without anyone touching it:
$ SG=$(aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.cidr,Values=0.0.0.0/0 --query 'SecurityGroups[0].GroupId' --output text)
$ aws ec2 revoke-security-group-ingress --group-id $SG --protocol tcp --port 22 --cidr 0.0.0.0/0 --query Return
true
$ sleep 5; aws securityhub get-findings --filters '{"ComplianceSecurityControlId":[{"Value":"EC2.19","Comparison":"EQUALS"}],"ResourceId":[{"Value":"arn:aws:ec2:eu-central-1:111122223333:security-group/'$SG'","Comparison":"EQUALS"}]}' --query 'Findings[0].[Compliance.Status,Workflow.Status]' --output text
PASSED RESOLVED
A finding you accept on purpose is suppressed with a note - so the next person sees why, instead of the dashboard simply being red:
$ FID=$(aws securityhub get-findings --filters '{"ComplianceSecurityControlId":[{"Value":"EC2.7","Comparison":"EQUALS"}],"ComplianceStatus":[{"Value":"FAILED","Comparison":"EQUALS"}]}' --query 'Findings[0].Id' --output text); echo $FID | cut -c1-80
arn:aws:securityhub:eu-central-1:111122223333:security-control/EC2.7/finding/b97
$ aws securityhub batch-update-findings --finding-identifiers Id=$FID,ProductArn=arn:aws:securityhub:eu-central-1::product/aws/securityhub --workflow Status=SUPPRESSED --note Text="accepted: encryption by default is enabled with the platform migration (Q1)",UpdatedBy=learner --query 'length(ProcessedFindings)'
1
$ aws securityhub get-findings --filters '{"ProductName":[{"Value":"GuardDuty","Comparison":"EQUALS"}]}' --query 'Findings[].[Severity.Label,Types[0]]' --output text | head -3
HIGH TTPs/Impact/CryptoCurrency:EC2-BitcoinTool.B!DNS
LOW TTPs/Discovery/Recon:EC2-PortProbeUnprotectedPort
LOW TTPs/Initial Access/UnauthorizedAccess:EC2-SSHBruteForce
Inspector: what is vulnerable
Inspector scans SSM-managed EC2 instances (it reads the package inventory through the agent - an unmanaged instance shows UNMANAGED_EC2_INSTANCE in coverage), container images in ECR, and Lambda functions:
$ aws inspector2 enable --resource-types EC2 --query 'accounts[0].resourceStatus.ec2' --output text
ENABLING
$ sleep 120
$ aws inspector2 list-coverage --query 'coveredResources[].[resourceId,resourceType,scanStatus.statusCode]' --output text
i-0e51940f154311175 AWS_EC2_INSTANCE ACTIVE
$ I=$(aws ec2 describe-instances --filters Name=tag:Name,Values=try-web-1 Name=instance-state-name,Values=running --query 'Reservations[0].Instances[0].InstanceId' --output text)
$ aws inspector2 list-findings --filter-criteria '{"resourceId":[{"comparison":"EQUALS","value":"'$I'"}],"findingStatus":[{"comparison":"EQUALS","value":"ACTIVE"}]}' --query 'findings[].[severity,title,packageVulnerabilityDetails.vulnerablePackages[0].fixedInVersion]' --output text
HIGH CVE-2026-31007 - openssl, libssl3t64 0:3.5.5-1ubuntu3.7
MEDIUM CVE-2026-29911 - systemd, libsystemd0, udev, libudev1 0:259.5-0ubuntu3.4
(The CVE numbers are the lab's own feed, (simulator); the shape is Inspector's.) Each finding names the fixed version - the fix is patching, which Inspector notices on its own:
$ aws ssm send-command --document-name AWS-RunPatchBaseline --instance-ids $I --parameters Operation=Install,RebootOption=NoReboot --query Command.Status --output text; sleep 10
Pending
$ aws inspector2 list-findings --filter-criteria '{"resourceId":[{"comparison":"EQUALS","value":"'$I'"}]}' --query 'findings[].[status,title]' --output text
CLOSED CVE-2026-31007 - openssl, libssl3t64
CLOSED CVE-2026-29911 - systemd, libsystemd0, udev, libudev1
Access Analyzer: who outside can get in
An analyzer with the account (or organization) as its zone of trust reports every resource policy that grants access to someone outside it - S3 buckets, IAM role trust policies, KMS keys, secrets, SQS queues, Lambda functions:
$ aws accessanalyzer create-analyzer --analyzer-name try-account --type ACCOUNT --query arn --output text
arn:aws:access-analyzer:eu-central-1:111122223333:analyzer/try-account
$ sleep 3; aws accessanalyzer list-findings --analyzer-arn arn:aws:access-analyzer:eu-central-1:111122223333:analyzer/try-account --query 'findings[].[resourceType,resource,principal.AWS,action[0],isPublic,status]' --output text
AWS::S3::Bucket arn:aws:s3:::oncall-try-partner-111122223333 210987654321 s3:GetObject False ACTIVE
$ aws accessanalyzer validate-policy --policy-document file://broad-policy.json --policy-type IDENTITY_POLICY --query 'findings[].[findingType,issueCode]' --output text
SECURITY_WARNING PASS_ROLE_WITH_STAR_IN_RESOURCE
SUGGESTION REDUNDANT_ACTION
A partner reading exports is intended: archive the finding (or write an archive rule for that account). A finding you did not expect is an incident. validate-policy is the linter to run in the pipeline before a policy ships - iam:PassRole on * is a privilege escalation waiting to happen.
Trusted Advisor and Compute Optimizer
Trusted Advisor checks cost, security, fault tolerance, performance and service limits. In the console everyone gets the core checks; through the API (aws support) it needs a Business Support+ (or legacy Business, until 1 Jan 2027), Enterprise or Unified Operations support plan, and the Support API has one endpoint, in us-east-1:
$ aws support describe-trusted-advisor-checks --language en
aws: [ERROR]: Could not connect to the endpoint URL: "https://support.eu-central-1.amazonaws.com/"
$ aws support describe-trusted-advisor-checks --language en --region us-east-1
aws: [ERROR]: An error occurred (SubscriptionRequiredException) when calling the DescribeTrustedAdvisorChecks operation: AWS Premium Support Subscription is required to use this service.
Compute Optimizer recommends instance types (and EBS, Lambda, ECS, Auto Scaling group sizes) from 14 days of CloudWatch metrics - after you opt in:
$ aws compute-optimizer get-ec2-instance-recommendations
aws: [ERROR]: An error occurred (OptInRequiredException) when calling the GetEC2InstanceRecommendations operation: The account is not opted in.
$ aws compute-optimizer update-enrollment-status --status Active --query status --output text
Active
$ aws compute-optimizer get-ec2-instance-recommendations --query 'instanceRecommendations[].[instanceArn,finding,currentInstanceType,recommendationOptions[0].instanceType]' --output text
arn:aws:ec2:eu-central-1:111122223333:instance/i-0e51940f154311175 Overprovisioned t4g.small t4g.micro
Two more names to place: Amazon Detective builds a graph from CloudTrail, Flow Logs and GuardDuty to investigate a finding ("what else did this IP and this role do?"); Amazon Macie finds sensitive data (personal data, credentials) in S3 buckets - the tool behind a "data classification" requirement, together with tags such as data-class=confidential.
| question | service |
|---|---|
| is someone attacking or using my resources? | GuardDuty |
| which instances / images run vulnerable packages? | Inspector |
| who outside the account can reach this resource? | IAM Access Analyzer |
| does my configuration meet CIS / FSBP, and one list of everything? | Security Hub |
| where is personal data in S3? | Macie |
| investigate a finding's history | Detective |
| cost, limits, idle resources | Trusted Advisor, Compute Optimizer |
On the exam (SOA-C03 4.1 and 4.2, SAA-C03 1.1, CLF-C02 2.x): which service finds what (the table above is the whole question bank), GuardDuty severity and the EventBridge rule that pages on High, Security Hub needing Config, Inspector needing SSM, Trusted Advisor's API needing Business Support+, Compute Optimizer for rightsizing, and delegated administrators in Organizations.
In an interview: "GuardDuty fires a High finding at 3 am. What do you do?" - "Read it: the type tells me the threat and the resource, the action tells me from where, count and last seen tell me if it is ongoing. Then contain before I investigate - isolate the instance with a security group, revoke the role's sessions if credentials are involved - preserve evidence with a snapshot, and use CloudTrail to see what the actor did. Afterwards: fix the cause, archive the finding with a note, and write it up."
You can now: read GuardDuty findings by type, severity, resource and action, generate samples and archive what is handled, enable Security Hub with Config underneath and work its control findings through their workflow, turn on Inspector and close its findings by patching, find external access with Access Analyzer and lint policies, call Trusted Advisor and Compute Optimizer with their prerequisites, and say which service answers which question.