Skip to content

Commit d5cd483

Browse files
committed
Fix for vuln with shown key
1 parent 557865c commit d5cd483

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge35.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
package org.owasp.wrongsecrets.challenges.docker;
22

3+
import java.nio.charset.StandardCharsets;
4+
import java.security.InvalidAlgorithmParameterException;
5+
import java.security.InvalidKeyException;
6+
import java.security.NoSuchAlgorithmException;
37
import java.util.List;
8+
import javax.crypto.BadPaddingException;
9+
import javax.crypto.Cipher;
10+
import javax.crypto.IllegalBlockSizeException;
11+
import javax.crypto.NoSuchPaddingException;
12+
import javax.crypto.spec.IvParameterSpec;
13+
import javax.crypto.spec.SecretKeySpec;
414
import lombok.extern.slf4j.Slf4j;
15+
import org.apache.commons.codec.binary.Base64;
516
import org.owasp.wrongsecrets.RuntimeEnvironment;
617
import org.owasp.wrongsecrets.ScoreCard;
718
import org.owasp.wrongsecrets.challenges.Challenge;
@@ -59,7 +70,29 @@ public List<RuntimeEnvironment.Environment> supportedRuntimeEnvironments() {
5970
}
6071

6172
private String getKey() {
62-
// google api key
63-
return "AIzaSyBSpHvt8l1f9qlppJqQW280vGacXgwNnrk";
73+
String ciphertext = "zRR77ETjg5GsXv3az1TZU73xiFWYHbVceJBvBbjChxLyMjHkF6kFdwIXIduVBHAT";
74+
try {
75+
return decrypt(ciphertext);
76+
} catch (Exception e) {
77+
log.warn("there was an exception with decrypting content in challenge35", e);
78+
return "error_decryption";
79+
}
80+
}
81+
82+
private String decrypt(String ciphertext)
83+
throws InvalidAlgorithmParameterException,
84+
InvalidKeyException,
85+
NoSuchPaddingException,
86+
NoSuchAlgorithmException,
87+
IllegalBlockSizeException,
88+
BadPaddingException {
89+
IvParameterSpec iv = new IvParameterSpec("1234567890123456".getBytes(StandardCharsets.UTF_8));
90+
SecretKeySpec skeySpec =
91+
new SecretKeySpec(
92+
"12345678901234561234567890123456".getBytes(StandardCharsets.UTF_8), "AES");
93+
94+
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
95+
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
96+
return new String(cipher.doFinal(Base64.decodeBase64(ciphertext)));
6497
}
6598
}

0 commit comments

Comments
 (0)