<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Simple Software</title>
    <description>The latest articles on DEV Community by Simple Software (@simplesoftware).</description>
    <link>https://dev.to/simplesoftware</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F841%2F10b9d646-b51c-4c48-b79e-0f61bb5444e5.png</url>
      <title>DEV Community: Simple Software</title>
      <link>https://dev.to/simplesoftware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simplesoftware"/>
    <language>en</language>
    <item>
      <title>The Surprising Results Of VueJS Conditional Rendering “v-if”</title>
      <dc:creator>Corey McCormick</dc:creator>
      <pubDate>Mon, 12 Oct 2020 00:39:02 +0000</pubDate>
      <link>https://dev.to/simplesoftware/the-surprising-results-of-vuejs-conditional-rendering-v-if-49ee</link>
      <guid>https://dev.to/simplesoftware/the-surprising-results-of-vuejs-conditional-rendering-v-if-49ee</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5G6MDgRn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AwYpRuJFpF_49f9vY" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5G6MDgRn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AwYpRuJFpF_49f9vY" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@d_mccullough?utm_source=medium&amp;amp;utm_medium=referral"&gt;Daniel McCullough&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today was one of those days that everything seemed to go wrong while trying to create a simple VueJS component. The day that you question everything — am I a developer? What am I doing wrong?? How can this not be working??? Deep despair sets in as nothing on Google seems to find your exact problem. We have all been here. Stack Overflow has abandoned you and you must find an answer to the problem all by yourself. Hopefully, my troubles can save you an hour or two in the future.&lt;/p&gt;

&lt;p&gt;First, a quick summary of the differences between v-if and v-show. v-if is used when one doesn’t want the DOM element to load onto the page unless the directive is set to true. Toggling the directive will cause the DOM element to be removed from the DOM and then re-inserted firing all associated &lt;a href="https://vuejs.org/v2/guide/instance.html#Instance-Lifecycle-Hooks"&gt;VueJs life cycle events.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;v-showis used to hide and display components within the DOM. The key differences come down to the method in which the elements are removed from the display. Instead of completely remove the DOM element; a CSS property is added display:none. It is important to note that the VueJS lifecycle events will not fire while using v-show.&lt;/p&gt;

