Exploit database

GH-b9a479c206260172efdfb154b1237e66

umairahmadh/react-vuln-scanner

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-55182

257 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files5
umairahmadh/react-vuln-scannerRevision ef93a6ed3be7

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

scan-react-vuln.sh

Shell · 8,886 bytes
#!/bin/bash

# ============================================================================
# React CVE-2025-55182 Vulnerability Scanner
# Scans for vulnerable React Server Components packages across all users
# Run with: sudo ./scan-react-vuln.sh
# ============================================================================

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
BOLD='\033[1m'

# Vulnerable packages and their fixed versions
declare -A VULNERABLE_PACKAGES=(
    ["react-server-dom-webpack"]="19.0.1 19.1.2 19.2.1"
    ["react-server-dom-parcel"]="19.0.1 19.1.2 19.2.1"
    ["react-server-dom-turbopack"]="19.0.1 19.1.2 19.2.1"
)

# Vulnerable base versions
VULNERABLE_VERSIONS=("19.0.0" "19.1.0" "19.1.1" "19.2.0")

# React core packages to check
REACT_PACKAGES=("react" "react-dom" "react-is")

# Counter for vulnerabilities found
VULN_COUNT=0
APPS_SCANNED=0

# Arrays to store results
declare -a VULNERABLE_APPS=()
declare -a SAFE_APPS=()

echo -e "${BOLD}${BLUE}============================================================${NC}"
echo -e "${BOLD}${BLUE}  React CVE-2025-55182 Vulnerability Scanner${NC}"
echo -e "${BOLD}${BLUE}  Critical: Remote Code Execution (CVSS 10.0)${NC}"
echo -e "${BOLD}${BLUE}============================================================${NC}"
echo ""

# Check if running as root
if [[ $EUID -ne 0 ]]; then
    echo -e "${YELLOW}Warning: Not running as root. Some directories may be inaccessible.${NC}"
    echo -e "${YELLOW}Run with 'sudo' for a complete scan.${NC}"
    echo ""
fi

