Skip to content

Usage of non-local environment variables #309

@xathon

Description

@xathon

Currently, the command-handling logic is not placed inside a function, making the usage of local environment variables impossible. This can cause previously set environment variables to get overwritten.

To mitigate the above issue, environmental variables get cleared before usage or directly overwritten. However, in some cases environment variables get appended, but not checked if they are empty before. This can cause external code to change the environmental variable at a specific time, causing injection of unwanted codes into the options of mscs/msctl. This can have multiple effects ranging from a confusing and bloated output of status to a spam of created folders when using start; however, as far as I have seen, there are no security implications, since variables are always enclosed in double quotes and thus not interpreted.

An example of the above:

mscs/msctl

Lines 3053 to 3058 in 8118d10

status | show | status-json | show-json)
# Figure out which worlds to show the status for.
if [ "$#" -ge 1 ]; then
for arg in "$@"; do
if isWorldAvailable "$arg"; then
WORLDS="$WORLDS $arg"

An example where it's done correctly (note L2668):

mscs/msctl

Lines 2667 to 2676 in 8118d10

elif [ "$#" -ge 1 ]; then
WORLDS=''
for arg in "$@"; do
if isWorldEnabled "$arg"; then
if serverRunning "$arg"; then
printf "Unable to start the requested worlds: world '$arg' already running.\n"
exit 1
else
WORLDS="$WORLDS $arg"
fi

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions