Skip to content

Commit 79ba736

Browse files
Prevent writing plaintext admin key and password to stdout (#290)
* Prevent writing plaintext admin key and password to stdout
1 parent 34ec19f commit 79ba736

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

core/files/configure_misp.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ init_user() {
350350
fi
351351

352352
if [ -n "$ADMIN_KEY" ]; then
353-
echo "... setting admin key to '${ADMIN_KEY}'"
353+
if [ "$DISABLE_PRINTING_PLAINTEXT_CREDENTIALS" == "true" ]; then
354+
echo "... setting admin key from environment variable"
355+
else
356+
echo "... setting admin key to '${ADMIN_KEY}'"
357+
fi
354358
CHANGE_CMD=(sudo -u www-data /var/www/MISP/app/Console/cake User change_authkey 1 "${ADMIN_KEY}")
355359
elif [ -z "$ADMIN_KEY" ] && [ "$AUTOGEN_ADMIN_KEY" == "true" ]; then
356360
echo "... regenerating admin key (set \$ADMIN_KEY if you want it to change)"
@@ -361,11 +365,19 @@ init_user() {
361365

362366
if [[ -v CHANGE_CMD[@] ]]; then
363367
ADMIN_KEY=$("${CHANGE_CMD[@]}" | awk 'END {print $NF; exit}')
364-
echo "... admin user key set to '${ADMIN_KEY}'"
368+
if [ "$DISABLE_PRINTING_PLAINTEXT_CREDENTIALS" == "true" ]; then
369+
echo "... admin user key set"
370+
else
371+
echo "... admin user key set to '${ADMIN_KEY}'"
372+
fi
365373
fi
366374

367375
if [ ! -z "$ADMIN_PASSWORD" ]; then
368-
echo "... setting admin password to '${ADMIN_PASSWORD}'"
376+
if [ "$DISABLE_PRINTING_PLAINTEXT_CREDENTIALS" == "true" ]; then
377+
echo "... setting admin password from environment variable"
378+
else
379+
echo "... setting admin password to '${ADMIN_PASSWORD}'"
380+
fi
369381
PASSWORD_POLICY=$(sudo -u www-data /var/www/MISP/app/Console/cake Admin getSetting "Security.password_policy_complexity" | jq ".value" -r)
370382
PASSWORD_LENGTH=$(sudo -u www-data /var/www/MISP/app/Console/cake Admin getSetting "Security.password_policy_length" | jq ".value" -r)
371383
sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Security.password_policy_length" 1

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ services:
112112
- "ENABLE_BACKGROUND_UPDATES=${ENABLE_BACKGROUND_UPDATES}"
113113
- "ENCRYPTION_KEY=${ENCRYPTION_KEY}"
114114
- "DISABLE_CA_REFRESH=${DISABLE_CA_REFRESH}"
115+
- "DISABLE_PRINTING_PLAINTEXT_CREDENTIALS=${DISABLE_PRINTING_PLAINTEXT_CREDENTIALS}"
115116
# standard settings
116117
- "ADMIN_EMAIL=${ADMIN_EMAIL}"
117118
- "ADMIN_PASSWORD=${ADMIN_PASSWORD}"

template.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ ADMIN_ORG_UUID=
4444
ADMIN_KEY=
4545
# defaults to MISP's default (admin)
4646
ADMIN_PASSWORD=
47+
# Prevent MISP Initialization from writing ADMIN_KEY and ADMIN_PASSWORD in plaintext
48+
# Recommend uncommenting / setting to true in production or kubernetes environments where output is logged.
49+
#DISABLE_PRINTING_PLAINTEXT_CREDENTIALS=true
4750
# defaults to 'passphrase'
4851
GPG_PASSPHRASE=
4952
# defaults to 1 (the admin user)

0 commit comments

Comments
 (0)