Razeen AcademyRazeen — Cloud Security
LAB-03 · Free

The Unreviewed Code

A developer wrote a Terraform file and is about to hit "Deploy" . It has 4 security flaws — find them before it ships.

the briefwaha finance

The dev team at Waha Finance now builds infrastructure as code (Terraform) instead of clicking around the console. Developer Khalid wrote a file for a new environment holding customer documents and the transactions database.

Before it deploys, they've asked you for a quick security review. Read it line by line and answer.

code reviewmain.tf
main.tfpull request #41 · awaiting review
# main.tf  -  new Waha environment  (written by dev-khalid)

provider "aws" {
  region = "eu-central-1"
}

# --- customer documents storage ---
resource "aws_s3_bucket" "customer_docs" {
  bucket = "waha-customer-docs-prod"
}

resource "aws_s3_bucket_public_access_block" "customer_docs" {
  bucket                  = aws_s3_bucket.customer_docs.id
  block_public_acls       = false
  block_public_policy     = false
  ignore_public_acls      = false
  restrict_public_buckets = false
}

# --- transactions database ---
resource "aws_db_instance" "transactions" {
  identifier          = "waha-transactions-db"
  engine              = "postgres"
  instance_class      = "db.t3.micro"
  allocated_storage   = 20
  username            = "waha_admin"
  password            = "RAZEEN{h4rdc0d3d_s3cr3t_1n_t3rr4f0rm}"
  storage_encrypted   = false
  skip_final_snapshot = true
}

# --- network ---
resource "aws_security_group" "app" {
  name = "waha-app-sg"

  ingress {
    description = "HTTPS for customers"
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  ingress {
    description = "temp access - remove later"
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

A synthetic file for educational purposes. It was never deployed anywhere.

review06 steps
01

The customer-documents bucket: what's wrong with it?

Hint

Remember LAB-01. Which setting would have prevented the problem there?

Every Block Public Access setting is off. They should all be true.

02

In the Security Group, which port shouldn't be open to the world?

Hint

Port 443 is for customers, so it's normal for it to be open. Look at the other one — its description says "remove later".

Port 22 (SSH) — the door into the server itself.

03

What does 0.0.0.0/0 mean?

Hint

All zeros here mean "no restriction at all".

Any device on the internet — anyone can try to get into the server on port 22.

04

The transactions database: which setting is dangerous?

Hint

Financial data… is it protected if someone gets hold of the disk itself?

Encryption is off. Financial data must be encrypted while stored (encryption at rest).

05

🚩 What's the flag?

Hint

Something is written in the code that should never be there.

Another hint (if you're stuck)

Look at the password line in the database resource.

Correct flag. In a real environment this would be a real password, and anyone who can see the code (or GitHub) could get into the database.

06

Where should the database password live instead of the code?

Hint

base64 isn't encryption — anyone can decode it in a second.

A secrets service like AWS Secrets Manager. And tools like Checkov catch every flaw you found here automatically, before deploy.

You stopped the deploy just in time

You found all four flaws before they hit production. This is called "Shift Left": catching problems in code instead of in an incident. You've finished all three free labs 🎉

Follow us for upcoming labs

Waha Finance is a fictional company for educational purposes; any resemblance to a real organization is unintended. All data in this lab is a synthetic dataset. Only use these skills on systems you're authorized to test.