Skip to content

Commit a86063b

Browse files
authored
Merge pull request #2400 from OWASP/copilot/add-mcp-challenge-endpoint
feat: Add Challenge 60 — insecure MCP server with prompt injection leaking env var secrets
2 parents 5ce426c + 96fda14 commit a86063b

File tree

54 files changed

+954
-215
lines changed

Some content is hidden

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

54 files changed

+954
-215
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class Challenge[Number]Test {
202202
docker build -t wrongsecrets .
203203

204204
# Run locally
205-
docker run -p 8080:8080 wrongsecrets
205+
docker run -p 8080:8080 -p 8090:8090 wrongsecrets
206206
```
207207

208208
## Testing Guidelines

.github/scripts/.bash_history

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ rm -rf jdk-18_linux-x64_bin.deb
347347
git rebase -i main
348348
git rebase -i master
349349
git stash
350-
export tempPassword="Mvd9twjm41byoPqwaY66rZ8/xJ8FNQQnGW8jPMlMocw="
350+
export tempPassword="OeyxzcLdUbln0KxnhlQaT2wQKfpJpV/A7/ach+erH4M="
351351
mvn run tempPassword
352352
k6
353353
npx k6

.github/scripts/docker-create.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ Heroku_publish_demo() {
6464
heroku container:login
6565
echo "heroku deployment to demo"
6666
cd ../..
67-
heroku container:push --recursive --arg argBasedVersion=${tag}heroku --app arcane-scrubland-42646
67+
# heroku container:push --recursive --arg argBasedVersion=${tag}heroku --app arcane-scrubland-42646
68+
heroku container:push --arg argBasedVersion=${tag}heroku --app arcane-scrubland-42646
6869
heroku container:release web --app arcane-scrubland-42646
69-
heroku container:push --recursive --arg argBasedVersion=${tag}heroku,CTF_ENABLED=true,HINTS_ENABLED=false --app wrongsecrets-ctf
70-
heroku container:release web --app wrongsecrets-ctf
70+
# heroku container:push --recursive --arg argBasedVersion=${tag}heroku,CTF_ENABLED=true,HINTS_ENABLED=false --app wrongsecrets-ctf
71+
# heroku container:release web --app wrongsecrets-ctf
7172
echo "wait for contianer to come up"
7273
until curl --output /dev/null --silent --head --fail https://arcane-scrubland-42646.herokuapp.com/; do
7374
printf '.'
@@ -236,7 +237,7 @@ local_extra_info() {
236237
if [[ $script_mode == "local" ]] ; then
237238
echo ""
238239
echo "⚠️⚠️ This script is running in local mode, with no arguments this script will build your current code and package into a docker container for easy local testing"
239-
echo "If the container gets built correctly you can run the container with the command: docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:local-test, if there are errors the script should tell you what to do ⚠️⚠️"
240+
echo "If the container gets built correctly you can run the container with the command: docker run -p 8080:8080 -p 8090:8090 jeroenwillemsen/wrongsecrets:local-test, if there are errors the script should tell you what to do ⚠️⚠️"
240241
echo ""
241242
fi
242243
}
@@ -447,7 +448,7 @@ test() {
447448
if [[ "$script_mode" == "test" ]]; then
448449
echo "Running the tests"
449450
echo "Starting the docker container"
450-
docker run -d -p 8080:8080 jeroenwillemsen/wrongsecrets:local-test
451+
docker run -d -p 8080:8080 -p 8090:8090 jeroenwillemsen/wrongsecrets:local-test
451452
until $(curl --output /dev/null --silent --head --fail http://localhost:8080); do
452453
printf '.'
453454
sleep 5

.github/workflows/container-alts-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- uses: actions/checkout@v5
2020
- name: run container
2121
run: |
22-
podman run -dt -p 8080:8080 docker.io/jeroenwillemsen/wrongsecrets:latest-no-vault && \
22+
podman run -dt -p 8080:8080 -p 8090:8090 docker.io/jeroenwillemsen/wrongsecrets:latest-no-vault && \
2323
echo "wait 20 seconds for container to come up" && sleep 20 && \
2424
curl localhost:8080

.github/workflows/master-container-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
echo "**🐳 Try the bleeding-edge version:**" >> $GITHUB_STEP_SUMMARY
117117
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
118118
echo "docker pull ghcr.io/${{ github.repository }}/wrongsecrets-master:latest-master" >> $GITHUB_STEP_SUMMARY
119-
echo "docker run -p 8080:8080 ghcr.io/${{ github.repository }}/wrongsecrets-master:latest-master" >> $GITHUB_STEP_SUMMARY
119+
echo "docker run -p 8080:8080 -p 8090:8090 ghcr.io/${{ github.repository }}/wrongsecrets-master:latest-master" >> $GITHUB_STEP_SUMMARY
120120
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
121121
echo "" >> $GITHUB_STEP_SUMMARY
122122
echo "Then visit: http://localhost:8080" >> $GITHUB_STEP_SUMMARY

.github/workflows/minikube-k8s-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
kubectl expose deployment secret-challenge --type=LoadBalancer --port=8080
6363
kubectl port-forward \
6464
$(kubectl get pod -l app=secret-challenge -o jsonpath="{.items[0].metadata.name}") \
65-
8080:8080 \
65+
8080:8080 8090:8090 \
6666
&
6767
echo "Do minikube delete to stop minikube from running and cleanup to start fresh again"
6868
echo "wait 20 seconds so we can check if vault-k8s-container works"

.github/workflows/pr-preview.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ jobs:
178178
\`\`\`bash
179179
# Download the artifact, extract it, then:
180180
docker load < wrongsecrets-preview.tar
181-
docker run -p 8080:8080 wrongsecrets-preview
181+
docker run -p 8080:8080 -p 8090:8090 wrongsecrets-preview
182182
\`\`\`
183183
184184
**🚀 Alternative - Pull from Registry:**
185185
\`\`\`bash
186186
docker pull ${imageTag}
187-
docker run -p 8080:8080 ${imageTag}
187+
docker run -p 8080:8080 -p 8090:8090 ${imageTag}
188188
\`\`\`
189189
190190
Then visit: http://localhost:8080
@@ -318,8 +318,8 @@ jobs:
318318

319319
- name: Start both versions
320320
run: |
321-
docker run -d -p 8080:8080 --name pr-version wrongsecrets-pr
322-
docker run -d -p 8081:8080 --name main-version wrongsecrets-main
321+
docker run -d -p 8080:8080 -p 8090:8090 --name pr-version wrongsecrets-pr
322+
docker run -d -p 8081:8080 -p 8091:8090 --name main-version wrongsecrets-main
323323
324324
# Wait for services to start
325325
echo "Waiting for services to start..."

.github/workflows/visual-diff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ jobs:
7979
8080
- name: Start both versions
8181
run: |
82-
docker run -d -p 8080:8080 --name pr-version wrongsecrets-pr
83-
docker run -d -p 8081:8080 --name main-version wrongsecrets-main
82+
docker run -d -p 8080:8080 -p 8090:8090 --name pr-version wrongsecrets-pr
83+
docker run -d -p 8081:8080 -p 8091:8090 --name main-version wrongsecrets-main
8484
8585
# Wait for containers to start
8686
echo "Waiting for containers to start..."

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM bellsoft/liberica-openjre-debian:25-cds AS builder
22
WORKDIR /builder
33

4-
ARG argBasedVersion="1.12.11"
4+
ARG argBasedVersion="1.13.1-alpha5"
55

66
COPY --chown=wrongsecrets target/wrongsecrets-${argBasedVersion}-SNAPSHOT.jar application.jar
77
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
@@ -18,6 +18,7 @@ ENV APP_VERSION=$argBasedVersion
1818
ENV DOCKER_ENV_PASSWORD="This is it"
1919
ENV AZURE_KEY_VAULT_ENABLED=false
2020
ENV CHALLENGE59_SLACK_WEBHOOK_URL=$challenge59_webhook_url
21+
ENV WRONGSECRETS_MCP_SECRET=MCPStolenSecret42!
2122
ENV SPRINGDOC_UI=false
2223
ENV SPRINGDOC_DOC=false
2324
ENV BASTIONHOSTPATH="/home/wrongsecrets/.ssh"
@@ -70,4 +71,5 @@ RUN rm -rf /var/run/secrets/kubernetes.io
7071
RUN adduser -u 2000 -D wrongsecrets
7172
USER wrongsecrets
7273

73-
CMD java --add-modules=jdk.unsupported -jar -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=$(echo ${SPRING_PROFILES_ACTIVE}) -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} -D application.jar
74+
CMD java -Xms128m -Xmx128m -Xss512k -jar -Dserver.port=$PORT -XX:MaxRAMPercentage=75 -XX:MinRAMPercentage=25 -Dspring.profiles.active=without-vault -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} application.jar
75+
# CMD java -jar -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=$(echo ${SPRING_PROFILES_ACTIVE}) -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} -D application.jar

Dockerfile.web

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM jeroenwillemsen/wrongsecrets:1.12.11-no-vault
2-
ARG argBasedVersion="1.12.11-no-vault"
1+
FROM jeroenwillemsen/wrongsecrets:1.13.1-alpha5-no-vault
2+
ARG argBasedVersion="1.13.1-alpha5"
33
ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
44
ARG CTF_ENABLED=false
55
ARG HINTS_ENABLED=true
@@ -40,4 +40,4 @@ COPY .github/scripts/ /var/helpers
4040
COPY src/test/resources/alibabacreds.kdbx /var/helpers
4141
COPY src/test/resources/RSAprivatekey.pem /var/helpers
4242
COPY .ssh/ /home/wrongsecrets/.ssh/
43-
CMD java -Xms128m -Xmx128m -Xss512k -jar -Dserver.port=$PORT -XX:MaxRAMPercentage=75 -XX:MinRAMPercentage=25 -Dspring.profiles.active=without-vault -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} application.jar
43+
CMD java -jar -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=$(echo ${SPRING_PROFILES_ACTIVE}) -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} -D application.jar

0 commit comments

Comments
 (0)