# Function to compare versions
version_lte() {
    [ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}

version_lt() {
    [ "$1" = "$2" ] && return 1 || version_lte "$1" "$2"
}

# Function to check if version is vulnerable
is_vulnerable_version() {
    local version="$1"
    local package="$2"
    
    # Strip any leading 'v' or '^' or '~'
    version=$(echo "$version" | sed 's/^[v^~]//')
    
    # Exact vulnerable versions for RSC packages
    local vuln_list="19.0.0 19.1.0 19.1.1 19.2.0"
    
    # Check react-server-dom-* packages (exact match only)
    if [[ "$package" == react-server-dom-* ]]; then
        for vuln_ver in $vuln_list; do
            if [[ "$version" == "$vuln_ver" ]]; then
                return 0  # Vulnerable
            fi
        done
    fi
    
    # Check react core packages - only flag exact vulnerable versions
    if [[ "$package" == "react" || "$package" == "react-dom" || "$package" == "react-is" ]]; then
        for vuln_ver in $vuln_list; do
            if [[ "$version" == "$vuln_ver" ]]; then
                return 0  # Potentially vulnerable if using RSC
            fi
        done
    fi
    
    return 1  # Not vulnerable
}

# Function to extract version from package.json
get_package_version() {
    local package_json="$1"
    local package_name="$2"
    
    if command -v jq &> /dev/null; then
        version=$(jq -r ".dependencies[\"$package_name\"] // .devDependencies[\"$package_name\"] // empty" "$package_json" 2>/dev/null)
    else
        version=$(grep -o "\"$package_name\"[[:space:]]*:[[:space:]]*\"[^\"]*\"" "$package_json" 2>/dev/null | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
    fi
    
    echo "$version"
}

# Function to check node_modules for installed version
get_installed_version() {
    local node_modules="$1"
    local package_name="$2"
    
    local pkg_json="$node_modules/$package_name/package.json"
    if [[ -f "$pkg_json" ]]; then
        if command -v jq &> /dev/null; then
            jq -r '.version // empty' "$pkg_json" 2>/dev/null
        else
            grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$pkg_json" 2>/dev/null | head -1 | sed 's/.*"\([^"]*\)"$/\1/'
        fi
    fi
}

# Function to scan a directory for React apps
scan_directory() {
    local dir="$1"
    local owner="$2"
    
    # Look for package.json files (exclude common false positive directories)
    find "$dir" -maxdepth 4 -name "package.json" -type f \
        -not -path "*/node_modules/*" \
        -not -path "*/.cache/*" \
        -not -path "*/.npm/*" \
        -not -path "*/.pnpm/*" \
        -not -path "*/wp-content/*" \
        -not -path "*/wp-includes/*" \
        -not -path "*/plugins/*" \
        -not -path "*/themes/*" \
        2>/dev/null | while read -r package_json; do
        
        local app_dir=$(dirname "$package_json")
        local app_name=$(basename "$app_dir")
        local is_vulnerable=false
        local vuln_details=""
        
        # Check for React packages
        local has_react=false
        for pkg in "${REACT_PACKAGES[@]}"; do
            local version=$(get_package_version "$package_json" "$pkg")
            if [[ -n "$version" ]]; then
                has_react=true
                break
            fi
        done
        
        if [[ "$has_react" == false ]]; then
            continue
        fi
        
        ((APPS_SCANNED++)) || true
        
        # Check for vulnerable RSC packages
        for pkg in "${!VULNERABLE_PACKAGES[@]}"; do
            local version=$(get_package_version "$package_json" "$pkg")
            if [[ -n "$version" ]]; then
                # Check node_modules for actual installed version
                local node_modules="$app_dir/node_modules"
                local installed_version=$(get_installed_version "$node_modules" "$pkg")
                
                if [[ -n "$installed_version" ]]; then
                    if is_vulnerable_version "$installed_version" "$pkg"; then
                        is_vulnerable=true
                        vuln_details+="\n    - $pkg@$installed_version (VULNERABLE)"
                        ((VULN_COUNT++)) || true
                    else
                        vuln_details+="\n    - $pkg@$installed_version (OK)"
                    fi
                else
                    vuln_details+="\n    - $pkg@$version (declared, not installed)"
                fi
            fi
        done
        
        # Check react version
        local react_version=$(get_package_version "$package_json" "react")
        if [[ -n "$react_version" ]]; then
            local node_modules="$app_dir/node_modules"
            local installed_react=$(get_installed_version "$node_modules" "react")
            
            if [[ -n "$installed_react" ]]; then
                if is_vulnerable_version "$installed_react" "react"; then
                    vuln_details+="\n    - react@$installed_react (UPDATE RECOMMENDED)"
                else
                    vuln_details+="\n    - react@$installed_react"
                fi
            fi
        fi
        
        # Print results immediately
        if [[ "$is_vulnerable" == true ]]; then
            echo -e "${RED}[VULNERABLE]${NC} ${BOLD}$app_name${NC}"
            echo -e "  Path: $app_dir"
            echo -e "  Owner: $owner"
            echo -e "$vuln_details"
            echo ""
        elif [[ -n "$vuln_details" ]]; then
            echo -e "${GREEN}[SAFE]${NC} ${BOLD}$app_name${NC}"
            echo -e "  Path: $app_dir"
            echo -e "  Owner: $owner"
            echo -e "$vuln_details"
            echo ""
        fi
        
    done
}

echo -e "${CYAN}Scanning for React applications...${NC}"
echo ""

# Track scanned directories to avoid duplicates
declare -A SCANNED_DIRS=()

# Function to scan if not already scanned
scan_if_new() {
    local dir="$1"
    local owner="$2"
    local real_dir=$(readlink -f "$dir" 2>/dev/null || echo "$dir")
    
    if [[ -z "${SCANNED_DIRS[$real_dir]}" ]]; then
        SCANNED_DIRS["$real_dir"]=1
        echo -e "${BLUE}Scanning: ${BOLD}$dir${NC} (owner: $owner)"
        scan_directory "$dir" "$owner"
    fi
}

# Scan root's home directory if it exists and is accessible
if [[ -d "/root" && -r "/root" ]]; then
    scan_if_new "/root" "root"
fi

# Scan each user's home directory
if [[ -d "/home" ]]; then
    for home_dir in /home/*; do
        if [[ -d "$home_dir" ]]; then
            owner=$(basename "$home_dir")
            scan_if_new "$home_dir" "$owner"
        fi
    done
fi

# Scan system locations (skip if already scanned via symlinks)
for loc in /var/www /srv /opt; do
    if [[ -d "$loc" ]]; then
        scan_if_new "$loc" "system"
    fi
done

# Print summary
echo ""
echo -e "${BOLD}${BLUE}============================================================${NC}"
echo -e "${BOLD}${BLUE}  SCAN COMPLETE${NC}"
echo -e "${BOLD}${BLUE}============================================================${NC}"
echo ""
echo -e "${YELLOW}If vulnerabilities were found, update immediately:${NC}"
echo ""
echo "  npm install react@latest react-dom@latest"
echo "  npm install react-server-dom-webpack@latest"
echo ""
echo -e "Reference: ${CYAN}https://react.dev/blog/2025/12/03/react-rsc-security-vulnerability${NC}"
echo ""