Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/.bash_history
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ rm -rf jdk-18_linux-x64_bin.deb
git rebase -i main
git rebase -i master
git stash
export tempPassword="mVskm4vj9tBf4BqqQEyPaFtTAFJ+K9csVbQkwF3Kj04="
export tempPassword="8S2PzZ7da3Jx9geda6JOqqfYlSDYzM7QbpUGyxM9umw="
mvn run tempPassword
k6
npx k6
Expand Down
7 changes: 5 additions & 2 deletions .github/scripts/docker-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ Heroku_publish_demo() {
heroku container:login
echo "heroku deployment to demo"
cd ../..
heroku container:push web --arg argBasedVersion=${tag} --app arcane-scrubland-42646
heroku container:release web --app arcane-scrubland-42646
git add Dockerfile.web
git commit --no-verify -m "Fix Heroku deploy"
git push heroku HEAD:master
# heroku container:push web --arg argBasedVersion=${tag} --app arcane-scrubland-42646
# heroku container:release web --app arcane-scrubland-42646
# heroku container:push --recursive --arg argBasedVersion=${tag}heroku,CTF_ENABLED=true,HINTS_ENABLED=false --app wrongsecrets-ctf
# heroku container:release web --app wrongsecrets-ctf
echo "wait for contianer to come up"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM bellsoft/liberica-openjre-debian:25-cds AS builder
WORKDIR /builder

ARG argBasedVersion="1.13.1-alpha6"
ARG argBasedVersion="1.13.1-alpha11"

COPY --chown=wrongsecrets target/wrongsecrets-${argBasedVersion}-SNAPSHOT.jar application.jar
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
Expand All @@ -13,12 +13,12 @@
ARG spring_profile=""
ARG challenge59_webhook_url="YUhSMGNITTZMeTlvYjI5cmN5NXpiR0ZqYXk1amIyMHZjMlZ5ZG1salpYTXZWREEwVkRRd1RraFlMMEl3T1VSQlRrb3lUamRMTDJNeWFqYzFSVEUzVjFrd2NFeE5SRXRvU0RsbGQzZzBhdz09"
ENV SPRING_PROFILES_ACTIVE=$spring_profile
ENV ARG_BASED_PASSWORD=$argBasedPassword

Check warning on line 16 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ARG_BASED_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV APP_VERSION=$argBasedVersion

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$argBasedVersion' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV DOCKER_ENV_PASSWORD="This is it"

Check warning on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "DOCKER_ENV_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV AZURE_KEY_VAULT_ENABLED=false

Check warning on line 19 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "AZURE_KEY_VAULT_ENABLED") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV CHALLENGE59_SLACK_WEBHOOK_URL=$challenge59_webhook_url
ENV WRONGSECRETS_MCP_SECRET=MCPStolenSecret42!

Check warning on line 21 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "WRONGSECRETS_MCP_SECRET") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV SPRINGDOC_UI=false
ENV SPRINGDOC_DOC=false
ENV BASTIONHOSTPATH="/home/wrongsecrets/.ssh"
Expand Down Expand Up @@ -71,4 +71,4 @@
RUN adduser -u 2000 -D wrongsecrets
USER wrongsecrets

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

Check warning on line 74 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-preview

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
9 changes: 6 additions & 3 deletions Dockerfile.web
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault
ARG argBasedVersion="1.13.1-alpha6-no-vault"
FROM jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault
ARG argBasedVersion="1.13.1-alpha11-no-vault"
ARG spring_profile="without-vault"
ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
ARG CTF_ENABLED=false
Expand Down Expand Up @@ -39,9 +39,12 @@ ENV default_aws_value_challenge_11=$CHALLENGE_11_VALUE
ENV BASTIONHOSTPATH="/home/wrongsecrets/.ssh"
ENV PROJECTSPECPATH="/var/helpers/project-specification.mdc"
ENV funnybunny="This is a funny bunny"
# Keep memory usage within Heroku dyno limits (512MB dyno).
# Hard cap heap to 250M, metaspace to 60M, disable expensive GC, exit on OOM immediately.
ENV JAVA_TOOL_OPTIONS="-Xmx250M -Xms128M -XX:MetaspaceSize=40M -XX:MaxMetaspaceSize=60M -XX:CompressedClassSpaceSize=32M -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump.hprof"
# Deploy WrongSecrets to Heroku
COPY .github/scripts/ /var/helpers
COPY src/test/resources/alibabacreds.kdbx /var/helpers
COPY src/test/resources/RSAprivatekey.pem /var/helpers
COPY .ssh/ /home/wrongsecrets/.ssh/
CMD ["/bin/sh", "-c", "java -jar -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -Dserver.port=${PORT} -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} application.jar"]
CMD ["/bin/sh", "-c", "java ${JAVA_TOOL_OPTIONS} -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -Dserver.port=${PORT} -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} -jar application.jar"]
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java -Xmx200M -Xms100M -XX:MetaspaceSize=30M -XX:MaxMetaspaceSize=50M -XX:CompressedClassSpaceSize=24M -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+ExitOnOutOfMemoryError -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -Dserver.port=${PORT} -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} -jar target/application.jar
2 changes: 1 addition & 1 deletion aws/k8s/secret-challenge-vault-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spec:
volumeAttributes:
secretProviderClass: "wrongsecrets-aws-secretsmanager"
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
imagePullPolicy: IfNotPresent
name: secret-challenge
command: ["/bin/sh"]
Expand Down
2 changes: 1 addition & 1 deletion azure/k8s/secret-challenge-vault-deployment.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
volumeAttributes:
secretProviderClass: "azure-wrongsecrets-vault"
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
imagePullPolicy: IfNotPresent
name: secret-challenge
command: ["/bin/sh"]
Expand Down
141 changes: 141 additions & 0 deletions docs/CHALLENGE61_MULTI_INSTANCE_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Challenge61 Multi-Instance Setup Guide

