Skip to content

Commit df1c76e

Browse files
committed
first commit
0 parents  commit df1c76e

File tree

165 files changed

+18533
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+18533
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @snyk/devrel
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: log4shell-goof-server Docker image build and test
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- 'log4shell-goof/log4shell-goof-server/**'
9+
- '.github/workflows/log4shell-goof-server-docker-image.yaml'
10+
pull_request:
11+
branches:
12+
- 'main'
13+
paths:
14+
- 'log4shell-goof/log4shell-goof-server/**'
15+
- '.github/workflows/log4shell-goof-server-docker-image.yaml'
16+
jobs:
17+
18+
build-log4shell-server-image:
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
working-directory: log4shell-goof/log4shell-server
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v1
28+
29+
- name: Build
30+
uses: docker/build-push-action@v2
31+
with:
32+
load: true
33+
context: log4shell-goof/log4shell-server
34+
push: false
35+
tags: log4shell-server:latest
36+
37+
- name: Run container
38+
run: docker run -d --rm --name log4shell-server log4shell-server:latest && sleep 5
39+
40+
- name: Smoke test LDAP running in container
41+
run: docker logs log4shell-server | grep "LDAP server listening on 0.0.0.0:8000"
42+
43+
- name: Smoke test HTTP running in container
44+
run: docker logs log4shell-server | grep "HTTP server listening on 0.0.0.0:9999"
45+
46+
- name: Cleanup container
47+
run: docker kill log4shell-server
48+
49+
- name: Start minikube
50+
uses: medyagh/setup-minikube@master
51+
with:
52+
cni: calico
53+
54+
- name: Deploy to minikube
55+
run: |
56+
sed -i 's/${DOCKER_ACCOUNT}\///' k8s/deploy.yaml
57+
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/deploy.yaml
58+
minikube image load log4shell-server:latest
59+
kubectl apply -f k8s/deploy.yaml
60+
61+
- name: Test pods came up cleanly
62+
run: |
63+
kubectl get all --namespace=darkweb && \
64+
kubectl wait --namespace=darkweb --for=condition=ready pod --selector=app=log4shell --timeout=90s
65+
66+
- name: Dump pod description
67+
if: ${{ failure() }}
68+
run: |
69+
kubectl describe pod --namespace=darkweb --selector=app=log4shell
70+
kubectl describe deploy --namespace=darkweb --selector=app=log4shell
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: todolist-goof Docker image build and test
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- 'todolist-goof/**'
9+
- '.github/workflows/todolist-goof-docker-image.yaml'
10+
pull_request:
11+
branches:
12+
- 'main'
13+
paths:
14+
- 'todolist-goof/**'
15+
- '.github/workflows/todolist-goof-docker-image.yaml'
16+
17+
jobs:
18+
build-todolist-image:
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
working-directory: todolist-goof
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v1
28+
29+
- name: Build
30+
uses: docker/build-push-action@v2
31+
with:
32+
load: true
33+
context: todolist-goof
34+
push: false
35+
tags: java-goof:latest
36+
37+
- name: Run container
38+
run: docker run -d --rm --name java-goof -p 8080:8080 java-goof:latest
39+
40+
- name: Smoke test container
41+
run: sleep 5 && curl -s --retry 5 --retry-delay 1 --retry-max-time 30 http://localhost:8080/todolist/
42+
43+
- name: Teardown container
44+
run: docker kill java-goof
45+
46+
- name: Start minikube
47+
uses: medyagh/setup-minikube@master
48+
with:
49+
cni: calico
50+
51+
- name: Deploy to minikube
52+
run: |
53+
sed -i 's/${DOCKER_ACCOUNT}\///' k8s/java-goof.yaml
54+
sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/java-goof.yaml
55+
minikube image load java-goof:latest
56+
kubectl apply -f k8s/java-goof.yaml
57+
58+
- name: Test pod came up cleanly
59+
run: |
60+
kubectl get all
61+
kubectl wait --for=condition=ready pod --selector=app=goof --timeout=90s
62+
63+
- name: Dump pod description
64+
if: ${{ failure() }}
65+
run: kubectl describe pod --selector=app=goof

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.iml
2+
.idea
3+
**/target/**
4+
**/.DS_Store

