{"id":3150,"date":"2024-04-18T03:29:53","date_gmt":"2024-04-18T08:29:53","guid":{"rendered":"https:\/\/www.darkreading.com\/application-security\/sneaky-shellcode-windows-fibers-edr-proof-code-execution"},"modified":"2024-04-18T03:29:53","modified_gmt":"2024-04-18T08:29:53","slug":"sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution","status":"publish","type":"post","link":"https:\/\/ddi.mohflo.net\/index.php\/2024\/04\/18\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution\/","title":{"rendered":"Sneaky Shellcode: Windows Fibers Offer EDR-Proof Code Execution"},"content":{"rendered":"<div class=\"media_block\"><a href=\"https:\/\/i0.wp.com\/eu-images.contentstack.com\/v3\/assets\/blt6d90778a997de1cd\/blt7e22039997bdf4ff\/6620d95ef8211a1ffe55d9c4\/threads-Robert_K_Chin-Alamy.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution.jpg?w=640&#038;ssl=1\" class=\"media_thumbnail\"><\/a><\/div>\n<div><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution.jpg?w=640&#038;ssl=1\" class=\"ff-og-image-inserted\"><\/div>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Windows fibers, little-known components of Windows OS, represent a largely undocumented code-execution pathway that exists exclusively in usermode \u2013 and is therefore largely overlooked by <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/www.darkreading.com\/cyberattacks-data-breaches\/-blindside-attack-subverts-edr-platforms-windows-kernel\" rel=\"noopener\">endpoint detection and response (EDR) platforms<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">. As such, it&#8217;s possible for attackers to exploit them to stealthily land on PCs and deploy malicious payloads.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">That&#8217;s according to Daniel Jary, an independent security researcher, who laid out two new proof-of-concept (PoC) attacks using fibers in <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/www.blackhat.com\/asia-24\/briefings\/schedule\/#immoral-fiber-unlocking-38-discovering-new-offensive-capabilities-of-fibers-37947\" rel=\"noopener\">a session at Black Hat Asia<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"> on Thursday.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Fibers are an alternative to the standard &#8220;threads&#8221; that Windows uses to execute code from the OS or an application, he explains.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;Threads are like workers, essentially, within a Windows process or an application, and traditionally, they&#8217;ve always been the way that you&#8217;d execute code and get things done,&#8221; he tells Dark Reading. &#8220;But there&#8217;s a more niche way of doing it, through fibers.&#8221;<\/span><\/p>\n<h2 class=\"ContentText ContentText_variant_h2 ContentText_align_left\" data-testid=\"content-text\" id=\"Fibers: A Forgotten &amp; Overlooked Windows OS Pathway\">Fibers: A Forgotten &amp; Overlooked Windows OS Pathway<\/h2>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Fibers, when used, exist within threads \u2013 they&#8217;re essentially smaller, more lightweight versions of the bigger thread concept. <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/procthread\/fibers\" rel=\"noopener\">Fibers were initially developed<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"> at a time when CPUs had fewer cores available to them and could accommodate only so many threads. At a high level, the smaller were a way to expand capacity, by allowing developers to split up workloads within a single thread and make processes more efficient.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;But as computers became more powerful, with more memory to play with, fibers became somewhat redundant in the vast majority of scenarios,&#8221; Jary explains. &#8220;And that&#8217;s why a lot of people really haven&#8217;t heard about them and they&#8217;re a bit obscure, but they do serve a few purposes for some old legacy applications and a way to port programs from other operating systems over to Windows. And, some Windows processes themselves actually still use fibers.&#8221;<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Thus, fibers enjoy the dubious honor of being both a core Windows function, and an overlooked one by security teams. And to boot, Jary notes that traditional detection mechanisms in EDR platforms and antivirus engines tend to ignore them \u2013 making them a perfect stealth avenue to execute malicious code.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;Threads are heavily monitored by EDR agents, which look at syscalls and kernel mode callbacks to capture telemetry and send it to a rules engine to generate detection,&#8221; explains Jary. &#8220;But fibers exist purely in usermode, and don&#8217;t show up in kernel collection; so their telemetry is not actually getting recorded by EDRs.&#8221;<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Some open-source techniques already exist to take advantage of fibers&#8217; under-the-radar status. A PoC from 2022 for instance details a method for <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/www.hopinfosec.com\/evasion\/2022\/05\/11\/evasion-pt3\/\" rel=\"noopener\">hiding malicious shell code inside a fiber<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">, thus evading the majority of AV engines. &nbsp;<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Others have created methods for <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/www.mdsec.co.uk\/2022\/07\/part-2-how-i-met-your-beacon-cobalt-strike\/\" rel=\"noopener\">callstack masking<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">, which enables attackers to hide a malicious execution pathway within a thread\u2014in this case, a fiber\u2014behind a different, dormant fiber that&#8217;s benign\u2014also evading detection. The technique takes advantage of the fact that if fibers are in use, there&#8217;s always an active fiber, then a dormant fiber that it switches off with. This masking capability that was added into Cobalt Strike&#8217;s Artefact Kit in 2022.<\/span><\/p>\n<h2 class=\"ContentText ContentText_variant_h2 ContentText_align_left\" data-testid=\"content-text\" id=\"New Frontiers in Malicious Fiber Execution\">New Frontiers in Malicious Fiber Execution<\/h2>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Jary set off to explore whether it&#8217;s possible to improve on existing malicious fiber techniques, and came up with two new PoCs, dubbed Phantom Thread and Poison Fiber.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Existing adversarial fiber methods have certain disadvantages for attackers: Some indicators could still be used for EDR detection; and the maliciousness isn&#8217;t hidden from inline event-based callstack collection. And, any collection of dormant fibers, for which several techniques exist, would remove callstack masking.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Phantom Thread is a next-gen callstack masking approach that removes the ability of memory scans to target fibers, by having those fibers masquerade as threads. This involves creating a fiber, then patching it so that it self-identifies as a thread. Then, it becomes possible to remove any fiber callstack indicators and essentially hide the fibers from any scanning altogether.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">The second PoC, Poison Fiber, enumerates any running Windows processes, looking at threads in use and then whether any of those threads are using fibers. Then, &#8220;it presents you with an opportunity to inject your payload or your shellcode into a dormant fiber,&#8221; Jary explains.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;You can only one run one fiber per thread at any one time, which means you always have another dormant fiber parked somewhere else on the stack,&#8221; he says. &#8220;When we execute our code using Poison Fiber, this injects our code into a dormant fiber, so we don&#8217;t have to suspend the thread in order to inject the shellcode, which is a huge indicator for malicious activity. And, because we&#8217;ve injected the payload into a dormant fiber, then the application triggers the execution for us, and we don&#8217;t initiate the execution ourselves.&#8221; The technique has an added benefit of allowing remote code-execution (RCE) as well.<\/span><\/p>\n<h2 class=\"ContentText ContentText_variant_h2 ContentText_align_left\" data-testid=\"content-text\" id=\"Wake Up to Fiber's Adversarial Potential\">Wake Up to Fiber&#8217;s Adversarial Potential<\/h2>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">While they remain somewhat obscure, fibers should be on security teams&#8217; list of attack vectors, warns Jary, who has not yet released his evolved PoCs or granular details on the methods publicly. He reasons that it&#8217;s only a matter of time before others find ways of overcoming drawbacks in existing open-source fiber execution methods. &nbsp;<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;Fiber&#8217;s alternate execution method is valuable to attackers because it helps us sidestep traditional telemetry sources that we get with threads, in particular kernel callbacks,&#8221; he says. &#8220;Fibers aren&#8217;t a privilege escalation tactic; and they aren&#8217;t a user access comntrol (UAC) bypass. But it does allow a payload delivery that gets a lot less spotlight and attention from the security community. Fibers are really simple to implement, but they&#8217;re harder to detect. So that makes them perfect for any script kiddie to use to attack businesses.&#8221;<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">Jary advises implementing <\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"><a class=\"ContentText-BodyTextChunk ContentText-BodyTextChunk_link\" target=\"_blank\" href=\"https:\/\/www.darkreading.com\/application-security\/mockingjay-edr-tools-process-injection-technique\" rel=\"noopener\">mature EDR products<\/a><\/span><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\"> that can be continually tested against emerging techniques like these.<\/span><\/p>\n<p class=\"ContentParagraph ContentParagraph_align_left\" data-testid=\"content-paragraph\"><span class=\"ContentText ContentText_variant_bodyNormal\" data-testid=\"content-text\">&#8220;Talk to your red teamers about open-source fiber methods which are being used in the wild,&#8221; he says. &#8220;Do some research to see what attackers are having joy with, what&#8217;s popular in the wild, then feed that back into your research team and your EDR product developers. That&#8217;s going to help build better defenses and probably make your threat-hunters&#8217; lives a little bit easier as well.&#8221;<\/span><\/p>\n<p><a href=\"https:\/\/www.darkreading.com\/application-security\/sneaky-shellcode-windows-fibers-edr-proof-code-execution\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows fibers, little-known components of Windows OS, represent a largely<\/p>\n","protected":false},"author":12,"featured_media":3151,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[809],"class_list":["post-3150","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-dark-reading"],"featured_image_urls":{"full":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=2560%2C1706&ssl=1",2560,1706,false],"thumbnail":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?resize=150%2C150&ssl=1",150,150,true],"medium":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=300%2C200&ssl=1",300,200,true],"medium_large":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=640%2C427&ssl=1",640,427,true],"large":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=640%2C427&ssl=1",640,427,true],"1536x1536":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=1536%2C1024&ssl=1",1536,1024,true],"2048x2048":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=2048%2C1365&ssl=1",2048,1365,true],"chromenews-featured":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=1024%2C683&ssl=1",1024,683,true],"chromenews-large":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?resize=825%2C575&ssl=1",825,575,true],"chromenews-medium":["https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?resize=590%2C410&ssl=1",590,410,true]},"author_info":{"display_name":"Dark Reading","author_link":"https:\/\/ddi.mohflo.net\/index.php\/author\/darkreading\/"},"category_info":"<a href=\"https:\/\/ddi.mohflo.net\/index.php\/category\/uncategorized\/\" rel=\"category tag\">Uncategorized<\/a>","tag_info":"Uncategorized","comment_count":"0","jetpack_featured_media_url":"https:\/\/i0.wp.com\/ddi.mohflo.net\/wp-content\/uploads\/2024\/04\/sneaky-shellcode-windows-fibers-offer-edr-proof-code-execution-scaled.jpg?fit=2560%2C1706&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/posts\/3150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/comments?post=3150"}],"version-history":[{"count":0,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/posts\/3150\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/media\/3151"}],"wp:attachment":[{"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/media?parent=3150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/categories?post=3150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ddi.mohflo.net\/index.php\/wp-json\/wp\/v2\/tags?post=3150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}