{"id":19001,"date":"2026-10-22T21:02:24","date_gmt":"2026-10-22T18:02:24","guid":{"rendered":"https:\/\/www.hyyat.com\/knowledgebase\/exposed-sensitive-files-env-git-backups\/"},"modified":"2026-10-22T21:02:32","modified_gmt":"2026-10-22T18:02:32","password":"","slug":"exposed-sensitive-files-env-git-backups","status":"publish","type":"docs","link":"https:\/\/www.hyyat.com\/en\/knowledgebase\/exposed-sensitive-files-env-git-backups\/","title":{"rendered":"Exposed Sensitive Files on Your Site: .env, .git and Backups, and How to Hide Them"},"content":{"rendered":"<div class=\"hkb\" dir=\"ltr\">\n<div class=\"hkb-tldr\"><b>In short<\/b>Every file inside your site folder public_html can be requested from a browser. If you leave a .env file with passwords, a .git folder with your full code, or a zipped backup there, anyone who knows the name can download it, and attackers try these names automatically on every site. The rule: keep in public_html only what visitors should see, and block access to whatever cannot be moved.<\/div>\n<figure class=\"hkb-fig\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/10\/hkb-exposed-files.webp\" alt=\"Exposed sensitive files: env, git and backup files inside the site folder and a magnifier\" width=\"1200\" height=\"630\" loading=\"lazy\" \/><\/figure>\n<p>When a site is hacked we usually imagine a clever attack. But sometimes the attacker only types <span dir=\"ltr\">yoursite.com\/.env<\/span> into a browser and finds the database password and payment keys written in front of them. Automated scanners try dozens of well-known names on every site they find.<\/p>\n<h2>The most dangerous exposed files<\/h2>\n<div class=\"hkb-tbl\">\n<table>\n<thead>\n<tr>\n<th>File<\/th>\n<th>What it holds<\/th>\n<th>Where it comes from<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><span dir=\"ltr\">.env<\/span><\/td>\n<td>Database passwords, API keys and payment keys.<\/td>\n<td>Laravel, Node.js and other projects.<\/td>\n<\/tr>\n<tr>\n<td>The <span dir=\"ltr\">.git<\/span> folder<\/td>\n<td>Your full code with its history, possibly including old passwords.<\/td>\n<td>Deploying with Git straight into public_html.<\/td>\n<\/tr>\n<tr>\n<td><span dir=\"ltr\">backup.zip<\/span>, <span dir=\"ltr\">site.tar.gz<\/span><\/td>\n<td>A full copy of the site.<\/td>\n<td>A manual backup left in the folder.<\/td>\n<\/tr>\n<tr>\n<td><span dir=\"ltr\">*.sql<\/span><\/td>\n<td>The whole database.<\/td>\n<td>A phpMyAdmin export never deleted.<\/td>\n<\/tr>\n<tr>\n<td><span dir=\"ltr\">wp-config.php.bak<\/span><\/td>\n<td>WordPress settings and the database password as plain text.<\/td>\n<td>A copy made before editing. Read <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wp-config\/\">protecting wp-config.php<\/a>.<\/td>\n<\/tr>\n<tr>\n<td><span dir=\"ltr\">phpinfo.php<\/span>, <span dir=\"ltr\">error_log<\/span><\/td>\n<td>Server paths, software versions and errors.<\/td>\n<td>Test files or error logs.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>How to check your site<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Open the cPanel File Manager:<\/b> Go to public_html and turn on \u201cshow hidden files\u201d in the settings, because files starting with a dot are hidden by default.<\/li>\n<li><b>Look for risky extensions:<\/b> <span dir=\"ltr\">.zip<\/span>, <span dir=\"ltr\">.tar.gz<\/span>, <span dir=\"ltr\">.sql<\/span>, <span dir=\"ltr\">.bak<\/span>, <span dir=\"ltr\">.old<\/span>, <span dir=\"ltr\">.env<\/span>, and the <span dir=\"ltr\">.git<\/span> folder.<\/li>\n<li><b>Test from the browser:<\/b> Open <span dir=\"ltr\">yoursite.com\/.env<\/span> and <span dir=\"ltr\">yoursite.com\/.git\/config<\/span>. If you see content instead of an error, the file is exposed.<\/li>\n<li><b>Move or delete:<\/b> Download backups and SQL files to your computer, then delete them. Move .env outside public_html if your project allows it.<\/li>\n<\/ol>\n<h2>Block access to what must stay<\/h2>\n<p>If a .env file or .git folder has to stay where it is, add these rules to your main <code>.htaccess<\/code> file:<\/p>\n<pre class=\"hkb-code\">&lt;FilesMatch &quot;^\\.(env|git|htpasswd)|\\.(sql|bak|old|zip|tar|gz|log)$&quot;&gt;\n  Require all denied\n&lt;\/FilesMatch&gt;\nRedirectMatch 404 \/\\.git<\/pre>\n<div class=\"hkb-note w\"><b>If the files were already exposed:<\/b> blocking access now is not enough. Assume their contents were read, and change every password and key in them: the database, API keys and payment keys.<\/div>\n<h2>Habits that prevent the problem<\/h2>\n<ul class=\"hkb-list\">\n<li>Keep backups in a folder outside public_html, or download them straight to your computer.<\/li>\n<li>When deploying from Git, copy only the files, not the .git folder.<\/li>\n<li>Delete test files such as phpinfo.php after using them.<\/li>\n<li>Keep debug mode off on the live site.<\/li>\n<\/ul>\n<div class=\"hkb-hh\">\n<h2>How Hyyat Host protects your site<\/h2>\n<ul>\n<li><strong>ModSecurity<\/strong> and <strong>Imunify360<\/strong> rules block many automated scans for well-known sensitive files.<\/li>\n<li><strong>ImunifyAV<\/strong> scans files daily and detects new malicious files.<\/li>\n<li>If you find a sensitive file that was exposed, open a ticket and we will help you check the logs to see whether anyone downloaded it.<\/li>\n<\/ul>\n<p style=\"margin:10px 0 0\">Also read <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/secure-file-permissions\/\">secure file permissions<\/a>.<\/p>\n<\/div>\n<h2>Frequently asked questions<\/h2>\n<div class=\"hkb-faq\">\n<details>\n<summary>How do I know whether someone downloaded the exposed file?<\/summary>\n<p>Search the visitor logs in cPanel for the file name. If there are successful requests, assume it was downloaded and change the passwords.<\/p>\n<\/details>\n<details>\n<summary>Will deleting the .git folder break my site?<\/summary>\n<p>No, the site does not need it to run. It is only used by the code management tool.<\/p>\n<\/details>\n<details>\n<summary>Where should I keep the backup if not in public_html?<\/summary>\n<p>In a folder in your account outside public_html, or download it to your computer or external storage.<\/p>\n<\/details>\n<\/div>\n<div class=\"hkb-rel\"><b>Related guides<\/b><\/p>\n<ul>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wp-config\/\">How to Protect wp-config.php in WordPress: 7 Steps to Secure Your Most Important File<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-website-database-phpmyadmin\/\">Protecting Your Website Database and phpMyAdmin: Users, Privileges and Passwords<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/secure-file-permissions\/\">Secure File Permissions for Your Website: When to Use 644 and 755, and Why to Avoid 777<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/signs-your-website-is-hacked\/\">How to Tell if Your Website Is Hacked: 10 Signs and Quick Checks<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.hyyat.com\/en\/kb\/website-protection\/\">All website security guides \u2192<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In shortEvery file inside your site folder public_html can be requested from a browser. If you leave a .env file with passwords, a .git folder with your full code, or a zipped backup there, anyone who knows the name can download it, and attackers try these names automatically on every site. The rule: keep in [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"_templately_pack_id":"","_templately_imported_at":"","_templately_source":"","_templately_import_session_id":"","footnotes":""},"doc_category":[2744],"doc_tag":[],"class_list":["post-19001","docs","type-docs","status-publish","hentry","doc_category-website-protection"],"year_month":"2026-10","word_count":644,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"ahmed fathy","author_nicename":"ahmed-fathy","author_url":"https:\/\/www.hyyat.com\/en\/author\/ahmed-fathy\/"},"doc_category_info":[{"term_name":"Website Security","term_url":"https:\/\/www.hyyat.com\/en\/kb\/website-protection\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/19001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/comments?post=19001"}],"version-history":[{"count":0,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/19001\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media?parent=19001"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_category?post=19001"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_tag?post=19001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}