Skip to content

Commit 6878b1e

Browse files
authored
Merge pull request #388 from commjoen/okteo
Add Okteto support, enable hosted-wrongsecrets hint alternatives, fixes for GCP/AWS/Azure & introduce latest docker tag
2 parents 6bff8e9 + 7346ba6 commit 6878b1e

Some content is hidden

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

48 files changed

+400
-33
lines changed

.github/scripts/docker-create.sh

+33-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Help() {
77
# Display Help
88
echo "A versatile script to create a docker image for testing. Call this script with no arguments to simply create a local image that you can use to test your changes. For more complex use see the below help section"
99
echo
10-
echo "Syntax: docker-create.sh [-h (help)|-t (test)|-p (publish)|-e (herokud)|-f (herokup)|-g (fly)|-n (notag) [tag={tag}|message={message}|buildarg={buildarg}|springProfile={springProfile}]"
10+
echo "Syntax: docker-create.sh [-h (help)|-t (test)|-p (publish)|-e (herokud)|-f (herokup)|-g (fly)|-o (okteto)|-n (notag) [tag={tag}|message={message}|buildarg={buildarg}|springProfile={springProfile}]"
1111
echo "options: (All optional)"
1212
echo "tag= Write a custom tag that will be added to the container when it is build locally."
1313
echo "message= Write a message used for the actual tag-message in git"
@@ -28,6 +28,23 @@ break_on_tag(){
2828
exit
2929
fi
3030
}
31+
32+
Okteto_redeploy(){
33+
break_on_tag
34+
echo "Rebuilding the Okteto environment: https://wrongsecrets-commjoen.cloud.okteto.net/"
35+
echo "Check if all required binaries are installed"
36+
source ../../scripts/check-available-commands.sh
37+
checkCommandsAvailable okteto
38+
echo "validating okteto k8 deployment to contain the right container with tag "${tag}" (should be part of '$(cat ../../okteto/k8s/secret-challenge-deployment.yml | grep image)')"
39+
if [[ "$(cat ../../okteto/k8s/secret-challenge-deployment.yml | grep image)" != *"${tag}"* ]]; then
40+
echo "tag ${tag} in ../../okteto/k8s/secret-challenge-deployment.yml not properly set, aborting"
41+
exit
42+
fi
43+
cd ../../okteto
44+
okteto destroy
45+
okteto deploy
46+
}
47+
3148
heroku_check_container() {
3249
break_on_tag
3350
echo "validating dockerfile to contain tag "${tag}" (should be part of '$(head -n 1 ../../Dockerfile.web)')"
@@ -90,7 +107,7 @@ Fly_publish(){
90107
# Set option to local if no option provided
91108
script_mode="local"
92109
# Parse provided options
93-
while getopts ":htpefgn*" option; do
110+
while getopts ":htpefgon*" option; do
94111
case $option in
95112
h) # display Help
96113
Help
@@ -111,6 +128,9 @@ while getopts ":htpefgn*" option; do
111128
g) #Helper
112129
script_mode="fly_p"
113130
;;
131+
o) #okteto
132+
script_mode="okteto"
133+
;;
114134
n) #notags
115135
disable_tagging_in_git="true"
116136
;;
@@ -127,7 +147,7 @@ done
127147
################################################
128148
for ARGUMENT in "$@";
129149
do
130-
if [[ $ARGUMENT != "-h" && $ARGUMENT != "-t" && $ARGUMENT != "-p" && $ARGUMENT != "-e" && $ARGUMENT != "-f" && $ARGUMENT != "-g" ]]
150+
if [[ $ARGUMENT != "-h" && $ARGUMENT != "-t" && $ARGUMENT != "-p" && $ARGUMENT != "-e" && $ARGUMENT != "-f" && $ARGUMENT != "-g" && $ARGUMENT != "-o" ]]
131151
then
132152
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
133153
KEY_LENGTH=${#KEY}
@@ -188,6 +208,8 @@ elif [[ $script_mode == "heroku_p" ]]; then
188208
Heroku_publish_prod
189209
elif [[ $script_mode == "fly_p" ]]; then
190210
Fly_publish
211+
elif [[ $script_mode == "okteto" ]]; then
212+
Okteto_redeploy
191213
fi
192214

193215

@@ -274,13 +296,20 @@ create_containers() {
274296
echo "Creating containers"
275297
if [[ "$script_mode" == "publish" ]]; then
276298
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
299+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
277300
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
301+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
278302
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
303+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
279304
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
305+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
280306
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
307+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
281308
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
309+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
282310
cd ../..
283-
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:$tag -f Dockerfile.webdesktop --push .
311+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:$tag -f Dockerfile_webdesktop --push .
312+
docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:latest -f Dockerfile_webdesktop --push .
284313
cd .github/scripts
285314
elif [[ "$script_mode" == "test" ]]; then
286315
docker buildx build -t jeroenwillemsen/wrongsecrets:$tag --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --load ./../../.

Dockerfile.web

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM jeroenwillemsen/wrongsecrets:jre18test2-no-vault
1+
FROM jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
22

3-
ARG argBasedVersion="1.5.2"
3+
ARG argBasedVersion="1.5.3RC1"
44
ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
55
ARG CTF_ENABLED=false
66
ARG HINTS_ENABLED=true

Dockerfile.webdesktop renamed to Dockerfile_webdesktop

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ RUN \
99
touch /var/run/docker.sock && \
1010
chown abc:abc /var/run/docker.sock && \
1111
echo "**** cleanup ****" && \
12-
rm -rf \
13-
/tmp/*
12+
rm -rf /tmp/*
1413

1514
WORKDIR /config/Desktop
1615

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Welcome to the OWASP WrongSecrets p0wnable app. With this app, we have packed va
1010
secrets. These can help you to realize whether your secret management is ok. The challenge is to find all the different
1111
secrets by means of various tools and techniques.
1212

13-
Can you solve all the 23 challenges?
13+
Can you solve all the 24 challenges?
1414
![screenshot.png](screenshot.png)
1515

1616
## Support
@@ -24,7 +24,7 @@ based project, so it might take a little while before we respond.
2424

2525
## Basic docker exercises
2626

27-
_Can be used for challenges 1-4, 8, 12-23_
27+
_Can be used for challenges 1-4, 8, 12-24_
2828

2929
For the basic docker exercises you currently require:
3030

@@ -34,7 +34,7 @@ For the basic docker exercises you currently require:
3434
You can install it by doing:
3535

3636
```bash
37-
docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:1.5.2-no-vault
37+
docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:latest-no-vault
3838
```
3939

4040
Now you can try to find the secrets by means of solving the challenge offered at:
@@ -56,6 +56,7 @@ Now you can try to find the secrets by means of solving the challenge offered at
5656
- [localhost:8080/challenge/21](http://localhost:8080/challenge/21)
5757
- [localhost:8080/challenge/22](http://localhost:8080/challenge/22)
5858
- [localhost:8080/challenge/23](http://localhost:8080/challenge/23)
59+
- [localhost:8080/challenge/24](http://localhost:8080/challenge/24)
5960

6061
Note that these challenges are still very basic, and so are their explanations. Feel free to file a PR to make them look
6162
better ;-).
@@ -81,7 +82,7 @@ spoiling it for others that want to testdrive it.
8182

8283
## Basic K8s exercise
8384

84-
_Can be used for challenges 1-6, 8, 12-23_
85+
_Can be used for challenges 1-6, 8, 12-24_
8586

8687
### Minikube based
8788

@@ -126,9 +127,13 @@ now you can use the provided IP address and port to further play with the K8s va
126127
- [localhost:8080/challenge/5](http://localhost:8080/challenge/5)
127128
- [localhost:8080/challenge/6](http://localhost:8080/challenge/6)
128129

130+
### Okteto based
131+
132+
Don't want to go over the hassle of setting up K8S yourself? visit [https://wrongsecrets-commjoen.cloud.okteto.net](https://wrongsecrets-commjoen.cloud.okteto.net/). Please note that we are using the free Developer version here, so it might take a while for it to respond. Please: do not try to hack/Fuzz the application as this might bring it down and spoil the fun for others.
133+
129134
## Vault exercises with minikube
130135

131-
_Can be used for challenges 1-8, 12-23_
136+
_Can be used for challenges 1-8, 12-24_
132137
Make sure you have the following installed:
133138

134139
- minikube with docker (or comment out line 8 and work at your own k8s setup),
@@ -148,7 +153,7 @@ vault and not update the secret-challenge application with the new secret.
148153

149154
## Cloud Challenges
150155

151-
_Can be used for challenges 1-23_
156+
_Can be used for challenges 1-24_
152157

153158
**READ THIS**: Given that the exercises below contain IAM privilege escalation exercises,
154159
never run this on an account which is related to your production environment or can influence your account-over-arching
@@ -370,7 +375,7 @@ If you want to play the challenges, but cannot install tools like keepass, Radar
370375
containers, try the following:
371376

372377
```shell
373-
docker run -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock jeroenwillemsen/wrongsecrets-desktop:1.5.2
378+
docker run -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock jeroenwillemsen/wrongsecrets-desktop:latest
374379
```
375380

376381
or use something more configurable:
@@ -386,9 +391,9 @@ docker run -d \
386391
-e KEYBOARD=en-us-qwerty \
387392
-p 3000:3000 \
388393
-v /var/run/docker.sock:/var/run/docker.sock \
389-
--shm-size="1gb" \
394+
--shm-size="2gb" \
390395
--restart unless-stopped \
391-
jeroenwillemsen/wrongsecrets-desktop:1.5.2
396+
jeroenwillemsen/wrongsecrets-desktop:latest
392397
```
393398

394399
And then at [http://localhost:3000](http://localhost:3000).

aws/k8s/secret-challenge-vault-deployment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
volumeAttributes:
3838
secretProviderClass: "wrongsecrets-aws-secretsmanager"
3939
containers:
40-
- image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
40+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
4141
imagePullPolicy: IfNotPresent
4242
ports:
4343
- containerPort: 8080

azure/k8s-vault-azure-start.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ source ../scripts/install-consul.sh
5353
source ../scripts/install-vault.sh
5454

5555
echo "Add secrets manager driver to repo"
56-
helm repo add csi-secrets-store-provider-azure https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/charts
56+
helm repo add csi-secrets-store-provider-azure https://azure.github.io/secrets-store-csi-driver-provider-azure/charts
5757

5858
helm list --namespace kube-system | grep 'csi-secrets-store' &>/dev/null
5959
if [ $? == 0 ]; then
6060
echo "CSI driver is already installed"
6161
else
6262
echo "Installing CSI driver"
63-
helm install -n kube-system csi csi-secrets-store-provider-azure/csi-secrets-store-provider-azure
63+
helm install csi csi-secrets-store-provider-azure/csi-secrets-store-provider-azure
6464
fi
6565

6666
echo "Add Azure pod identity to repo"

azure/k8s/secret-challenge-vault-deployment.yml.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
volumeAttributes:
3636
secretProviderClass: "azure-wrongsecrets-vault"
3737
containers:
38-
- image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
38+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
3939
imagePullPolicy: IfNotPresent
4040
ports:
4141
- containerPort: 8080

fly.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ processes = []
99
dockerfile = "Dockerfile"
1010

1111
[build.args]
12-
argBasedVersion="1.5.2"
12+
argBasedVersion="1.5.3RC1"
1313
spring_profile="without-vault"
14-
argBasedEnv="Fly(Docker)"
1514

1615
[env]
1716
K8S_ENV="Fly(Docker)"

gcp/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Make sure you have an active account at GCP for which you have configured the cr
2020

2121
If you want to host a multi-user setup, you will probably want to share the state file so that everyone can try related challenges. We have provided a starter to easily do so using a Terraform gcs backend.
2222

23-
First, create an s3 bucket:
23+
First, create an storage bucket:
2424

2525
1. Navigate to the 'shared-state' directory `cd shared-state`
2626
2. Change the `project_id` in the `terraform.tfvars` file to your project id
@@ -44,7 +44,7 @@ The bucket name should be in the output. Please use that to configure the Terraf
4444
5. Run `terraform init` (if required, use tfenv to select TF 0.14.0 or higher )
4545
6. Run `terraform plan`
4646
7. Run `terraform apply`. Note: the apply will take 10 to 20 minutes depending on the speed of the GCP backplane.
47-
8. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`
47+
8. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`. Note if it errors on a missing plugin to support `kubectl`, then run `gcloud components install gke-gcloud-auth-plugin` and `gcloud container clusters get-credentials wrongsecrets-exercise-cluster` .
4848
9. Run `./k8s-vault-gcp-start.sh`
4949

5050
### GKE ingres for shared deployment

gcp/k8s-vault-gcp-start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo "This is a script to bootstrap the configuration. You need to have installe
1111
echo "This script is based on the steps defined in https://learn.hashicorp.com/tutorials/vault/kubernetes-minikube. Vault is awesome!"
1212

1313
export GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
14-
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
14+
#export USE_GKE_GCLOUD_AUTH_PLUGIN=True
1515

1616
kubectl get configmaps | grep 'secrets-file' &>/dev/null
1717
if [ $? == 0 ]; then

gcp/k8s/secret-challenge-vault-deployment.yml.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
volumeAttributes:
3838
secretProviderClass: "wrongsecrets-gcp-secretsmanager"
3939
containers:
40-
- image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
40+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
4141
imagePullPolicy: IfNotPresent
4242
ports:
4343
- containerPort: 8080

k8s/secret-challenge-deployment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
runAsGroup: 2000
2929
fsGroup: 2000
3030
containers:
31-
- image: jeroenwillemsen/wrongsecrets:jre18test2-no-vault
31+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
3232
imagePullPolicy: IfNotPresent
3333
ports:
3434
- containerPort: 8080

k8s/secret-challenge-vault-deployment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
runAsNonRoot: true
3131
serviceAccountName: vault
3232
containers:
33-
- image: jeroenwillemsen/wrongsecrets:jre18test2-k8s-vault
33+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
3434
imagePullPolicy: IfNotPresent
3535
ports:
3636
- containerPort: 8080
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: secret-challenge
6+
name: secret-challenge
7+
namespace: commjoen
8+
spec:
9+
progressDeadlineSeconds: 600
10+
replicas: 1
11+
revisionHistoryLimit: 10
12+
selector:
13+
matchLabels:
14+
app: secret-challenge
15+
strategy:
16+
rollingUpdate:
17+
maxSurge: 25%
18+
maxUnavailable: 25%
19+
type: RollingUpdate
20+
template:
21+
metadata:
22+
labels:
23+
app: secret-challenge
24+
name: secret-challenge
25+
spec:
26+
securityContext:
27+
runAsUser: 2000
28+
runAsGroup: 2000
29+
fsGroup: 2000
30+
containers:
31+
- image: jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
32+
imagePullPolicy: IfNotPresent
33+
ports:
34+
- containerPort: 8080
35+
protocol: TCP
36+
name: secret-challenge
37+
resources: {}
38+
terminationMessagePath: /dev/termination-log
39+
terminationMessagePolicy: File
40+
env:
41+
- name: K8S_ENV
42+
value: Okteto(k8s)
43+
- name: SPECIAL_K8S_SECRET
44+
valueFrom:
45+
configMapKeyRef:
46+
name: secrets-file
47+
key: funny.entry
48+
- name: SPECIAL_SPECIAL_K8S_SECRET
49+
valueFrom:
50+
secretKeyRef:
51+
name: funnystuff
52+
key: funnier
53+
dnsPolicy: ClusterFirst
54+
restartPolicy: Always
55+
schedulerName: default-scheduler
56+
terminationGracePeriodSeconds: 30

okteto/k8s/secrets-config.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
data:
3+
funny.entry: "thisIsK8SConfigMap"
4+
kind: ConfigMap
5+
metadata:
6+
creationTimestamp: "2020-10-29T19:29:38Z"
7+
name: secrets-file
8+
namespace: commjoen
9+
resourceVersion: "4228"
10+
selfLink: /api/v1/namespaces/default/configmaps/secrets-file
11+
uid: d777ebfa-2a53-4bca-b1e3-4907eca16552

okteto/k8s/secrets-secret.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
data:
3+
funnier: dGhpcyBpcyBhcGFzc3dvcmQ=
4+
kind: Secret
5+
metadata:
6+
creationTimestamp: "2020-10-29T20:49:16Z"
7+
managedFields:
8+
- apiVersion: v1
9+
fieldsType: FieldsV1
10+
fieldsV1:
11+
f:data:
12+
.: {}
13+
f:funnier.entry: {}
14+
f:type: {}
15+
manager: kubectl-create
16+
operation: Update
17+
time: "2020-10-29T20:49:16Z"
18+
name: funnystuff
19+
namespace: commjoen
20+
resourceVersion: "6559"
21+
selfLink: /api/v1/namespaces/default/secrets/funnystuff
22+
uid: baee7f4a-5161-4777-a512-3d236d3573d4
23+
type: Opaque

0 commit comments

Comments
 (0)