flawopen.com/Teardowns/cve-2023-32558-nodejs-permission-model-fs-escape

● CVE-2023-32558 · CVSS 7.5 · उच्च
सुरक्षा अनुसंधान · FlawOpen

तकनीकी विश्लेषण: CVE-2023-32558: Node.js Permission Model Filesystem Escape Teardown

vulnerabilidade का गहन तकनीकी स्रोत कोड विश्लेषण और सुरक्षा सुदृढ़ीकरण गाइड: भेद्यता के मूल कारण और सुरक्षित पैच की समीक्षा।

💡 आसान भाषा में (ELI5)

सरल भौतिक उपमा द्वारा समझें: Imagine a high-security office building with security guards at the front doors checking badges. A worker who doesn't have a badge walks around back, opens the maintenance door marked 'Internal Staff Only', and walks straight into the vault. In Node.js, the developer guarded the public JavaScript functions, but forgot to lock the underlying C++ internal door.

इस पेज के मुख्य शब्द

Node.js Permission Model
The experimental --permission CLI flag restricting process capabilities like filesystem, child process, and worker access.
process.binding()
The legacy internal Node.js API that directly exposes native C++ bindings to JavaScript code.
Path Containment
Ensuring file operations remain strictly inside specified directory boundaries.
Defense-in-Depth
Enforcing security checks at the lowest possible layer (native C++ layer) rather than superficial JS wrappers.

मूल कारण विश्लेषण (Root Cause)

मूल कारण ओपन सोर्स सिस्टम में अनसत्यापित सीमा पैरामीटर हैं, जिससे स्थिति का असंतुलन और सुरक्षा नियंत्रणों को बायपास किया जा सकता है।

हमले का चरण-दर-चरण प्रवाह

Step 1

हमला चरण: Start Sandboxed Node.js Process

तकनीकी शोषण तंत्र और निष्पादन विवरण: A developer runs untrusted code with node --permission --allow-fs-read=/tmp app.js.

Step 2

हमला चरण: Access Internal Binding

तकनीकी शोषण तंत्र और निष्पादन विवरण: The script invokes const binding = process.binding('fs');.

Step 3

हमला चरण: Bypass High-Level JS Checks

तकनीकी शोषण तंत्र और निष्पादन विवरण: The script calls binding.open('/etc/passwd') directly, bypassing fs.readFile() wrappers.

Step 4

हमला चरण: Arbitrary System File Read

तकनीकी शोषण तंत्र और निष्पादन विवरण: The native C++ binding executes without permission checks, leaking confidential server files.

सोर्स कोड: कमज़ोर बनाम सुरक्षित कार्यान्वयन

कमज़ोर कार्यान्वयन
// VULNERABLE: src/node_file.cc before patch
static void Open(const FunctionCallbackInfo<Value>& args) {
    Environment* env = Environment::GetCurrent(args);
    
    // ROOT CAUSE:
    // Only verified permissions if called through JS 'fs' module wrappers!
    // Direct callers of process.binding('fs').open() evaded the check!
    const char* path = *Utf8Value(env->isolate(), args[0]);
    int fd = uv_fs_open(..., path, ...);
    args.GetReturnValue().Set(fd);
}
सुरक्षित और सुदृढ़ फ़िक्स
// SECURE: src/node_file.cc patch
static void Open(const FunctionCallbackInfo<Value>& args) {
    Environment* env = Environment::GetCurrent(args);
    
    const char* path = *Utf8Value(env->isolate(), args[0]);
    
    // 1. Enforce permission verification directly inside native C++ binding layer
    if (env->permission()->is_enabled()) {
        if (!env->permission()->is_granted(PermissionScope::kFileSystemRead, path)) {
            THROW_ERR_ACCESS_DENIED(env, "Access to path %s denied by Permission Model", path);
            return;
        }
    }
    
    int fd = uv_fs_open(..., path, ...);
    args.GetReturnValue().Set(fd);
}

इंजीनियरिंग और सिस्टम सुरक्षा चेकलिस्ट

स्रोत