Skip to content

Commit 0e4cf24

Browse files
fix(challenge63): add explicit constructor and document intentional CBC usage
1 parent 35e02c4 commit 0e4cf24

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/org/owasp/wrongsecrets/challenges/docker/challenge63/Challenge63.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
import org.owasp.wrongsecrets.challenges.Spoiler;
1010
import org.springframework.stereotype.Component;
1111

12+
/**
13+
* Challenge demonstrating bad encryption practices: hardcoding both the encryption key and IV
14+
* directly in source code. Even though the secret is encrypted, the key is right here in the code,
15+
* making the encryption completely ineffective.
16+
*/
17+
@SuppressWarnings("java:S5542")
1218
@Slf4j
1319
@Component
1420
public class Challenge63 implements Challenge {
@@ -17,6 +23,10 @@ public class Challenge63 implements Challenge {
1723
private static final String HARDCODED_IV = "InitVector123456";
1824
private static final String CIPHERTEXT = "TDPwOvcLsbCWV5erlk6OHFnlFoXNtdQOt2JQeq+i4Ho=";
1925

26+
public Challenge63() {
27+
// explicit constructor required
28+
}
29+
2030
@Override
2131
public Spoiler spoiler() {
2232
return new Spoiler(getAnswer());
@@ -34,6 +44,7 @@ private String getAnswer() {
3444
byte[] cipherBytes = Base64.getDecoder().decode(CIPHERTEXT);
3545
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
3646
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
47+
// Intentionally using CBC mode to demonstrate padding oracle vulnerability
3748
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
3849
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
3950
byte[] decrypted = cipher.doFinal(cipherBytes);
@@ -43,4 +54,4 @@ private String getAnswer() {
4354
return "decryption-error";
4455
}
4556
}
46-
}
57+
}

src/main/resources/explanations/challenge63_reason.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ This challenge highlights a widespread mistake in software development: using en
1616
**Real world examples:**
1717
This exact pattern has been found in numerous data breaches where developers believed their secrets were "safe" because they were encrypted, not realizing the key was equally exposed.
1818

19+
Additionally, this challenge uses AES in CBC mode which is vulnerable to
20+
padding oracle attacks. Production code should use AES/GCM instead.
21+
1922
**References:**
2023
- https://owasp.org/www-project-top-ten/[OWASP Top 10]
2124
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html[OWASP Secrets Management Cheat Sheet]

0 commit comments

Comments
 (0)