Skip to content

Commit dd0f4dd

Browse files
committed
make hmac key configurable in deployment
1 parent 328a7b3 commit dd0f4dd

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ spec:
6060
value: {{ .Values.wrongsecrets.tag}}
6161
- name: WRONGSECRETS_DESKTOP_TAG
6262
value: 1.5.7RC1
63+
- name: REACT_APP_CREATE_TEAM_HMAC_KEY
64+
value: hardcodedkey
6365
- name: SECRETS_MANAGER_SECRET_ID_1
6466
value: {{ .Values.balancer.env.SECRETS_MANAGER_SECRET_ID_1 }}
6567
- name: SECRETS_MANAGER_SECRET_ID_2

wrongsecrets-balancer/src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ app.get('/balancer/dynamics', (req, res) => {
6666
heroku_wrongsecret_ctf_url: process.env['REACT_APP_HEROKU_WRONGSECRETS_URL'],
6767
ctfd_url: process.env['REACT_APP_CTFD_URL'],
6868
s3_bucket_url: process.env['REACT_APP_S3_BUCKET_URL'],
69+
hmac_key: process.env['REACT_APP_CREATE_TEAM_HMAC_KEY'],
6970
enable_password: usePassword,
7071
});
7172
});

wrongsecrets-balancer/src/teams/teams.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const accessPassword = process.env.REACT_APP_ACCESS_PASSWORD;
1010

1111
const validator = expressJoiValidation.createValidator();
1212
const k8sEnv = process.env.K8S_ENV || 'k8s';
13-
13+
const hmac_key = process.env.REACT_APP_CREATE_TEAM_HMAC_KEY;
1414
const router = express.Router();
1515

1616
const {
@@ -96,7 +96,7 @@ async function validateHMAC(req, res, next) {
9696
const { team } = req.params;
9797
const { hmacvalue } = req.body;
9898
const validationValue = crypto
99-
.createHmac('sha256', 'hardcodedkey')
99+
.createHmac('sha256', hmac_key)
100100
.update(`${team}`, 'utf-8')
101101
.digest('hex');
102102
if (validationValue === hmacvalue) {

wrongsecrets-balancer/ui/src/pages/JoinPage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const JoinPage = injectIntl(({ intl }) => {
5858
}
5959
if (dynamics.enable_password) {
6060
const hmacvalue = cryptoJS
61-
.HmacSHA256(`${teamname}`, 'hardcodedkey')
61+
.HmacSHA256(`${teamname}`, dynamics.hmac_key)
6262
.toString(cryptoJS.enc.Hex);
6363
const { data } = await axios.post(`/balancer/teams/${teamname}/join`, {
6464
passcode,
@@ -68,7 +68,7 @@ export const JoinPage = injectIntl(({ intl }) => {
6868
navigate(`/teams/${teamname}/joined/`, { state: { passcode: data.passcode } });
6969
} else {
7070
const hmacvalue = cryptoJS
71-
.HmacSHA256(`${teamname}`, 'hardcodedkey')
71+
.HmacSHA256(`${teamname}`, dynamics.hmac_key)
7272
.toString(cryptoJS.enc.Hex);
7373
const { data } = await axios.post(`/balancer/teams/${teamname}/join`, {
7474
passcode,
@@ -99,6 +99,7 @@ export const JoinPage = injectIntl(({ intl }) => {
9999
heroku_wrongsecret_ctf_url: process.env['REACT_APP_HEROKU_WRONGSECRETS_URL'],
100100
ctfd_url: process.env['REACT_APP_CTFD_URL'],
101101
s3_bucket_url: process.env['REACT_APP_S3_BUCKET_URL'],
102+
hmac_key: process.env['REACT_APP_CREATE_TEAM_HMAC_KEY'],
102103
enable_password: false,
103104
};
104105

0 commit comments

Comments
 (0)