#!/bin/sh # Copyright 2026 Tailwind Resource Group # SPDX-License-Identifier: Apache-2.0 # Provided as is, with no warranty. License: https://everythingsfine.io/license/ # # n2s_check_node.sh # # Report each Node.js binary on this host and whether its version has the # fix for CVE-2026-111497 ("Node2Shell"). The script only reads versions. # It does not send network traffic and does not change the system. # # Usage: sh n2s_check_node.sh [/path/to/node ...] # With no arguments, it checks "node" on PATH and the binaries of # running node processes (Linux /proc only). # # Fixed releases: 22.23.4, 24.22.1, 26.12.1. Other release lines are # end-of-life and get no fix. status=0 check_one() { bin=$1 [ -x "$bin" ] || return 0 info=$("$bin" -e 'var v=process.versions,c=(process.config&&process.config.variables)||{};console.log(v.node+" "+(v.brotli||"unknown")+" "+(c.node_shared_brotli===true||c.node_shared_brotli==="true"?"system":"bundled"))' 2>/dev/null) || { echo "UNKNOWN $bin: cannot run it" status=1 return 0 } ver=${info%% *} rest=${info#* } brotli=${rest%% *} source=${rest#* } major=${ver%%.*} minor=${ver#*.}; minor=${minor%%.*} patch=${ver##*.} case $major in 22) fix_minor=23; fix_patch=4 ;; 24) fix_minor=22; fix_patch=1 ;; 26) fix_minor=12; fix_patch=1 ;; *) if [ "$major" -gt 26 ] 2>/dev/null; then echo "CHECK $bin: node $ver is newer than this script knows; confirm with the Node.js advisory" else echo "EOL $bin: node $ver has no fix; move to a supported release line" status=1 fi return 0 ;; esac if [ "$minor" -gt "$fix_minor" ] || { [ "$minor" -eq "$fix_minor" ] && [ "$patch" -ge "$fix_patch" ]; }; then verdict="FIXED" else verdict="AFFECTED" status=1 fi printf "%-9s %s\n" "$verdict" "$bin: node $ver, brotli $brotli ($source)" if [ "$source" = "system" ]; then echo " $bin uses the system Brotli library: also update the OS brotli package" fi } if [ $# -gt 0 ]; then for b in "$@"; do check_one "$b"; done else seen="" p=$(command -v node 2>/dev/null) && { check_one "$p"; seen="$p"; } if [ -d /proc ]; then for exe in /proc/[0-9]*/exe; do t=$(readlink "$exe" 2>/dev/null) || continue case $t in */node|*/nodejs) ;; *) continue ;; esac case " $seen " in *" $t "*) continue ;; esac seen="$seen $t" check_one "$t" done fi [ -n "$seen" ] || echo "No node binary found on PATH or in running processes." fi exit $status