&lt;p&gt;v-show will always load the element to the DOM which results in a higher initial render but quicker display toggling. See more details in the &lt;a href="https://vuejs.org/v2/guide/conditional.html#v-if-vs-v-show"&gt;documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My situation began with a very simple VueJs Component very much like the following. JsFiddle (&lt;a href="https://jsfiddle.net/simplycorey/7s20ra1e/11/"&gt;https://jsfiddle.net/simplycorey/7s20ra1e/11/&lt;/a&gt;) Notice that the alert “mounted” only occurs once even though the component should mount multiple times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="cache-demo"&amp;gt;
  &amp;lt;cache-demo :component="component" v-if="component === 'first'"&amp;gt;&amp;lt;/cache-demo&amp;gt;
  &amp;lt;cache-demo :component="component" v-if="component === 'second'"&amp;gt;&amp;lt;/cache-demo&amp;gt;
&amp;lt;button @click="component = 'first'"&amp;gt;
    First
  &amp;lt;/button&amp;gt;
  &amp;lt;button @click="component = 'second'"&amp;gt;
    Second
  &amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I was attempting to retrieve data in the mounted function as I have done a thousand times before. All seemed normal when the page would load as my components would mount, retrieve their data and show up properly. The problem? Somehow the data was &lt;strong&gt;&lt;em&gt;leaking&lt;/em&gt;&lt;/strong&gt; between the two. This blew my mind at first because I had no logic to share the data between them. Checking the props verified that they were receiving the correct information. Continued debugging showed that the mounted, created, destroyed, and other lifecycle events were not firing.&lt;/p&gt;

&lt;p&gt;So what gives? It boils down to VueJS attempting to be smart by using an internal cache system to speed up the rendering of the DOM. VueJS will automatically re-use the component and share its data between them. This can cause surprising and frustrating results if you do not know what is going on.&lt;/p&gt;

&lt;p&gt;Adding a key attribute will alert VueJS that the components are indeed different and should not use this internal cache system. Instead, the components will fully load each time firing all of the VueJS lifecycle events.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://vuejs.org/v2/guide/conditional.html#Controlling-Reusable-Elements-with-key"&gt;Controlling Reusable Elements with &lt;/a&gt;&lt;a href="https://vuejs.org/v2/guide/conditional.html#Controlling-Reusable-Elements-with-key"&gt;&lt;em&gt;key&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vue tries to render elements as efficiently as possible, often re-using them instead of rendering from scratch. Beyond helping make Vue very fast, this can have some useful advantages. &lt;a href="https://vuejs.org/v2/guide/conditional.html#Controlling-Reusable-Elements-with-key"&gt;Read more.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Updating our example to the following would provide the results I was looking for. You’ll notice that clicking first or second will always fire the mounted event. JsFiddle (&lt;a href="https://jsfiddle.net/simplycorey/3uvde2p7/3/"&gt;https://jsfiddle.net/simplycorey/3uvde2p7/3/&lt;/a&gt;) Notice that “mounted” is always fired when switching the loaded components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="cache-demo"&amp;gt;
  &amp;lt;cache-demo key="first" :component="component" v-if="component === 'first'"&amp;gt;&amp;lt;/cache-demo&amp;gt;
  &amp;lt;cache-demo key="second" :component="component" v-if="component === 'second'"&amp;gt;&amp;lt;/cache-demo&amp;gt;
&amp;lt;button @click="component = 'first'"&amp;gt;
    First
  &amp;lt;/button&amp;gt;
  &amp;lt;button @click="component = 'second'"&amp;gt;
    Second
  &amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Check out &lt;a href="https://keep.sh"&gt;keep.sh&lt;/a&gt; if you enjoyed this article and learned something. keep.sh is a &lt;a href="https://keep.sh"&gt;free server file transfer system that allows you to send a file with a single command.&lt;/a&gt; Try it from your MacBook terminal or any command line the supports curl now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --upload-file ./yourLocalFile.txt https://keep.sh

https://keep.sh/3d1fd43a21/yourLocalFile.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I hope this example and explanation will save you some hours in the future!&lt;/p&gt;




</description>
      <category>vue</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Detecting and Blocking Vulnerable Curl Requests From Your Users</title>
      <dc:creator>Corey McCormick</dc:creator>
      <pubDate>Mon, 12 Oct 2020 00:34:52 +0000</pubDate>
      <link>https://dev.to/simplesoftware/detecting-and-blocking-vulnerable-curl-requests-from-your-users-46g9</link>
      <guid>https://dev.to/simplesoftware/detecting-and-blocking-vulnerable-curl-requests-from-your-users-46g9</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OMSQaZlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AEJBsnFoEs8CYAxPR" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OMSQaZlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2AEJBsnFoEs8CYAxPR" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;amp;utm_medium=referral"&gt;Markus Spiske&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I recently came across a very interesting, and potentially exploitable, problem while working on &lt;a href="https://keep.sh"&gt;keep.sh&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was uploading a file with an Authorization header from a curl client and noticed a strange behavior. During a redirect, the Authorization header stayed with the request even though it was redirected to a different domain.&lt;/p&gt;

&lt;p&gt;This sparked my interest as this was clearly undesired behavior and a possible security issue.&lt;/p&gt;

&lt;p&gt;A quick Google search led me to &lt;a href="https://curl.haxx.se/docs/CVE-2018-1000007.html"&gt;CVE-2018-1000007&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When asked to send custom headers in its HTTP requests, curl will send that set of headers first to the host in the initial URL but also, if asked to follow redirects and a 30X HTTP response code is returned, to the host mentioned in URL in the Location: response header value.&lt;/p&gt;

&lt;p&gt;Sending the same set of headers to subsequent hosts is, in particular, a problem for applications that pass on custom Authorization: headers, as this header often contains privacy-sensitive information or data that could allow others to impersonate the curl-using client's request.&lt;/p&gt;

&lt;p&gt;We are not aware of any exploit of this flaw.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This security vulnerability has been patched within curl for well over a year but still largely exists in the wild. As of today’s writing, the vulnerability still exists on my MacBook Pro which runs Curl 7.54 natively if you have not specifically updated it using Homebrew or another solution.&lt;/p&gt;

&lt;p&gt;This security vulnerability caused a large headache for our service as we rely on the Authorization header for our premium offerings. (Coming Soon!)&lt;/p&gt;

&lt;p&gt;This vulnerability prevents our customers from safely downloading their files from our service as it leaks their Authorization information to third party providers.&lt;/p&gt;

&lt;p&gt;When you download a file from our service, we currently return a signed URL that redirects to our Digital Ocean space. This allows for your download to start immediately without us having to be a middle-man that fetches the file from our servers and then relay it to you.&lt;/p&gt;

&lt;p&gt;This approach speeds up the request and reduces server demand. Herein lies the problem — if your version of curl is vulnerable to a signed redirect, you may be leaking your keys during this redirect.&lt;/p&gt;

&lt;p&gt;There was a lot of internal discussion on how to solve this problem to prevent our customers from unknowingly exposing their private keys.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do we detect the requesting curl version and simply block the request? Do we allow our customers to use a curl version with this security vulnerability and show a warning? Do we abandon the use of redirects?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To make finding a solution even more difficult — we cannot simply detect and rely on the curl version as patches were released for older versions. This means that if you are using an older version of curl it &lt;strong&gt;&lt;em&gt;may&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;may not&lt;/em&gt;&lt;/strong&gt; be vulnerable.&lt;/p&gt;

&lt;p&gt;In the end, we had to get creative to solve this complicated issue. We created a two-part system to &lt;em&gt;detect&lt;/em&gt; if the incoming requests have this vulnerability and then &lt;em&gt;block&lt;/em&gt; the vulnerable requests with a notice.&lt;/p&gt;

&lt;p&gt;When a download is first received, our system inspects the User-Agent header for the version of curl you are using. This is done to check if you are using an older version of curl that may be vulnerable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
 * Determines if a curl request may be vulnerable to CVE-2018-1000007
 *
 * @param Request $request
 * @return bool
 */
protected function curlMayBeVulnerable(Request $request)
{
    if (! $request-&amp;gt;hasHeader('Authorization')) {
        return false;
    }

    [$agent, $version] = explode('/', $request-&amp;gt;userAgent());
    $version = new Version($version);
    $vulnerableVersion = new Version('7.58.0');

    if ($version-&amp;gt;lt($vulnerableVersion)) {
        return true;
    }

    return false;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once we determine that you are using a version of curl that may be vulnerable, we send a redirect to a separate secure domain &lt;strong&gt;controlled by us.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This behavior mimics the actual security vulnerability &lt;strong&gt;&lt;em&gt;without&lt;/em&gt;&lt;/strong&gt; exposing your private keys to an outside organization.&lt;/p&gt;

&lt;p&gt;This specially-crafted redirect simply checks if the Authorization headers are still present. If they are (and they shouldn’t be), &lt;em&gt;this means that your current version of curl is vulnerable to CVE-2018–1000007.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After we determine that you are vulnerable to this attack, we actively block the request from continuing and show an error message on your console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The version of curl you are using has a known security vulnerability that prevents us from safely allowing you to download your files. See [https://curl.haxx.se/docs/CVE-2018-1000007.html](https://curl.haxx.se/docs/CVE-2018-1000007.html) for more information.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Balancing security with convenience is a constant battle. We could have easily just ignored the issue and allowed our customers to expose their Authorization header to an outside organization while retrieving their files.&lt;/p&gt;

&lt;p&gt;We believed, even though it can potentially take away from the experience, that blocking all vulnerable requests is the best course of action. This protects our users and their files.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;keep.sh is a free file transfer service that allows you to &lt;a href="http://keep.sh"&gt;transfer files easily with a simple command line on any server.&lt;/a&gt; We recommend you try it today! &lt;strong&gt;curl — upload-file file.txt&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




</description>
      <category>curl</category>
      <category>security</category>
    </item>
    <item>
      <title>Thank Your Favorite Projects</title>
      <dc:creator>Corey McCormick</dc:creator>
      <pubDate>Sun, 16 Jun 2019 22:48:52 +0000</pubDate>
      <link>https://dev.to/simplesoftware/thank-your-favorite-projects-2jpk</link>
      <guid>https://dev.to/simplesoftware/thank-your-favorite-projects-2jpk</guid>
      <description>&lt;p&gt;Over the years, I have used probably 100's of different open source projects throughout my codebases.  Many of these do not get the thanks the deserve so here is a small shout out to Spatie(&lt;a href="https://twitter.com/spatie_be"&gt;https://twitter.com/spatie_be&lt;/a&gt;), the provider of my most used open source projects!  Thank you!&lt;/p&gt;

&lt;p&gt;Who do you owe a thanks to?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What's your favorite Easter egg you have ever hidden in your work?</title>
      <dc:creator>Corey McCormick</dc:creator>
      <pubDate>Fri, 14 Jun 2019 23:25:01 +0000</pubDate>
      <link>https://dev.to/simplesoftware/what-s-your-favorite-easter-egg-you-have-ever-hidden-in-your-work-5087</link>
      <guid>https://dev.to/simplesoftware/what-s-your-favorite-easter-egg-you-have-ever-hidden-in-your-work-5087</guid>
      <description>&lt;p&gt;Most recently, I have been embedding quotes within random code doc blocks as a way to remind myself to have fun. They typically make me laugh years later when I find them.&lt;/p&gt;

&lt;p&gt;Here is one from a recent cache clear command I created which displays anytime the command is called:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;It can take years to mold a cache. It takes only a fraction of a second for it to be shattered...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What have you been hiding around your codebase?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
  </channel>
</rss>
