<?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: Aurimar</title>
    <description>The latest articles on DEV Community by Aurimar (@aurimarl).</description>
    <link>https://dev.to/aurimarl</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%2Fuser%2Fprofile_image%2F800875%2F0b0adc7d-74b6-41d3-9f41-e993f67a2cda.png</url>
      <title>DEV Community: Aurimar</title>
      <link>https://dev.to/aurimarl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aurimarl"/>
    <language>en</language>
    <item>
      <title>How I Accidentally "Hijacked" an npm Package 🚨</title>
      <dc:creator>Aurimar</dc:creator>
      <pubDate>Tue, 26 Nov 2024 17:48:11 +0000</pubDate>
      <link>https://dev.to/aurimarl/how-i-accidentally-hijacked-an-npm-package-198e</link>
      <guid>https://dev.to/aurimarl/how-i-accidentally-hijacked-an-npm-package-198e</guid>
      <description>&lt;p&gt;As developers, we often focus on writing clean code and building innovative features. However, sometimes it's the seemingly small decisions that can have significant implications. I recently had an experience that I believe is crucial to share with our community. hashtag#DeveloperLessons&lt;/p&gt;

&lt;h2&gt;
  
  
  The Incident
&lt;/h2&gt;

&lt;p&gt;While working on a fork of an open-source project, I decided to publish my modifications to npm. Due to some publishing errors and, admittedly, a bit of impatience, I made a critical mistake:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I removed the &lt;em&gt;&lt;a class="mentioned-user" href="https://dev.to/scope"&gt;@scope&lt;/a&gt;&lt;/em&gt; from the original &lt;a class="mentioned-user" href="https://dev.to/scope"&gt;@scope&lt;/a&gt;/PackageName.&lt;/li&gt;
&lt;li&gt;Published my fork simply as &lt;em&gt;PackageName&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Unintended Consequence
&lt;/h2&gt;

&lt;p&gt;The original package used a common npx command in its documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx PackageName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By publishing my fork with the same name, I inadvertently "hijacked" all calls to this command. Users intending to use the original package would now be directed to my fork instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Security Implications
&lt;/h2&gt;

&lt;p&gt;This situation highlights a significant security risk in our npm ecosystem. If exploited maliciously, such an oversight could lead to the distribution of compromised code to unsuspecting developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Always thoroughly understand npm scopes before publishing.&lt;/li&gt;
&lt;li&gt;Be extremely cautious when naming packages to avoid conflicts.&lt;/li&gt;
&lt;li&gt;Double-check your package name and its potential impact on existing packages.&lt;/li&gt;
&lt;li&gt;When forking and publishing, always use scoped packages.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Responsible Disclosure
&lt;/h2&gt;

&lt;p&gt;Upon realizing my mistake, I immediately:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Contacted the original repository owner. You can view our discussion here: &lt;a href="https://lnkd.in/d6fBbP9z" rel="noopener noreferrer"&gt;GitHub Issue #67&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Documented the incident for transparency. My forked repo: &lt;a href="https://lnkd.in/dVx7FEs6" rel="noopener noreferrer"&gt;AurimarL/surrealdb-client-generator&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Call to Action
&lt;/h2&gt;

&lt;p&gt;As members of the developer community, we have a shared responsibility to maintain the integrity and security of our package ecosystems. I encourage everyone to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regularly audit your published packages&lt;/li&gt;
&lt;li&gt;Stay vigilant about package names and versions in your projects&lt;/li&gt;
&lt;li&gt;Contribute to discussions about improving npm security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's work together to create a more secure and robust development environment for all.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>npm</category>
      <category>security</category>
    </item>
  </channel>
</rss>
