id: aws-credentials

info:
  name: AWS Credentials - Detect
  author: m4lwhere
  severity: high
  description: AWS credentials found via /.aws/credentials endpoint.
  reference:
    - https://aws.amazon.com/blogs/security/what-to-do-if-you-inadvertently-expose-an-aws-access-key/
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L
    cvss-score: 9.4
    cwe-id: CWE-200
  metadata:
    verified: true
    max-request: 1
  tags: config,exposure,aws,credential,vuln

http:
  - method: GET
    path:
      - "{{BaseURL}}/.aws/credentials"

    matchers-condition: and
    matchers:
      - type: regex
        regex:
          - 'aws_access_key_id\s*=\s*'

      - type: dsl
        dsl:
          - "!contains(tolower(body), '<html')"
          - "!contains(tolower(body), '<body')"
        condition: and

      - type: status
        status:
          - 200

    extractors:
      - type: regex
        part: body
        regex:
          - "(A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"
          - "([a-zA-Z0-9+/]{40})"
# digest: 4a0a00473045022100b65ab0d383ad225942c6a8a53b69b5df6d72d01dfecd79f02a9371d37eaaef8d022001e351933c70a18542e21513ab61256cd647ff2e3fe6f54cf4d6746b38b90ac2:922c64590222798bb761d5b6d8e72950