terraform.aws.security.aws-kinesis-stream-unencrypted.aws-kinesis-stream-unencrypted

profile photo of semgrepsemgrep
Author
unknown
Download Count*

The AWS Kinesis stream does not encrypt data at rest. The data could be read if the Kinesis stream storage layer is compromised. Enable Kinesis stream server-side encryption.

Run Locally

Run in CI

Defintion

rules:
  - id: aws-kinesis-stream-unencrypted
    patterns:
      - pattern: |
          resource "aws_kinesis_stream" $ANYTHING {
            ...
          }
      - pattern-not: |
          resource "aws_kinesis_stream" $ANYTHING {
            ...
            encryption_type = "KMS"
            ...
          }
    message: The AWS Kinesis stream does not encrypt data at rest. The data could be
      read if the Kinesis stream storage layer is compromised. Enable Kinesis
      stream server-side encryption.
    languages:
      - hcl
    severity: WARNING
    metadata:
      category: security
      technology:
        - terraform
        - aws
      owasp:
        - A03:2017 - Sensitive Data Exposure
        - A04:2021 - Insecure Design
      cwe:
        - "CWE-311: Missing Encryption of Sensitive Data"
      references:
        - https://owasp.org/Top10/A04_2021-Insecure_Design
        - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_stream#encryption_type
        - https://docs.aws.amazon.com/streams/latest/dev/server-side-encryption.html
      subcategory:
        - audit
      likelihood: LOW
      impact: HIGH
      confidence: MEDIUM
      rule-origin-note: published from /src/aws-kinesis-stream-unencrypted.yml in None
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
      vulnerability_class:
        - Cryptographic Issues

Examples

aws-kinesis-stream-unencrypted.tf

# ruleid: aws-kinesis-stream-unencrypted
resource "aws_kinesis_stream" "fail_1" {
  name = "example-stream"

  stream_mode_details {
    stream_mode = "ON_DEMAND"
  }
}

# ruleid: aws-kinesis-stream-unencrypted
resource "aws_kinesis_stream" "fail_2" {
  name            = "example-stream"
  encryption_type = "NONE"

  stream_mode_details {
    stream_mode = "ON_DEMAND"
  }
}

# ok: aws-kinesis-stream-unencrypted
resource "aws_kinesis_stream" "pass" {
  name            = "example-stream"
  encryption_type = "KMS"

  stream_mode_details {
    stream_mode = "ON_DEMAND"
  }
}