Skip to content

Commit 802d16b

Browse files
committed
Security Hardening: Keep config files locked down with mode 0o600 when not running in debug mode.
1 parent 8275f83 commit 802d16b

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

bin/container-start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@ PIDFILE=$HOMEDIR/logs/xyops.pid
3030
# delete old pid file
3131
rm -f $PIDFILE
3232

33+
# set perms on config files
34+
[[ -f conf/config.json ]] && chmod 600 conf/config.json
35+
[[ -f conf/overrides.json ]] && chmod 600 conf/overrides.json
36+
3337
# start xyops, replace current process
3438
exec $BINARY

bin/control.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ do
7979
continue
8080
fi
8181
echo "$0 $ARG: Starting up $NAME..."
82+
[[ -f conf/config.json ]] && chmod 600 conf/config.json
83+
[[ -f conf/overrides.json ]] && chmod 600 conf/overrides.json
8284
if $BINARY ; then
8385
echo "$0 $ARG: $NAME started"
8486
else

lib/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ class Util {
163163
} // master
164164

165165
// save file to disk
166-
Tools.writeFileAtomic( co_file, JSON.stringify(this.server.configOverrides, null, "\t") + "\n", callback );
166+
var opts = {};
167+
if (!this.server.debug) opts.mode = 0o600;
168+
Tools.writeFileAtomic( co_file, JSON.stringify(this.server.configOverrides, null, "\t") + "\n", opts, callback );
167169
}
168170

169171
convertCronicleDataFile(opts, callback) {

0 commit comments

Comments
 (0)