This guide explains how to configure and run Challenge61, which demonstrates how hardcoded Telegram bot credentials can be discovered and exploited. The bot token is double-encoded in base64 to make it slightly more challenging but still discoverable through code inspection.

## Overview

This challenge supports running on multiple app instances (e.g., Arcane and WrongSecrets Heroku apps) using either polling (getUpdates) or webhooks.

## Option 1: Polling with getUpdates (Default - Works Out of Box)

The code uses update offsets to minimize conflicts between multiple app instances:
- No configuration needed
- Uses update offsets to minimize conflicts between instances
- Multiple instances can run simultaneously
- Less efficient but simpler setup
- `timeout=0` - No long polling, quick responses
- `limit=1` - Process one update at a time
- Offset acknowledgment - Marks updates as processed

**Status**: ✅ Code updated and tested

## Option 2: Webhook Solution (Recommended for Production)

### Step 1: Configure Each Heroku App

For **WrongSecrets Heroku app**:
```bash
heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a wrongsecrets-app
heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a wrongsecrets-app
```

For **Arcane Heroku app**:
```bash
heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a arcane-app
heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a arcane-app
```

### Step 2: Choose ONE App for the Webhook

You can only set ONE webhook URL per bot. Choose either WrongSecrets or Arcane:

**Option A: Use WrongSecrets app**
```bash
# Get your webhook token
WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a wrongsecrets-app)

# Set the webhook
curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/setWebhook?url=https://your-wrongsecrets-app.herokuapp.com/telegram/webhook/challenge61&secret_token=$WEBHOOK_TOKEN"
```

**Option B: Use Arcane app**
```bash
# Get your webhook token
WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a arcane-app)

# Set the webhook
curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/setWebhook?url=https://your-arcane-app.herokuapp.com/telegram/webhook/challenge61&secret_token=$WEBHOOK_TOKEN"
```

### Step 3: Verify Webhook

```bash
curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo"
```

### Step 4: Test

1. Open @WrongsecretsBot in Telegram
2. Send `/start`
3. Bot should respond: "Welcome! Your secret is: telegram_secret_found_in_channel"

## Alternative: Use Both Apps with getUpdates (Current Setup)

If you want both apps to be able to respond (not recommended but possible):

1. **Keep webhook disabled** (default)
2. **Accept that responses may be inconsistent** - whichever app polls first will respond
3. **The improved getUpdates code** minimizes conflicts with offset handling

## Troubleshooting

### Check if webhook is active
```bash
curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo"
```

### Remove webhook (to go back to getUpdates)
```bash
curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/deleteWebhook"
```

### View Heroku logs
```bash
heroku logs --tail -a wrongsecrets-app | grep Challenge61
heroku logs --tail -a arcane-app | grep Challenge61
```

## Recommendation

For **production with multiple apps**: Use webhook on ONE primary app (WrongSecrets).

For **development/testing**: The current getUpdates approach with offsets works fine.

## BotFather Configuration (Optional but Recommended)

### 1. Configure Commands

- Send `/setcommands` to @BotFather
- Select your bot
- Add: `start - Get the secret message`

### 2. Set Description

- Send `/setdescription` to @BotFather
- Select your bot
- Add: "OWASP WrongSecrets Challenge 61 - Demonstrates hardcoded bot credentials. Send /start to receive the secret!"

### 3. Set About Text

- Send `/setabouttext` to @BotFather
- Add: "Educational security challenge from OWASP WrongSecrets project"

