Skip to content

Commit d5b53c2

Browse files
authored
Merge branch 'master' into issue-2357-upgrade-k8s-1.35
2 parents 3cb98df + 7e6ff7f commit d5b53c2

23 files changed

+411
-26
lines changed

.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="mVskm4vj9tBf4BqqQEyPaFtTAFJ+K9csVbQkwF3Kj04="
350+
export tempPassword="8S2PzZ7da3Jx9geda6JOqqfYlSDYzM7QbpUGyxM9umw="
351351
mvn run tempPassword
352352
k6
353353
npx k6

.github/scripts/docker-create.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ Heroku_publish_demo() {
6464
heroku container:login
6565
echo "heroku deployment to demo"
6666
cd ../..
67-
heroku container:push web --arg argBasedVersion=${tag} --app arcane-scrubland-42646
68-
heroku container:release web --app arcane-scrubland-42646
67+
git add Dockerfile.web
68+
git commit --no-verify -m "Fix Heroku deploy"
69+
git push heroku HEAD:master
70+
# heroku container:push web --arg argBasedVersion=${tag} --app arcane-scrubland-42646
71+
# heroku container:release web --app arcane-scrubland-42646
6972
# heroku container:push --recursive --arg argBasedVersion=${tag}heroku,CTF_ENABLED=true,HINTS_ENABLED=false --app wrongsecrets-ctf
7073
# heroku container:release web --app wrongsecrets-ctf
7174
echo "wait for contianer to come up"

Dockerfile

Lines changed: 1 addition & 1 deletion
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.13.1-alpha6"
4+
ARG argBasedVersion="1.13.1-alpha11"
55

66
COPY --chown=wrongsecrets target/wrongsecrets-${argBasedVersion}-SNAPSHOT.jar application.jar
77
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted

Dockerfile.web

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM jeroenwillemsen/wrongsecrets:1.13.1-alpha6-no-vault
2-
ARG argBasedVersion="1.13.1-alpha6-no-vault"
1+
FROM jeroenwillemsen/wrongsecrets:1.13.1-alpha11-no-vault
2+
ARG argBasedVersion="1.13.1-alpha11-no-vault"
3+
ARG spring_profile="without-vault"
34
ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
45
ARG CTF_ENABLED=false
56
ARG HINTS_ENABLED=true
@@ -21,7 +22,7 @@ ENV K8S_ENV=Heroku(Docker)
2122
ENV canarytokenURLs=$CANARY_URLS
2223
ENV ctf_enabled=$CTF_ENABLED
2324
ENV ctf_key=$CTF_KEY
24-
ENV SPRING_PROFILES_ACTIVE=without-vault
25+
ENV SPRING_PROFILES_ACTIVE=$spring_profile
2526
ENV hints_enabled=$HINTS_ENABLED
2627
ENV challengedockermtpath="/var/helpers"
2728
ENV keepasspath="/var/helpers/alibabacreds.kdbx"
@@ -38,8 +39,12 @@ ENV default_aws_value_challenge_11=$CHALLENGE_11_VALUE
3839
ENV BASTIONHOSTPATH="/home/wrongsecrets/.ssh"
3940
ENV PROJECTSPECPATH="/var/helpers/project-specification.mdc"
4041
ENV funnybunny="This is a funny bunny"
42+
# Keep memory usage within Heroku dyno limits (512MB dyno).
43+
# Hard cap heap to 250M, metaspace to 60M, disable expensive GC, exit on OOM immediately.
44+
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"
45+
# Deploy WrongSecrets to Heroku
4146
COPY .github/scripts/ /var/helpers
4247
COPY src/test/resources/alibabacreds.kdbx /var/helpers
4348
COPY src/test/resources/RSAprivatekey.pem /var/helpers
4449
COPY .ssh/ /home/wrongsecrets/.ssh/
45-
CMD java -jar -XX:SharedArchiveFile=application.jsa -Dspring.profiles.active=without-vault -Dserver.port=${PORT} -Dspringdoc.swagger-ui.enabled=${SPRINGDOC_UI} -Dspringdoc.api-docs.enabled=${SPRINGDOC_DOC} application.jar
50+
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"]

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ spec:
5858
volumeAttributes:
5959
secretProviderClass: "wrongsecrets-aws-secretsmanager"
6060
containers:
61-
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
61+
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
6262
imagePullPolicy: IfNotPresent
6363
name: secret-challenge
6464
command: ["/bin/sh"]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
volumeAttributes:
6262
secretProviderClass: "azure-wrongsecrets-vault"
6363
containers:
64-
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha6-k8s-vault
64+
- image: jeroenwillemsen/wrongsecrets:1.13.1-alpha11-k8s-vault
6565
imagePullPolicy: IfNotPresent
6666
name: secret-challenge
6767
command: ["/bin/sh"]
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Challenge61 Multi-Instance Setup Guide
2+
3+
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.
4+
5+
## Overview
6+
7+
This challenge supports running on multiple app instances (e.g., Arcane and WrongSecrets Heroku apps) using either polling (getUpdates) or webhooks.
8+
9+
## Option 1: Polling with getUpdates (Default - Works Out of Box)
10+
11+
The code uses update offsets to minimize conflicts between multiple app instances:
12+
- No configuration needed
13+
- Uses update offsets to minimize conflicts between instances
14+
- Multiple instances can run simultaneously
15+
- Less efficient but simpler setup
16+
- `timeout=0` - No long polling, quick responses
17+
- `limit=1` - Process one update at a time
18+
- Offset acknowledgment - Marks updates as processed
19+
20+
**Status**: ✅ Code updated and tested
21+
22+
## Option 2: Webhook Solution (Recommended for Production)
23+
24+
### Step 1: Configure Each Heroku App
25+
26+
For **WrongSecrets Heroku app**:
27+
```bash
28+
heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a wrongsecrets-app
29+
heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a wrongsecrets-app
30+
```
31+
32+
For **Arcane Heroku app**:
33+
```bash
34+
heroku config:set CHALLENGE61_WEBHOOK_ENABLED=true -a arcane-app
35+
heroku config:set CHALLENGE61_WEBHOOK_TOKEN=$(openssl rand -hex 32) -a arcane-app
36+
```
37+
38+
### Step 2: Choose ONE App for the Webhook
39+
40+
You can only set ONE webhook URL per bot. Choose either WrongSecrets or Arcane:
41+
42+
**Option A: Use WrongSecrets app**
43+
```bash
44+
# Get your webhook token
45+
WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a wrongsecrets-app)
46+
47+
# Set the webhook
48+
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"
49+
```
50+
51+
**Option B: Use Arcane app**
52+
```bash
53+
# Get your webhook token
54+
WEBHOOK_TOKEN=$(heroku config:get CHALLENGE61_WEBHOOK_TOKEN -a arcane-app)
55+
56+
# Set the webhook
57+
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"
58+
```
59+
60+
### Step 3: Verify Webhook
61+
62+
```bash
63+
curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo"
64+
```
65+
66+
### Step 4: Test
67+
68+
1. Open @WrongsecretsBot in Telegram
69+
2. Send `/start`
70+
3. Bot should respond: "Welcome! Your secret is: telegram_secret_found_in_channel"
71+
72+
## Alternative: Use Both Apps with getUpdates (Current Setup)
73+
74+
If you want both apps to be able to respond (not recommended but possible):
75+
76+
1. **Keep webhook disabled** (default)
77+
2. **Accept that responses may be inconsistent** - whichever app polls first will respond
78+
3. **The improved getUpdates code** minimizes conflicts with offset handling
79+
80+
## Troubleshooting
81+
82+
### Check if webhook is active
83+
```bash
84+
curl "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/getWebhookInfo"
85+
```
86+
87+
### Remove webhook (to go back to getUpdates)
88+
```bash
89+
curl -X POST "https://api.telegram.org/bot8132866643:AAHJmvZqvvM9dI2rtBOu--WMZyMFTfHNo9I/deleteWebhook"
90+
```
91+
92+
### View Heroku logs
93+
```bash
94+
heroku logs --tail -a wrongsecrets-app | grep Challenge61
95+
heroku logs --tail -a arcane-app | grep Challenge61
96+
```
97+
98+
## Recommendation
99+
100+
For **production with multiple apps**: Use webhook on ONE primary app (WrongSecrets).
101+
102+
For **development/testing**: The current getUpdates approach with offsets works fine.
103+
104+
## BotFather Configuration (Optional but Recommended)
105+
106+
### 1. Configure Commands
107+
108+
- Send `/setcommands` to @BotFather
109+
- Select your bot
110+
- Add: `start - Get the secret message`
111+
112+
### 2. Set Description
113+
114+
- Send `/setdescription` to @BotFather
115+
- Select your bot
116+
- Add: "OWASP WrongSecrets Challenge 61 - Demonstrates hardcoded bot credentials. Send /start to receive the secret!"
117+
118+
### 3. Set About Text
119+
120+
- Send `/setabouttext` to @BotFather
121+
- Add: "Educational security challenge from OWASP WrongSecrets project"
122+
123+
## Testing the Bot
124+
125+
1. Find the bot: Search for @WrongsecretsBot in Telegram (or your bot username)
126+
2. Send: `/start`
127+
3. Receive: "Welcome! Your secret is: telegram_secret_found_in_channel"
128+
129+
## Creating a New Bot
130+
131+
If you need to create your own bot for testing:
132+
133+
1. Message @BotFather in Telegram
134+
2. Send `/newbot`
135+
3. Follow prompts to choose name and username
136+
4. BotFather will provide a token like: `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`
137+
5. Double-encode the token for use in this challenge:
138+
```bash
139+
echo -n "YOUR_TOKEN" | base64 | base64
140+
```
141+
6. Replace the `encodedToken` value in the `getBotToken()` method in Challenge61.java

docs/VERSION_MANAGEMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ The project maintains version consistency between:
1212
## Version Schema
1313

1414
```
15-
pom.xml version: 1.13.1-alpha6-SNAPSHOT
16-
Dockerfile version: 1.13.1-alpha6
17-
Dockerfile.web version: 1.13.1-alpha6-no-vault
15+
pom.xml version: 1.13.1-alpha11-SNAPSHOT
16+
Dockerfile version: 1.13.1-alpha11
17+
Dockerfile.web version: 1.13.1-alpha11-no-vault
1818
```
1919

2020
## Automated Solutions

fly.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ app = "wrongsecrets"
88
primary_region = "ams"
99

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

1313
[env]
1414
K8S_ENV = "Fly(Docker)"

0 commit comments

Comments
 (0)