Skip to content

Checkov files #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Checkov files #20

wants to merge 1 commit into from

Conversation

nimratcoderabbit
Copy link

@nimratcoderabbit nimratcoderabbit commented Jul 14, 2025

image

Summary by CodeRabbit

  • New Features
    • Added a new configuration that creates an AWS S3 bucket with public read access.
    • Added a security group allowing SSH access from any IP and permitting all outbound traffic.

Copy link

coderabbitai bot commented Jul 14, 2025

📝 Walkthrough

Walkthrough

A new Terraform configuration file was introduced, specifying an AWS provider in the "us-east-1" region. It defines an S3 bucket with public-read access and a security group that allows unrestricted SSH access and outbound traffic.

Changes

File(s) Change Summary
checkov/test.tf Added Terraform config for AWS provider, S3 bucket with public-read ACL, and open security group

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Terraform
    participant AWS

    User->>Terraform: Apply configuration
    Terraform->>AWS: Create S3 bucket (public-read)
    Terraform->>AWS: Create security group (open ingress/egress)
    AWS-->>Terraform: Resources provisioned
    Terraform-->>User: Provisioning complete
Loading

Poem

A bucket stands open, its contents in view,
A security group waves, “SSH for you!”
Terraform whispers to AWS skies,
“Build it all wide, let no traffic disguise.”
With public and open, the test is now set—
Cloud gates unlocked, the boldest config yet!
☁️🗝️

Impact Analysis

Introduction of insecure AWS resources with public access

⚠️ High 🔒Impacts security

This change adds a Terraform configuration that creates an S3 bucket with public-read access and a security group allowing unrestricted SSH (port 22) access from any IP address, as well as unrestricted outbound traffic. These configurations expose resources to the public internet, significantly increasing the risk of unauthorized access and data breaches.

Deploy the Terraform configuration in a controlled environment and verify that the S3 bucket is publicly accessible and that the security group allows SSH access from any IP. Test for unintended exposure of sensitive data and confirm that security monitoring detects these insecure configurations.

🔍 Related Files
  • checkov/test.tf
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch preview/checkov

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nimratcoderabbit
Copy link
Author

@coderabbitai full review

Copy link

coderabbitai bot commented Jul 14, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
checkov/test.tf (3)

5-8: Lifecycle configuration missing – objects will live forever.

Checkov (CKV2_AWS_61) flags the absence of a lifecycle rule. Add a rule to abort incomplete multipart uploads and optionally expire/archive objects to control storage costs.

   bucket = "my-insecure-bucket"
   acl    = "public-read"
+
+  lifecycle_rule {
+    id      = "abort-incomplete-mpu"
+    status  = "Enabled"
+
+    abort_incomplete_multipart_upload_days = 7
+  }

19-24: Full egress to everywhere – tighten if possible.

While AWS allows 0.0.0.0/0 egress by default, locking outbound traffic to required destinations only (e.g., AWS services, on-prem CIDRs) reduces blast radius if the instance is compromised.

-    cidr_blocks = ["0.0.0.0/0"]
+    # Restrict egress to necessary networks
+    cidr_blocks = ["10.0.0.0/16"]

1-3: Hard-coding region reduces reuse.

Consider parameterising the region via a variable to support multi-region deployments.

-provider "aws" {
-  region = "us-east-1"
-}
+variable "aws_region" {
+  description = "AWS region to deploy into"
+  type        = string
+  default     = "us-east-1"
+}
+
+provider "aws" {
+  region = var.aws_region
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef04b8d and 7990b18.

📒 Files selected for processing (1)
  • checkov/test.tf (1 hunks)
🧰 Additional context used
🪛 Checkov (3.2.334)
checkov/test.tf

[MEDIUM] 5-8: Ensure that an S3 bucket has a lifecycle configuration

(CKV2_AWS_61)


[HIGH] 5-8: S3 Bucket has an ACL defined which allows public READ access.

(CKV_AWS_20)

Comment on lines +5 to +8
resource "aws_s3_bucket" "bad_bucket" {
bucket = "my-insecure-bucket"
acl = "public-read"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Public-read ACL creates a world-readable bucket – lock it down.

The acl = "public-read" line exposes every object in my-insecure-bucket to the entire internet. Unless the business case explicitly requires anonymous access (and most don’t), switch to a private ACL and add encryption / versioning / lifecycle controls.

-  acl    = "public-read"
+  acl    = "private"
+
+# Enable versioning to guard against accidental deletes
+  versioning {
+    enabled = true
+  }
+
+# Default encryption at rest (SSE-KMS)
+  server_side_encryption_configuration {
+    rule {
+      apply_server_side_encryption_by_default {
+        sse_algorithm = "aws:kms"
+      }
+    }
+  }

Add a separate Public Access Block resource to guarantee nothing re-opens the bucket:

+resource "aws_s3_bucket_public_access_block" "bad_bucket_pab" {
+  bucket = aws_s3_bucket.bad_bucket.id
+
+  block_public_acls   = true
+  ignore_public_acls  = true
+  block_public_policy = true
+  restrict_public_buckets = true
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resource "aws_s3_bucket" "bad_bucket" {
bucket = "my-insecure-bucket"
acl = "public-read"
}
resource "aws_s3_bucket" "bad_bucket" {
bucket = "my-insecure-bucket"
acl = "private"
# Enable versioning to guard against accidental deletes
versioning {
enabled = true
}
# Default encryption at rest (SSE-KMS)
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
}
resource "aws_s3_bucket_public_access_block" "bad_bucket_pab" {
bucket = aws_s3_bucket.bad_bucket.id
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true
}
🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 5-8: Ensure that an S3 bucket has a lifecycle configuration

(CKV2_AWS_61)


[HIGH] 5-8: S3 Bucket has an ACL defined which allows public READ access.

(CKV_AWS_20)

🤖 Prompt for AI Agents
In checkov/test.tf around lines 5 to 8, the S3 bucket is configured with a
public-read ACL, making it world-readable. Change the ACL to "private" to
restrict access, and add encryption, versioning, and lifecycle policies as
needed. Additionally, create a separate aws_s3_bucket_public_access_block
resource to block any public access settings and ensure the bucket remains
secure.

Comment on lines +10 to +18
resource "aws_security_group" "bad_sg" {
name = "open-sg"
description = "Security group with open ingress"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

SSH open to the world (0.0.0.0/0) – huge attack surface.

Unrestricted port 22 access invites automated scanning and brute-force attacks. Limit the source CIDR to a known bastion IP range or, better, drop public SSH and use SSM Session Manager.

-    cidr_blocks = ["0.0.0.0/0"]
+    # Example: restrict to corporate office IP range
+    cidr_blocks = ["203.0.113.0/24"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resource "aws_security_group" "bad_sg" {
name = "open-sg"
description = "Security group with open ingress"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
resource "aws_security_group" "bad_sg" {
name = "open-sg"
description = "Security group with open ingress"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
# Example: restrict to corporate office IP range
cidr_blocks = ["203.0.113.0/24"]
}
}
🤖 Prompt for AI Agents
In checkov/test.tf around lines 10 to 18, the security group ingress rule allows
SSH (port 22) from any IP address (0.0.0.0/0), creating a large attack surface.
To fix this, restrict the cidr_blocks value to a specific known IP range such as
a bastion host's IP or remove the public SSH access entirely and configure
access through AWS Systems Manager Session Manager instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant