Skip to content

AWS Security Hub Executor

Category: Cloud Security Script: aws_security_hub.py Integration: Python SDK (boto3) Faraday Plugin: Raw JSON Website: https://aws.amazon.com/security-hub/

Description

Imports findings from AWS Security Hub into Faraday. Security Hub aggregates the findings of AWS services and partner products, and the executor creates one host per affected AWS resource with one vulnerability per finding.

Prerequisites

  • An AWS account with Security Hub enabled in the region you want to import
  • An IAM principal (access key) with the securityhub:GetFindings permission. Use a session token if you use temporary credentials.
  • boto3 available in the agent's Python environment
  • Network access to the regional Security Hub endpoint

Configuration

Environment Variables (Setup)

Variable Required Description
AWS_ACCESS_KEY_ID Yes Access key ID of the AWS IAM principal
AWS_SECRET_ACCESS_KEY Yes Secret access key of the AWS IAM principal
AWS_SESSION_TOKEN No Session token, only for temporary (STS) credentials

These variables are also accepted as execution arguments, so a single run can override them.

Execution Arguments

Parameter Type Mandatory Description
AWS_REGION string Yes AWS region to query (e.g., us-east-1, eu-west-1). Security Hub is regional. If you do not set it here, the AWS_REGION or AWS_DEFAULT_REGION environment variable of the agent is used.
SECHUB_FILTERS_JSON string No JSON object with an AwsSecurityFindingFilters document, for example {"SeverityLabel": [{"Value": "CRITICAL", "Comparison": "EQUALS"}]}. Invalid JSON is ignored. Default: no filter.
SECHUB_MAX_RESULTS string No Maximum number of findings to import (default: 1000). Invalid or non-positive values fall back to the default.

YAML Configuration Example

executors:
  aws_security_hub:
    repo_executor: aws_security_hub.py
    max_size: 65536
    varenvs:
      AWS_ACCESS_KEY_ID: "<aws_access_key_id>"
      AWS_SECRET_ACCESS_KEY: "<aws_secret_access_key>"
      AWS_SESSION_TOKEN: "<aws_session_token>"
    params:
      AWS_REGION:
        mandatory: true
        type: string
        base: string
      SECHUB_FILTERS_JSON:
        mandatory: false
        type: string
        base: string
      SECHUB_MAX_RESULTS:
        mandatory: false
        type: string
        base: string

How It Works

  1. Creates a boto3 securityhub client for the configured region with the given AWS credentials
  2. Calls GetFindings (100 findings per page) with the filters from SECHUB_FILTERS_JSON, until SECHUB_MAX_RESULTS findings are collected
  3. Groups the findings by their first affected AWS resource and creates one host per resource
  4. Maps each finding (AWS Security Finding Format) to a Faraday vulnerability:
    • Name: [CNAPP], the finding title and the affected resource
    • Severity: the finding's severity label, or its normalized score (0 to 100), or the CVSS score
    • Status: workflow status NEW/NOTIFIED becomes open, RESOLVED or an archived record becomes closed, SUPPRESSED becomes risk-accepted
    • Resolution: the remediation recommendation, or an "Upgrade package to version" hint from the fixed package versions
    • References: CVEs, advisory URLs and other identifiers from the finding

Notes

  • Security Hub aggregates findings from AWS services (GuardDuty, Inspector, Macie and others) and partner products, so the import can include all of them.
  • Each AWS resource becomes one host. EC2 instances use their first IPv4 address. All other resources use the synthetic IP 0.0.0.0, and the resource is identified by its hostname (<resource label>@<resource id>).
  • Only the first resource of each finding is used, even if a finding lists several.
  • The IAM principal needs the securityhub:GetFindings permission.
  • Security Hub returns only findings ingested in the queried region. Run the executor once per region.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor. Use SECHUB_FILTERS_JSON to filter by severity or workflow status.