## Testing the Bot

1. Find the bot: Search for @WrongsecretsBot in Telegram (or your bot username)
2. Send: `/start`
3. Receive: "Welcome! Your secret is: telegram_secret_found_in_channel"

## Creating a New Bot

If you need to create your own bot for testing:

1. Message @BotFather in Telegram
2. Send `/newbot`
3. Follow prompts to choose name and username
4. BotFather will provide a token like: `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`
5. Double-encode the token for use in this challenge:
```bash
echo -n "YOUR_TOKEN" | base64 | base64
```
6. Replace the `encodedToken` value in the `getBotToken()` method in Challenge61.java
6 changes: 3 additions & 3 deletions docs/VERSION_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The project maintains version consistency between:
## Version Schema

```
pom.xml version: 1.13.1-alpha6-SNAPSHOT
Dockerfile version: 1.13.1-alpha6
Dockerfile.web version: 1.13.1-alpha6-no-vault
pom.xml version: 1.13.1-alpha11-SNAPSHOT
Dockerfile version: 1.13.1-alpha11
Dockerfile.web version: 1.13.1-alpha11-no-vault
```

## Automated Solutions
Expand Down
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ app = "wrongsecrets"
primary_region = "ams"

[build]
image = "docker.io/jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault"
image = "docker.io/jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault"

[env]
K8S_ENV = "Fly(Docker)"
Expand Down
2 changes: 1 addition & 1 deletion gcp/k8s/secret-challenge-vault-deployment.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spec:
volumeAttributes:
secretProviderClass: "wrongsecrets-gcp-secretsmanager"
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
imagePullPolicy: IfNotPresent
name: secret-challenge
command: ["/bin/sh"]
Expand Down
2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function secret() {
var password = "m2/lkfE=" + 9 + "DsPI" + 6 + "2yc=" + 2 + "BcHo" + 7;
var password = "UIz8ASo=" + 9 + "vCx1" + 6 + "DXw=" + 2 + "XaN4" + 7;
return password;
}
4 changes: 2 additions & 2 deletions k8s/challenge53/secret-challenge53-sidecar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
runAsGroup: 2000
fsGroup: 2000
containers:
- image: jeroenwillemsen/wrongsecrets-challenge53:1.13.1-alpha6
- image: jeroenwillemsen/wrongsecrets-challenge53:1.13.1-alpha11
name: secret-challenge-53
imagePullPolicy: IfNotPresent
resources:
Expand All @@ -45,7 +45,7 @@ spec:
command: ["/bin/sh", "-c"]
args:
- cp /home/wrongsecrets/* /shared-data/ && exec /home/wrongsecrets/start-on-arch.sh
- image: jeroenwillemsen/wrongsecrets-challenge53-debug:1.13.1-alpha6
- image: jeroenwillemsen/wrongsecrets-challenge53-debug:1.13.1-alpha11
name: sidecar
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c", "while true; do ls /shared-data; sleep 10; done"]
Expand Down
2 changes: 1 addition & 1 deletion k8s/challenge53/secret-challenge53.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
runAsGroup: 2000
fsGroup: 2000
containers:
- image: jeroenwillemsen/wrongsecrets-challenge53:1.13.1-alpha6
- image: jeroenwillemsen/wrongsecrets-challenge53:1.13.1-alpha11
name: secret-challenge-53
imagePullPolicy: IfNotPresent
resources:
Expand Down
2 changes: 1 addition & 1 deletion k8s/secret-challenge-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
runAsGroup: 2000
fsGroup: 2000
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault
imagePullPolicy: IfNotPresent
name: secret-challenge
ports:
Expand Down
2 changes: 1 addition & 1 deletion k8s/secret-challenge-vault-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
type: RuntimeDefault
serviceAccountName: vault
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
imagePullPolicy: IfNotPresent
name: secret-challenge
command: ["/bin/sh"]
Expand Down
2 changes: 1 addition & 1 deletion okteto/k8s/secret-challenge-ctf-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
runAsGroup: 2000
fsGroup: 2000
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault
name: secret-challenge-ctf
imagePullPolicy: IfNotPresent
securityContext:
Expand Down
2 changes: 1 addition & 1 deletion okteto/k8s/secret-challenge-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
runAsGroup: 2000
fsGroup: 2000
containers:
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault
name: secret-challenge
imagePullPolicy: IfNotPresent
securityContext:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.owasp</groupId>
<artifactId>wrongsecrets</artifactId>
<version>1.13.1-alpha6-SNAPSHOT</version>
<version>1.13.1-alpha11-SNAPSHOT</version>

<name>OWASP WrongSecrets</name>
<description>Examples with how to not use secrets</description>
Expand Down
Loading
Loading