README-K8S.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Kubernetes based Todolist + Log4Shell exploit
2+
To deploy Todolist on Kubernetes along with the needed ldap backend for exploiting the Log4shell
3+
vulnerability:
4+
5+
## Prerequisites
6+
1. A kubernetes cluster where you have permissions to create namespaces, deployments and services
7+
2. The `kubectl` client and credenials configuration
8+
3. Docker Desktop or docker-ce (for building and pushing images)
9+
4. A DockerHub account that you are logged in with at the command prompt (via `docker login`)
10+
11+
## Quickstart
12+
Assuming you have your kubernetes cluster up and ready, from the top level of this repo you can run `./k8s-quickstart.sh` which will do the following:
13+
1. Builds todolist-goof image and pushes it to Docker Hub. _(see below for account/tagging info)_
14+
2. Deploys the todolist to the `default` namespace in your kubernetes cluster along with a LoadBalancer type service
15+
3. Builds the log4shell-server image and pushes to Docker Hub. _(see below for account/tagging info)_
16+
4. Deploys the log4shell-server and a pair of ClusterIP type services into a new namespace named `darkweb` in your Kubernetes cluster.
17+
18+
NOTE: You will be prompted for your DockerHub account in order for the scripts to tag, push and pull the images.
19+
If you set and environmental variable named `DOCKER_ACCOUNT` to that account name, the script will pre-populate that prompt with it.
20+
```bash
21+
export DOCKER_ACCOUNT="yourdockeraccount"
22+
```
23+
## Accessing the application
24+
Once complete, run `kubectl get svc` and note the IP Address or hostname of the `goof` service.
25+
26+
You should be able to open a browser to http://{svc-ip-addr}/todolist and see the app
27+
28+
#### EKS cluster notes
29+
* In order to perform NetworkPolicy egress examples, you will need to deploy the Calico CNI plugin as EKS does not implement NetworkPolicy by default.
30+
The `eks-calico.sh` script in `todolist-goof/k8s` will deploy this for you. (that script is sym-linked to the top level here too)
31+
* You should log into the AWS console and change inbound access for the good service's ELB to only allow your home IP, otherwise you *will* have audience members trying to mess with it.
32+
33+
#### Docker Desktop Kubernetes notes
34+
* Docker Desktop automatically serves the goof service loadblancer external IP to your workstation's localhost so the app will be available at http://localhost/todolist
35+
* Docker Desktop Kubernetes CNI does not implement Network Policy so you will not be able to demonstrate any mitigation techniques that use that.
36+
37+
#### Kind (Kubernetes on Docker) notes
38+
* Kind's default CNI does not currently support Network Policy so you should deploy your own using the instructions on their website.
39+
* If running Kind on top of Docker Desktop, you will need to run a port-forward to access the app. For example, use something like this: `kubectl port-forward service/goof 8000:80` and then access it via browser at http://localhost:8000/todolist
40+
41+
## Quick cleanup
42+
Run the `/.k8s-quickstop.sh` script at the top level of this repo which will do the following:
43+
1. Deletes the todolist deployment and associated service in the `default` namespace
44+
2. Deletes the log4shell deployment and associated services in the `darkweb` namespace and deltes the namespace as well
45+
**Note:** This will not delete any additional objects you may have deployed such as NetworkPolicies.
46+
47+
It is up to you to shut down your Kubernetes cluster as appropriate.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Java Goof
2+
3+
This is a collection of Java demo apps that are vulnerable in different ways.
4+
5+
It's divided into modules, each one having its own README:
6+
7+
* [Todolist Goof](todolist-goof/README.md)
8+
* [Log4Shell Goof](log4shell-goof/README.md)
9+
* [Quickstart for running both Todolist with Log4Shell in Kubernetes](README-K8S.md)

eks-calico.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
todolist-goof/k8s/eks-calico.sh

k8s-quickstart.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
TOP_LEVEL_MYDIR=$(dirname $0)
3+
if [[ "$1" == "" ]]; then
4+
read -e -i "${DOCKER_ACCOUNT}" -p "Please enter your DockerHub user/account name: " input
5+
name="${input:-$DOCKER_ACCOUNT}"
6+
else
7+
DOCKER_ACCOUNT=$1
8+
fi
9+
$TOP_LEVEL_MYDIR/todolist-goof/k8s/quickstart.sh $DOCKER_ACCOUNT
10+
$TOP_LEVEL_MYDIR/log4shell-goof/log4shell-server/k8s/quickstart.sh $DOCKER_ACCOUNT

k8s-quickstop.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
TOP_LEVEL_MYDIR=$(dirname $0)
3+
$TOP_LEVEL_MYDIR/todolist-goof/k8s/shutdown.sh
4+
$TOP_LEVEL_MYDIR/log4shell-goof/log4shell-server/k8s/shutdown.sh

kind-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
todolist-goof/k8s/kind-init.sh

0 commit comments

Comments
 (0)