Exploit database

GH-f41a0ab13516046a84cec42d32717cfa

sun977/cve-2025-55182

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 files3
sun977/cve-2025-55182Revision 5a0e9d7f2935

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

cve-2025-55182-check.sh

Shell · 18,904 bytes
#!/usr/bin/env bash
# Version: 1.0.0
# Author: Sun977
# Update: 2025-12-07
# Description: 扫描当前目录下所有 node_modules、lock 文件及 package.json,判断是否存在受影响的 Next.js 及连带生态包。
# Usage: CVE-2025-66478-Check.sh [-h] [-f <path>] [-a]

set -euo pipefail

# 帮助信息
usage() {
    echo "Usage: $0 [-h] [-f <path>] [-a]"
    echo "Options:"
    echo "  -h          Show this help message"
    echo "  -f <path>   Scan a specific project directory"
    echo "  -a          Scan the entire disk (default: /)"
    exit 0
}

# 默认参数
SCAN_MODE="project"
TARGET_DIR="."

# 解析参数
while getopts ":hf:a" opt; do
    case $opt in
        h) usage ;;
        f) SCAN_MODE="project"; TARGET_DIR="$OPTARG" ;;
        a) SCAN_MODE="full" ;;
        \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
        :) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;;
    esac
done

# 检查 Node.js 是否安装
if ! command -v node &> /dev/null; then
    echo "Error: Node.js is not installed. Please install Node.js first."
    exit 1
fi

RED='\033[0;31m'; YEL='\033[0;33m'; GRN='\033[0;32m'; NC='\033[0m'
EXIT_CODE=0

# 1) 官方确认受影响的 Next.js 版本正则
VUL_REGEX='^1[45]\.(0\.[0-4]|1\.[0-8]|2\.[0-5]|3\.[0-5]|4\.[0-7]|5\.[0-6])(-canary\.\d+)?$|^16\.0\.[0-6]$|^19\.(0\.[01]|1\.[0-9]|2\.0)$'

