D33 lvl 3 Report
19 / 10 / 2026
UVCE MARVEL — CL-CY-001, Level 3
Task 1 — AWS Lambda: Two-Person Chat Application
What I Did
Built a two-person chat app using AWS Lambda. Messages are saved to DynamoDB. The frontend is a single HTML file that runs in the browser.
| Part | Tech | Role |
|---|---|---|
| Frontend | HTML + JS | Name entry, message box, live feed |
| Backend | AWS Lambda (Python) | Handles send/receive logic |
| Database | DynamoDB | Stores all messages |
| Access | Lambda Function URL | HTTPS endpoint for the browser to call |
Tested locally with LocalStack first, then deployed to real AWS Lambda.
How It Works
The Lambda receives a request with an action field:
send— saves the message to DynamoDBmessages— returns the last 100 messages, sorted by time
Each message is stored as: { id, name, message, createdAt (ms timestamp) }.
The frontend polls for new messages every 2 seconds. It tracks already-seen message IDs so the same message isn't shown twice.
User input is set using textContent (not innerHTML) to prevent script injection.
Deployment
- Code zipped and uploaded as a Lambda function
- DynamoDB table created separately
- Config passed via environment variables:
TABLE_NAME,DYNAMODB_ENDPOINT,AWS_DEFAULT_REGION - Credentials not committed —
.envis in.gitignore
Limitations
table.scan()reads the whole table on every poll — fine for a small demo, but would need a proper query with a limit at scale- CORS is open (
*) — should be locked to a specific domain in production - Errors are returned as plain text — fine for debugging, should be hidden in production
Task 2 — CI/CD with Jenkins
What I Did
Created a Jenkins pipeline (Jenkinsfile) that builds, tests, and deploys a password manager web app automatically. Jenkins runs in a container on my machine.
The app has three services:
| Service | Tech | Role |
|---|---|---|
db | MySQL 8.0 | Database |
backend | PHP 8.2 + Apache | REST API |
frontend | nginx | Serves UI, proxies /api/ to backend |
Pipeline Stages
- Checkout — pulls the code from the repo
- Build — builds Docker images
- Start Services — starts all containers with
docker compose up -d - Resolve Port — reads the dynamic frontend port with
docker compose port frontend 80 - Wait for Services — polls the login endpoint every 2s (up to 60s) until it returns 200
- Test API — logs in, extracts the auth token, calls
/api/vaultsand/api/vaults/1/items - Health Check — checks container status and HTTP response codes
- Deploy — tags the image with the commit SHA and
latest, pushes to a registry if credentials are set
Notes
- The frontend uses a random port each run to avoid port conflicts between builds
- Registry push is skipped if
REGISTRY_URL,REGISTRY_USER,REGISTRY_TOKENare not set — build still passes - Demo credentials are hardcoded in
docker-compose.yml— fine for a throwaway CI stack, not for production - The stack is never torn down between runs — a cleanup stage would make reruns fully reproducible
Task 3 — SSH: Key Discovery and Transfer
What I Did
Wrote a Bash script that SSHes into a server, finds all SSH keys on it, and copies them to a second server.
Both servers are Docker containers (built from Dockerfile.sshd) running real SSH daemons — source on port 2222, destination on 2223. The source was seeded with real keys: RSA, Ed25519, a .pem, and authorized_keys.
How the Script Works (script.sh)
The script takes source and destination host/port/user/password as arguments. It runs 5 stages:
-
Discover — runs
sudo find /on the source over SSH, looking for files matchingid_rsa*,id_ed25519*,*.pem,*.key,authorized_keys*,known_hosts*. Usessudoso root-owned keys aren't missed. Excludes/proc,/sys,/etc/ssl,/usrto avoid unrelated system certificates. -
Pack — uploads the list of found paths to the source, then tars them all into one archive (
collected_keys.tar.gz) on the source server. -
Retrieve — downloads the archive from the source to a local staging folder.
-
Upload — pushes the archive to the destination server.
-
Extract — unpacks the archive on the destination, fixes file ownership, lists recovered files, then deletes the archive from both servers.
sshpass is used to supply passwords non-interactively. StrictHostKeyChecking=no is set so the script works with containers (which get new host keys on every rebuild).
Verification
MD5 checksums were compared before and after — all 6 files matched:
source: 5575223f2ebaaf0bdccb86c93c6d0d34 deploy_key.pem
destination: 5575223f2ebaaf0bdccb86c93c6d0d34 deploy_key.pem
File permissions (600) were also preserved since tar stores them.
Notes
StrictHostKeyChecking=nodisables host verification — necessary for containers but dangerous in real use (removes protection against man-in-the-middle attacks)sshpassexposes the password in the process list while running — not suitable for productionssh_transfer/(raw scan, path list, archive) is gitignored and not committed
Task 4 — Terraform: Infrastructure as Code on AWS
What I Did
Used Terraform to create, modify, and destroy an AWS infrastructure stack — the full build → change → destroy lifecycle. Ran against LocalStack (a local AWS emulator) so no real AWS account was needed.
11 resources defined in main.tf:
| # | Resource | Details |
|---|---|---|
| 1 | VPC | 10.0.0.0/16 |
| 2 | Subnet | 10.0.1.0/24, public |
| 3 | Internet Gateway | — |
| 4 | Route Table | default route to gateway |
| 5 | Route Table Association | links subnet to route table |
| 6 | Security Group | ingress on ports 80, 443, 22 |
| 7 | EC2 Instance | t3.micro, running |
| 8 | S3 Bucket | my-localstack-bucket-dev |
| 9 | DynamoDB Table | users-table, on-demand billing |
| 10 | SQS Queue | main-queue, 4-day retention |
| 11 | SNS Topic | main-topic |
Build, Change, Destroy
Build: terraform init → validate → apply — all 11 resources created. Running plan right after confirmed: No changes. Your infrastructure matches the configuration.
Change: Two types of changes were tested:
- Changing instance type (
t3.micro→t3.small) = in-place update, no downtime - Changing the bucket name = forced replacement (destroy old + create new), because bucket names are immutable in AWS
Destroy: terraform destroy removed all 11 resources in reverse dependency order. Verified with AWS CLI that resources were actually gone. Re-applying created new resources with different IDs, confirming it was a real teardown.
Notes
- AMI is a placeholder (
ami-12345678) — LocalStack accepts it, real AWS won't - Port 22 is open to
0.0.0.0/0— should be restricted to a specific IP range in production - Credentials are hardcoded as
test/test— required for LocalStack, never do this on real AWS force_destroyis not set on the S3 bucket — destroy only worked because the bucket was emptyterraform.tfstateand plan files are gitignored — they can contain sensitive data
Task 5 — Wireshark: Traffic Analysis and Fault Diagnosis
What I Did
Captured my own network traffic with Wireshark while doing the Level 3 tasks. Used the capture to diagnose a real fault that was happening at the time.
Capture file: marvel-l3.pcapng — 3,585 packets, 1,705 kB, 93 seconds (Wi-Fi interface wlp3s0).
Traffic Overview
| Protocol | Packets |
|---|---|
| TCP (total) | 3,181 (of which 1,492 carry TLS) |
| DNS | 184 |
| QUIC | 161 |
| UDP (other) | 69 |
| ARP / ICMPv6 | 14 |
All 92 DNS responses returned NOERROR — DNS was not the problem. No plaintext HTTP in the entire capture. IPv6 carried 3,213 packets vs 364 for IPv4 — this is an IPv6-preferring machine, which turned out to be the root cause of the fault.
The Fault — LocalStack Unreachable
Symptom: The LocalStack emulator (local AWS emulator running on port 4566) was completely unreachable for the entire 93-second window.
Clue from Wireshark (Statistics → Conversations → TCP): One address received 310 out of 333 total retransmissions (93%) — all going to 64:ff9b::7f00:1 on port 4566. Zero successful connections.
What that address means: 64:ff9b::7f00:1 is an IPv6 address. The last 32 bits decode to 127.0.0.1. This is a NAT64 address — the machine was trying to reach its own localhost over IPv6, which got routed through the NAT64 gateway instead of staying local. The SYN packets were delivered to the gateway's loopback — not the local machine — so nothing ever answered.
Evidence it was a real failure (not a capture gap):
- 349 SYNs sent, 0 SYN-ACKs received on port 4566
- Each connection retried with exponential backoff (1s, 2s, 4s, 8s...) before giving up after ~69 seconds
- LocalStack was running and healthy on
127.0.0.1:4566the whole time
Root Cause and Fix
The hostname localhost.localstack.cloud has two DNS records:
A 127.0.0.1
AAAA 64:ff9b::7f00:1
Because this machine prefers IPv6, it picked the AAAA record. That IPv6 address routes through the NAT64 gateway, which forwards to 127.0.0.1 on the gateway, not the local machine. LocalStack never received the connection.
Fix: Use the IPv4 literal http://127.0.0.1:4566 instead of the hostname. The Terraform config already does this. The Lambda handler.py still uses the hostname — that's the one place left to fix.
Notes
marvel-l3.pcapngis not committed to this repo- Even with all traffic encrypted, DNS queries and TLS hostnames reveal every site visited — the capture contains no credentials but is still sensitive
Task 6 — Docker: Containers, Images, and Dockerfiles
What I Did
Completed the Docker Get Started course: running containers, building images, persisting data, multi-container apps, and basics of Kubernetes. Examples below are from the Dockerfiles already in this repo.
Key Concepts
Image vs Container: An image is a template. A container is a running instance of that image. Multiple containers can share the same image — in Task 3, two SSH containers were started from one image and shared the same base layers, saving disk space.
Layers: Each line in a Dockerfile creates a layer. Changing one line invalidates that layer and everything after it. So heavy steps (like apt-get install) go near the top, app code near the bottom — this way code changes don't re-run installs.
apt-get update and apt-get install are kept in a single RUN command so a cached (stale) package index is never used with a fresh install step.
Common Dockerfile instructions:
FROM— base image to start fromRUN— runs a command at build time (creates a layer)COPY— copies files into the imageWORKDIR— sets the working directoryEXPOSE— documents which port the app uses (doesn't actually publish it)
Volumes and Networking
Bind mounts link a folder on the host into the container. Marked :ro (read-only) where the container shouldn't be able to change them (e.g. SQL schema files, nginx config).
Named volumes are managed by Docker and persist across container restarts. Used for the database so data survives docker compose down.
Containers on the same Docker network can reach each other by name. That's why nginx can say proxy_pass http://backend:80 — Docker resolves backend to the right container's IP automatically.
Docker vs Podman
This machine uses Podman behind the Docker CLI (DOCKER_HOST points to Podman's socket). The docker command works normally but is actually talking to Podman:
Client: Docker CLI v29.8.1
Server: Podman v5.4.2
| Docker | Podman | |
|---|---|---|
| Runs as | Root (daemon) | Regular user (no daemon) |
| Storage | /var/lib/docker | ~/.local/share/containers/storage |
| Default network name | bridge | podman |
All commands used in Tasks 2 and 3 (run, build, compose, inspect) worked without any changes.
Notes
- Neither Dockerfile sets a
USER— both containers run as root inside, which is fine for this exercise but should be changed in production
Task 7 — Dockerize the Web Application (No Compose File)
What I Did
Containerized the Level 0 password manager app using only docker run — no docker-compose.yml. Three containers on one shared network: db, backend, frontend.
Backend Dockerfile (task_docker/backend/Dockerfile):
FROM php:8.2-apache
RUN docker-php-ext-install pdo_mysql mysqli && a2enmod rewrite
WORKDIR /var/www/html
COPY backend/ /var/www/html/
RUN sed -i 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf
EXPOSE 80
Database (mysql:8.0) and frontend (nginx:alpine) use stock images. All three are connected to a single bridge network named pm-net.
Issues Found
docker build without --load silently does nothing. The build completes without error but the image isn't saved where docker run can find it. Must use docker build --load to write it to the local image store.
Podman ignores HEALTHCHECK in Dockerfiles. The instruction is stored in the image but never runs at startup. Health checks must be passed via command-line flags instead: --health-cmd, --health-interval, --health-start-period.
Can't use curl -f for the backend health check. The API returns 401 without a session and 404 at / — both cause curl -f to fail even when the server is working. The health check was changed to accept any HTTP response (just checking the server started), and connection refused still fails correctly.
Rootless Podman can't bind port 80. -p 80:80 fails with a "privileged port" error. App runs on port 8000 instead (-p 8000:80).
Storage
- Database uses a named volume (
pm-db-data) — survives container restarts and rebuilds - SQL schema/seed files mounted read-only into
/docker-entrypoint-initdb.d/ - Init scripts only run when the data directory is empty — editing
schema.sqlhas no effect once the volume exists
Anonymous volume trap: If the MySQL container is started without specifying a volume, Docker silently creates an unnamed one. Removing the container loses it forever with no error. Always use a named volume.
Verification
Registered a user through the API, then confirmed the row was saved directly in the database:
POST /api/auth/register → 201, token returned
SELECT from USER table → row present with argon2id hash
After removing and rebuilding all containers (keeping only the named volume), the database came back with all previous data intact — init scripts did not re-run.
