Skip to content

Commit

Permalink
Fixed livestreaming issue introduced by CVE-2023-46809 in Node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bropat committed Mar 7, 2024
1 parent 8cd48f2 commit c842470
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions eufy-security-ws/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.8.0-1

- Fixed livestreaming issue introduced by CVE-2023-46809 in Node.js ([#310](https://github.com/bropat/eufy-security-ws/issues/310))

## 1.8.0

- Updated eufy-security-ws to version [`1.8.0`](https://github.com/bropat/eufy-security-ws/releases/tag/1.8.0)
Expand Down
30 changes: 29 additions & 1 deletion eufy-security-ws/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,37 @@ JSON_STRING="$( jq -n \
}"
)"

check_version() {
if [ "$1" = "$2" ]; then
return 1 # equal
fi
version=$(printf '%s\n' "$1" "$2" | sort -V | tail -n 1)
if [ "$version" = "$2" ]; then
return 2 # greater
fi
return 0 # lower
}

node_version=$(node -v)
node_result=0
if [ "${node_version:1:2}" = "18" ]; then
check_version "v18.19.1" "$node_version"
node_result=$?
elif [ "${node_version:1:2}" = "20" ]; then
check_version "v20.11.1" "$node_version"
node_result=$?
else
check_version "v21.6.2" "$node_version"
node_result=$?
fi
WORKAROUND_ISSUE_310=""
if [ $node_result -gt 0 ]; then
WORKAROUND_ISSUE_310="--security-revert=CVE-2023-46809"
fi

if bashio::config.has_value 'username' && bashio::config.has_value 'password'; then
echo "$JSON_STRING" > $CONFIG_PATH
exec /usr/bin/node $IPV4_FIRST_NODE_OPTION /usr/src/app/node_modules/eufy-security-ws/dist/bin/server.js --host 0.0.0.0 --config $CONFIG_PATH $DEBUG_OPTION $PORT_OPTION
exec /usr/bin/node $WORKAROUND_ISSUE_310 $IPV4_FIRST_NODE_OPTION /usr/src/app/node_modules/eufy-security-ws/dist/bin/server.js --host 0.0.0.0 --config $CONFIG_PATH $DEBUG_OPTION $PORT_OPTION
else
echo "Required parameters username and/or password not set. Starting aborted!"
fi
Expand Down

0 comments on commit c842470

Please sign in to comment.