# 2) 连带生态包(名称 => 受影响版本规则)
declare -A ECOSYSTEM
ECOSYSTEM["@vitejs/plugin-react-server-components"]="*<=1.0.0-beta.3"
ECOSYSTEM["@parcel/transformer-react-server-components"]="*<=2.13.0"
ECOSYSTEM["react-router-rsc"]="*<=0.8.0"
ECOSYSTEM["waku"]="*<=0.21.0"
ECOSYSTEM["@redwoodjs/web"]="*<=8.3.0"
ECOSYSTEM["react-server"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
# 新增的受影响组件
ECOSYSTEM["@about_/next"]="<=15.999.999"
ECOSYSTEM["@harjaapdhillon/next"]="<=15.4.0-canary.79566"
ECOSYSTEM["@hiogawa/vite-rsc"]="<=0.4.9"
ECOSYSTEM["@kenkaiiii/queen-rag"]="<=1.3.0"
ECOSYSTEM["@yadhukrishnan_jiitak/create-mvp"]="<=1.0.1"
ECOSYSTEM["asuw"]="<=1.0.0"
ECOSYSTEM["bug-finder-nextjs-mcp-server"]="<=1.0.3"
ECOSYSTEM["ccdash"]="<=0.6.9"
ECOSYSTEM["cli_project2"]="<=1.0.0"
ECOSYSTEM["climate-api-platform"]="<=1.0.0"
ECOSYSTEM["create-insomniac-nextjs-app"]="<=1.1.0"
ECOSYSTEM["cra-template-bobonext.js"]="<=0.7.0"
ECOSYSTEM["next-hocb"]="<=1.0.8"
ECOSYSTEM["react-on-rails-rsc"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
ECOSYSTEM["react-server-dom-bun"]="<=0.0.0-experimental-603e6108-20241029"
ECOSYSTEM["rsnext"]="<=15.0.0-canary.82"
ECOSYSTEM["vercel-nextjs"]="<=15.2.3"
ECOSYSTEM["wealthealth"]="<=1.0.0"
ECOSYSTEM["@aslmarcochan/next"]="<=13.5.11-asl.patch.1"
ECOSYSTEM["@fern-api/next"]="<=14.2.9-fork.2"
ECOSYSTEM["@modern-js/utils"]="<=2.68.9"
ECOSYSTEM["@redwoodjs/vite"]="<=9.0.0-canary.99"
ECOSYSTEM["action-next"]="<=14.2.15-3"
ECOSYSTEM["action-nextjs-project"]="<=0.0.0"
ECOSYSTEM["code-health-copilot"]="<=1.0.0"
ECOSYSTEM["testify-newtest"]="<=1.3.0"
ECOSYSTEM["@hikonomi/smk-yo"]="<=1.0.0"
ECOSYSTEM["@jodusnodus/next"]="<=14.2.6"
ECOSYSTEM["@symphonizeltd/next"]="<=15.4.0-canary.42-symphonize.1"
ECOSYSTEM["@vitejs/plugin-rsc"]="<=0.4.32"
ECOSYSTEM["adkui-nextjs"]="<=2.0.0"
ECOSYSTEM["codeapp-server-tool"]="<=1.0.0"
ECOSYSTEM["create-keepkey-app"]="<=0.1.2"
ECOSYSTEM["create-next-flask"]="<=1.0.2"
ECOSYSTEM["mequ-demo-library"]="<=1.0.1"
ECOSYSTEM["next"]="<=15.6.0-canary.9"
ECOSYSTEM["react-server-dom-parcel"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
ECOSYSTEM["react-server-dom-turbopack"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
ECOSYSTEM["react-server-dom-webpack"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
ECOSYSTEM["react-server-dom-vite-alpha"]=">=19.0.0 <=19.0.1 || >=19.1.0 <=19.1.999 || >=19.2.0 <=19.2.0"
ECOSYSTEM["@laborup/redwood"]="<=1.0.0"
ECOSYSTEM["bp-wizard-create-next-js"]="<=1.2.0"
ECOSYSTEM["bp-wizard-create-next-ts"]="<=1.2.0"
ECOSYSTEM["claudeee"]="<=0.4.1"
ECOSYSTEM["create-supawald"]="<=1.0.2"
ECOSYSTEM["hcb-ui-package"]="<=1.0.34"
ECOSYSTEM["html-export-kit"]="<=0.1.0"
ECOSYSTEM["next-hocb-test3"]="<=13.5.6"
ECOSYSTEM["next-hocb-test"]="<=1.0.1"
ECOSYSTEM["nodtearvn"]="<=1.1.4"
# ECOSYSTEM["react-server"]=">=19.0.0 <=19.2.0"  # 简化规则

# 3) 工具函数
semver_in_range() {
    node -e "
        const semver = require('semver');
        const ver = process.argv[1].replace(/^[\^~]/, '');
        const range = process.argv[2];
        console.log(semver.satisfies(ver, range) ? 'OK' : 'FAIL');
    " -- "$@"
}

log() {
    case $1 in
        ERR) echo -e "${RED}[ERR]${NC} $2" ; EXIT_CODE=1 ;;
        WRN) echo -e "${YEL}[WRN]${NC} $2" ;;
        OK ) echo -e "${GRN}[OK] ${NC} $2" ;;
    esac
}

# 4) 扫描 package.json 中的直接依赖
scan_manifest() {
    [ -f package.json ] || return
    log OK "Found package.json"
    local has_vul_pkg=false
    
    # 收集所有需要检查的包(next.js 和生态系统包)
    local all_pkgs=("next")
    for pkg in "${!ECOSYSTEM[@]}"; do
        all_pkgs+=("$pkg")
    done
    
    # 检查每个包是否存在以及是否受影响
    for pkg in "${all_pkgs[@]}"; do
        ver=$(node -pe "
            try {
                const p = require('./package.json');
                (p.dependencies || {})['$pkg'] ||
                (p.devDependencies || {})['$pkg'] ||
                (p.peerDependencies || {})['$pkg'] || 
                'NOT_FOUND'
            } catch {}
        " 2>/dev/null || echo "NOT_FOUND")

        if [ "$ver" = "NOT_FOUND" ]; then
            continue
        fi
        
        # 如果是第一个找到的包,打印表头
        if [ "$has_vul_pkg" = false ]; then
            echo "----------------------------------------"
            echo "检测到的包及版本状态:"
            echo "----------------------------------------"
            printf "%-40s %-15s %s\n" "Package Name" "Version" "Status"
            echo "----------------------------------------"
            has_vul_pkg=true
        fi

        # 去掉版本号前缀(^、~)
        ver=${ver#^}; ver=${ver#~}

        case "$pkg" in
            next)
                if node -e "const s='$ver'.match(/$VUL_REGEX/);process.exit(s?0:1)"; then
                    printf "%-40s %-15s \033[0;31m[VULNERABLE]\033[0m\n" "$pkg" "$ver"
                    EXIT_CODE=1
                else
                    printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "$pkg" "$ver"
                fi
                ;;
            *)
                result=$(semver_in_range "$ver" "${ECOSYSTEM[$pkg]}" 2>/dev/null)
                if [ "$result" = "OK" ]; then
                    printf "%-40s %-15s \033[0;33m[WARNING]\033[0m\n" "$pkg" "$ver"
                else
                    printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "$pkg" "$ver"
                fi
                ;;
        esac
    done
    
    # 如果没有发现任何相关包,显示提示信息
    if [ "$has_vul_pkg" = false ]; then
        echo "未在项目中发现 CVE-2025-66478 相关的包"
    else
        echo "----------------------------------------"
    fi
}

# 5) 扫描 lock 文件(npm/yarn/pnpm)
scan_lock() {
    local has_lock_pkg=false
    
    for lock in package-lock.json yarn.lock pnpm-lock.yaml; do
        [ -f "$lock" ] || continue
        
        if [ "$has_lock_pkg" = false ]; then
            log OK "Found $lock"
            echo "----------------------------------------"
            printf "%-40s %-15s %s\n" "Package Name" "Version" "Status"
            echo "----------------------------------------"
            has_lock_pkg=true
        fi

        # 定义 Node 脚本为变量(注意引号处理)
        read -r -d '' NODE_SCRIPT <<'EOF'
const fs=require('fs');
const file=process.argv[2];

// 检查文件参数是否存在
if (!file) {
    console.error("Error: No file path provided");
    process.exit(1);
}

// 检查文件是否存在
if (!fs.existsSync(file)) {
    console.error("Error: File does not exist: " + file);
    process.exit(1);
}

let data=fs.readFileSync(file,'utf8');

if(file.endsWith('package-lock.json')){
    try {
        const lock=JSON.parse(data);
        // 检查 packages 字段 (package-lock.json v2+)
        if (lock.packages) {
            Object.entries(lock.packages).forEach(([k,v])=>{
                // 处理路径形式的键,如 "node_modules/next"
                const pkgName = k.split('/').pop();
                if(pkgName === 'next' && v.version) {
                    console.log(`next\t${v.version}`);
                }
                
                // 检查是否有生态包
                const ecosystemPackages = [
                    "@vitejs/plugin-react-server-components",
                    "@parcel/transformer-react-server-components",
                    "react-router-rsc",
                    "waku",
                    "@redwoodjs/web",
                    "react-server"
                ];
                
                for (const ecoPkg of ecosystemPackages) {
                    const ecoPkgName = ecoPkg.split('/').pop();
                    if (pkgName === ecoPkgName && v.version) {
                        console.log(`${ecoPkg}\t${v.version}`);
                    }
                }
            });
        }
        // 检查 dependencies 字段 (package-lock.json v1)
        if (lock.dependencies) {
            Object.entries(lock.dependencies).forEach(([k,v])=>{
                if(k === 'next' && v.version) {
                    console.log(`next\t${v.version}`);
                }
                
                // 检查生态包
                const ecosystemPackages = [
                    "@vitejs/plugin-react-server-components",
                    "@parcel/transformer-react-server-components",
                    "react-router-rsc",
                    "waku",
                    "@redwoodjs/web",
                    "react-server"
                ];
                
                for (const ecoPkg of ecosystemPackages) {
                    const ecoPkgName = ecoPkg.split('/').pop();
                    if (k === ecoPkgName && v.version) {
                        console.log(`${ecoPkg}\t${v.version}`);
                    }
                }
            });
        }
    } catch(e) {
        console.error("Error parsing package-lock.json: " + e.message);
    }
} else if(file.endsWith('yarn.lock')){
    try {
        const lines = data.split('\n');
        let currentPkg = null;
        
        for (let i = 0; i < lines.length; i++) {
            const line = lines[i];
            
            // 匹配包声明行
            const pkgMatch = line.match(/^"?((?:@[^@\/]+\/)?[^@\/]+)@.*?:/);
            if (pkgMatch) {
                currentPkg = pkgMatch[1];
                continue;
            }
            
            // 匹配版本行
            const versionMatch = line.match(/^\s*version\s+"?([0-9]+(?:\.[0-9]+)*(?:-[^\s"]*)?)"?/);
            if (versionMatch && currentPkg) {
                if (currentPkg === 'next') {
                    console.log(`next\t${versionMatch[1]}`);
                }
                
                // 检查生态包
                const ecosystemPackages = [
                    "@vitejs/plugin-react-server-components",
                    "@parcel/transformer-react-server-components",
                    "react-router-rsc",
                    "waku",
                    "@redwoodjs/web",
                    "react-server"
                ];
                
                for (const ecoPkg of ecosystemPackages) {
                    if (currentPkg === ecoPkg) {
                        console.log(`${ecoPkg}\t${versionMatch[1]}`);
                    }
                }
                currentPkg = null;
            }
            
            // 匹配简单格式
            const simpleMatch = line.match(/^((?:@[^\/]+\/)?[^@\s]+)\s+"?([0-9]+(?:\.[0-9]+)*(?:-[^\s"]*)?)"?/);
            if (simpleMatch) {
                if (simpleMatch[1] === 'next') {
                    console.log(`next\t${simpleMatch[2]}`);
                }
                
                // 检查生态包
                const ecosystemPackages = [
                    "@vitejs/plugin-react-server-components",
                    "@parcel/transformer-react-server-components",
                    "react-router-rsc",
                    "waku",
                    "@redwoodjs/web",
                    "react-server"
                ];
                
                for (const ecoPkg of ecosystemPackages) {
                    if (simpleMatch[1] === ecoPkg) {
                        console.log(`${ecoPkg}\t${simpleMatch[2]}`);
                    }
                }
            }
        }
    } catch(e) {
        console.error("Error parsing yarn.lock: " + e.message);
    }
} else if(file.endsWith('pnpm-lock.yaml')){
    try {
        const lines = data.split('\n');
        for (let i = 0; i < lines.length; i++) {
            const line = lines[i];
            // 查找 next 包的定义行
            if (line.includes('next@') || line.includes('/next/') || line.trim().startsWith('next:')) {
                // 查找接下来几行中的版本号
                for (let j = i + 1; j < Math.min(i + 5, lines.length); j++) {
                    const versionMatch = lines[j].match(/^\s*version:\s*['"]?([^'"\s]+)/);
                    if (versionMatch) {
                        console.log(`next\t${versionMatch[1]}`);
                        break;
                    }
                }
            }
        }
    } catch(e) {
        console.error("Error parsing pnpm-lock.yaml: " + e.message);
    }
}
EOF

        # 读取Node脚本的输出并处理
        while IFS=$'\t' read -r pkg ver; do
            # 确保 pkg 和 ver 都不为空
            if [ -n "$pkg" ] && [ -n "$ver" ]; then
                case "$pkg" in
                    next)
                        if node -e "const s='$ver'.match(/$VUL_REGEX/);process.exit(s?0:1)"; then
                            printf "%-40s %-15s \033[0;31m[VULNERABLE]\033[0m\n" "$pkg" "$ver"
                            EXIT_CODE=1
                        else
                            printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "$pkg" "$ver"
                        fi
                        ;;
                    *)
                        if [[ -n "${ECOSYSTEM[$pkg]:-}" ]]; then
                            result=$(semver_in_range "$ver" "${ECOSYSTEM[$pkg]}" 2>/dev/null)
                            if [ "$result" = "OK" ]; then
                                printf "%-40s %-15s \033[0;33m[WARNING]\033[0m\n" "$pkg" "$ver"
                            else
                                printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "$pkg" "$ver"
                            fi
                        else
                            printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "$pkg" "$ver"
                        fi
                        ;;
                esac
            fi
        done < <(node -e "$NODE_SCRIPT" -- "$lock" 2>/dev/null || echo "")
    done
    
    if [ "$has_lock_pkg" = true ]; then
        echo "----------------------------------------"
    fi
}

