<?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: doncarlos dame</title>
    <description>The latest articles on DEV Community by doncarlos dame (@doncarlos_dame_dccbff3b32).</description>
    <link>https://dev.to/doncarlos_dame_dccbff3b32</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4198539%2F3bd0ff3e-9ee4-4a37-be2b-e48d4591b422.png</url>
      <title>DEV Community: doncarlos dame</title>
      <link>https://dev.to/doncarlos_dame_dccbff3b32</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/doncarlos_dame_dccbff3b32"/>
    <language>en</language>
    <item>
      <title>Why your Node.js API is leaking sensitive files (and how to fix it in 5 minutes)</title>
      <dc:creator>doncarlos dame</dc:creator>
      <pubDate>Wed, 21 Oct 2026 14:01:14 +0000</pubDate>
      <link>https://dev.to/doncarlos_dame_dccbff3b32/why-your-nodejs-api-is-leaking-sensitive-files-and-how-to-fix-it-in-5-minutes-a6c</link>
      <guid>https://dev.to/doncarlos_dame_dccbff3b32/why-your-nodejs-api-is-leaking-sensitive-files-and-how-to-fix-it-in-5-minutes-a6c</guid>
      <description>&lt;p&gt;As developers, we often focus on writing clean code, optimizing database queries, and building robust APIs. But there is one silent killer that takes down hundreds of production environments every day: &lt;strong&gt;exposing sensitive files in the public root directory.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I've seen this in Node.js projects, PHP, and static sites deployed to the cloud. You think your &lt;code&gt;.env&lt;/code&gt;, your &lt;code&gt;.git&lt;/code&gt; folder, or your database dumps are safe... until someone runs a simple &lt;code&gt;curl&lt;/code&gt; command and downloads your entire infrastructure.&lt;/p&gt;

&lt;p&gt;Let's see how this happens, and how to test your own site in less than 5 minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Silent Threat: Public Folders
&lt;/h3&gt;

&lt;p&gt;If your web server or CDN is misconfigured, a malicious user can try to access common paths like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;https://yourdomain.com/.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;https://yourdomain.com/.git/HEAD&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;https://yourdomain.com/backup.zip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;https://yourdomain.com/db.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the server returns &lt;code&gt;200 OK&lt;/code&gt; instead of &lt;code&gt;403 Forbidden&lt;/code&gt; or &lt;code&gt;404 Not Found&lt;/code&gt;, &lt;strong&gt;you have a critical vulnerability.&lt;/strong&gt; Your database credentials, API keys, and source code are publicly available.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to check if you are exposed (Right Now)
&lt;/h3&gt;

&lt;p&gt;Open your terminal and run this simple &lt;code&gt;curl&lt;/code&gt; command against your own domain:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
curl -I https://yourdomain.com/.env
Look at the HTTP status code:

If you see HTTP/1.1 200 OK: Panic. Your .env file is exposed. Fix it immediately.

If you see HTTP/1.1 403 Forbidden or HTTP/1.1 404 Not Found: You are safe.

How to fix it (Nginx/Apache)
If you are using Nginx, add this block to your server configuration:

nginx
location ~ /\.(env|git|svn|htaccess|htpasswd) {
    deny all;
    return 404;
}

location ~ \.(bak|old|sql|zip|tar\.gz)$ {
    deny all;
    return 404;
}
If you are on Express.js, ensure your static file middleware is not serving hidden files:

javascript
app.use(express.static('public', {
  dotfiles: 'deny',
  index: false
}));
How to automate this check
Checking this manually every time you deploy is a pain. There are tools that can automate this for you and give you a full security report.

I've been building a tool called Sealgrade that runs over 15 external security checks (including this exact file exposure test, SSL, DNS, and missing HTTP headers) and gives you a 0-100 health score. It's free to run an audit, and it gives you concrete remediation snippets like the ones above.

If you are deploying to production, it's worth a 30-second check: Audit your web here.

Stay safe out there, and keep your .env files private!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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