# 6) 扫描 node_modules(应对无 lock 场景)
scan_node_modules() {
    [ -d node_modules/next ] || return 0
    ver=$(node -pe "require('./node_modules/next/package.json').version" 2>/dev/null || echo "")
    [ -n "$ver" ] || return 0
    
    echo "----------------------------------------"
    printf "%-40s %-15s %s\n" "Package Name" "Version" "Status"
    echo "----------------------------------------"
    
    if node -e "const s='$ver'.match(/$VUL_REGEX/);process.exit(s?0:1)"; then
        printf "%-40s %-15s \033[0;31m[VULNERABLE]\033[0m\n" "next" "$ver"
        EXIT_CODE=1
    else
        printf "%-40s %-15s \033[0;32m[SAFE]\033[0m\n" "next" "$ver"
    fi
    echo "----------------------------------------"
    
    return 0
}

# 扫描全盘资产的 package.json 文件
# 函数:扫描包含package.json的目录
# 参数:
# $1: 要扫描的根目录路径
scan_package_json_dirs() {
    local root_dir="$1"
    local found_dirs=()
    
    # 定义排除列表
    local exclude_patterns=(
        "/proc/*"
        "/dev/*"
        "/sys/*"
        "/run/*"
        "/tmp/systemd-private-*"
        # "*/node_modules/*"
        "*/.cache/*"
        "*/site-packages/*"
        "*/.vscode-server/*"
        "*/cache/*"
        "*.log"
    )
    
    # 检查根目录是否存在
    if [ ! -d "$root_dir" ]; then
        echo "错误: 目录 '$root_dir' 不存在" >&2
        return 1
    fi
    
    # 构建find命令的排除参数
    local find_exclude_args=()
    for exclude in "${exclude_patterns[@]}"; do
        find_exclude_args+=(-path "$exclude" -prune -o)
    done
    
    # 使用find命令查找所有包含package.json的目录
    while IFS= read -r -d '' dir; do
        found_dirs+=("$dir")
    done < <(find "$root_dir" "${find_exclude_args[@]}" -name "package.json" -type f -printf '%h\0' 2>/dev/null | sort -z | uniq -z)
    
    # 输出结果
    for dir in "${found_dirs[@]}"; do
        echo "$dir"
    done
    
    return 0
}

# 在指定目录中执行扫描的函数
scan_project_directory() {
    local project_dir="$1"
    echo "====== Scanning project in $project_dir ======"
    
    # 检查目录是否存在且包含 package.json
    if [ ! -d "$project_dir" ] || [ ! -f "$project_dir/package.json" ]; then
        echo "Warning: Directory $project_dir does not exist or does not contain package.json"
        return
    fi
    
    # 保存当前目录
    local original_dir=$(pwd)
    
    # 进入项目目录并执行扫描,使用 || true 确保即使出错也不会导致脚本退出
    cd "$project_dir" || { echo "Failed to enter directory $project_dir"; cd "$original_dir"; return; }
    scan_manifest || echo "Warning: Failed to scan manifest in $project_dir"
    scan_lock || echo "Warning: Failed to scan lock files in $project_dir"
    scan_node_modules || echo "Warning: Failed to scan node_modules in $project_dir"
    
    # 返回原始目录
    cd "$original_dir" || { echo "Failed to return to original directory"; return; }
}

# 7) 主流程
echo "====== CVE-2025-66478 Self Check Pro ======"

if [ "$SCAN_MODE" = "full" ]; then
    echo "Performing full disk scan..."
    while IFS= read -r project_dir; do
        scan_project_directory "$project_dir"
    done < <(scan_package_json_dirs "/")
else
    # 默认项目扫描模式
    scan_project_directory "$TARGET_DIR"
fi

echo "====== Summary ======"
[ $EXIT_CODE -eq 0 ] && log OK "未检测到受影响组件,请保持依赖更新!" \
|| log ERR "发现高危版本,请立即升级到官方修复版本!"
exit $EXIT_CODE