Post Date:
Last Updated: November 30, 2026
Introduction
You installed an SSL certificate, added a firewall, turned on a security plugin, and set strong passwords. Then one morning your website starts redirecting visitors to a spam page. This is how most websites get hacked today: not by breaking the security you set up, but by walking around it through everyday habits nobody thinks about.
In this guide, we look at 10 real ways websites get hacked even with security in place, based on what developers, agencies, and site owners actually do. For each one, you will see why security tools miss it and exactly how to fix it, with quick checks you can run on your own site today.
Key takeaways:
- People and process beat tools: most attacks use a shared password, a forgotten account, or a leaked key, not a clever exploit.
- Secrets leak more than ever: GitGuardian found nearly 29 million new secrets exposed on public GitHub in 2025, up 34% in one year.
- 2FA is not the finish line: stolen session cookies let attackers skip both your password and your 2FA.
- Small checks catch big gaps: a few commands and a 30-minute review close most of these holes.
Quick self-check: how many of these are true for your team?
- Someone has shared an admin password in WhatsApp, Slack, or email.
- A freelancer or former employee still has a login to your website.
- There is a staging or test copy of your site you have not updated in months.
- A backup file or database dump has been saved inside the website folder.
- Your site loads a script from a third-party CDN you have never reviewed.
If you said yes to even one, your website has a gap that a firewall or SSL certificate will not close.
At Pheonix Solutions, we clean up hacked websites and run security reviews for businesses, and the 10 habits below are the ones we find again and again.
On This Page
Why Websites Get Hacked Even With Security in Place
Security tools are good at what they are built for: blocking known attack patterns, encrypting traffic, and stopping brute-force logins. But they trust anyone who arrives with a valid password, a valid session, or a script loaded from a domain you approved. Attackers know this, so they go after the people and processes around your website instead.

- Stolen credentials are the top entry point: Verizon’s Data Breach Investigations Report found stolen credentials in 31% of breaches over the past 10 years.
- Leaked secrets stay dangerous: GitGuardian reports that 70% of secrets leaked in 2022 were still valid years later.
- AI is adding to the problem: commits written with AI coding assistants leak secrets at twice the normal rate, according to GitGuardian’s 2026 report.
Prerequisites for Checking Your Website Security
You can review most of these habits in about 30 minutes. To run the checks in this guide, you need:
- Administrator access to your website and hosting control panel.
- SSH access to the server, plus WP-CLI if your site runs on WordPress.
- Git and the free gitleaks scanner for checking code repositories.
- A list of everyone who has worked on the site, including agencies and freelancers.
- Permission to test: only run these checks on websites and servers you own or manage.
10 Ways Websites Get Hacked (and How to Stop Each One)
Each habit below follows the same pattern: what teams actually do, why your security tools miss it, and how to fix it.
1. Admin Passwords Shared in WhatsApp, Slack, and Email
What teams actually do: “Can you send me the WordPress login?” The password goes into a chat, an email thread, or a project ticket, and it stays there for years.
Why security tools miss it: The password is strong and 2FA may even be on, so nothing looks wrong. But anyone who gets into that chat, inbox, or a teammate’s laptop now has your admin login. GitGuardian found that 38% of secret leaks in collaboration tools such as Slack, Jira, and Confluence were highly critical or urgent.
Fix it: Give every person their own account instead of sharing one admin login. Share any remaining credentials only through a password manager, change passwords that have ever been sent in chat, and turn on 2FA for every administrator.
2. Old Admin Accounts Nobody Removed
What teams actually do: A freelancer builds a feature, an agency handles a redesign, an employee leaves. Their administrator accounts stay active because nobody owns the clean-up.
Why security tools miss it: Every login from those accounts is “legitimate”. If one of those people reuses a password that later leaks, an attacker walks straight in.
Fix it: Review administrator accounts every month and remove anyone who no longer needs access. On WordPress, list every admin with WP-CLI:
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
Delete an old account and move its posts to another user (here, user ID 1):
wp user delete 42 --reassign=1
Note: Replace 42 with the ID of the account you are removing. Always reassign content before deleting a user who has published posts or pages.
3. API Keys and .env Files Committed to Git
What teams actually do: A developer commits a .env file or pastes an API key into the code “just for testing”, then deletes it in the next commit.
Why security tools miss it: Deleting the file does not delete it from Git history. Anyone with access to the repository, or to a copy of it, can still read the key. GitGuardian found nearly 29 million new hardcoded secrets in public GitHub commits in 2025, and private repositories are not safe either.
Fix it: Add .env to .gitignore, keep secrets in environment variables or a secrets manager, and scan your full repository history with gitleaks:
# Scan every commit in the current repository for leaked keys and passwords
gitleaks git -v .
Note: If gitleaks finds a real secret, rotate it immediately at the provider (create a new key and disable the old one). Removing it from the code is not enough, because the old key still works.
4. Forgotten Staging and Test Sites
What teams actually do: A copy of the site lives at staging.example.com or old.example.com. It was useful during the redesign, and then everyone forgot about it.
Why security tools miss it: Your firewall, updates, and monitoring cover the live site only. The forgotten copy runs outdated plugins, often with the same database credentials, and it is a perfect way in.
Fix it: Keep a list of every subdomain and environment. Password-protect staging sites, block search engines from indexing them, keep them updated, and delete the ones you no longer use. Public certificate logs show which subdomains exist for your own domain:
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
Note: Replace example.com with your own domain. The command needs jq installed, and it lists every subdomain that has ever had an SSL certificate, so check each result you do not recognize.
5. Backups and Database Dumps Left in the Web Root
What teams actually do: Before an update, someone saves backup.zip or database.sql inside the website folder, intending to delete it later.
Why security tools miss it: Anything inside the web root can be downloaded by anyone who guesses the file name, and attackers scan for these names automatically. One downloaded database dump can expose every user’s email and password hash.
Fix it: Store backups outside the public folder or offsite, and search your web root for leftover files:
find /var/www/html -maxdepth 3 -type f \( -name "*.sql" -o -name "*.zip" -o -name "*.tar.gz" -o -name "*.bak" \)
Note: Change /var/www/html to your site’s document root. Move or delete anything this command finds, then review your backup process so files are never saved there again.
Not sure how many of these gaps your website has? Our security team reviews your site, accounts, and server for exactly these habits and fixes what we find. Talk to our website security experts for a free consultation.
6. “Nulled” Premium Themes and Plugins
What teams actually do: To save money, someone downloads a paid theme or plugin for free from an unofficial site.
Why security tools miss it: The file installs like any other plugin, but “nulled” copies often include hidden backdoors that create admin users or inject spam. Security researchers have tracked malware families, such as WP-VCD, spreading through exactly these downloads.
Fix it: Only install themes and plugins from WordPress.org or the original developer. Delete any theme or plugin you are not using, because inactive code can still be attacked.
7. Debug Mode Left On in Production
What teams actually do: Debug mode was switched on to fix a bug on the live site, and it was never switched off.
Why security tools miss it: Error pages and debug screens can reveal file paths, database names, and in some frameworks even environment variables and API keys, giving attackers a map of your site.
Fix it: Keep debugging on your local or staging site, and make sure production has it turned off:
// wp-config.php on the live site
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false );
# .env for a Laravel application in production
APP_ENV=production
APP_DEBUG=false
8. Session Cookies Stolen by Infostealer Malware
What teams actually do: An admin opens a fake invoice, a “sponsorship” PDF, or a cracked piece of software on the same computer they use to manage the website.
Why security tools miss it: Infostealer malware copies the browser’s saved session cookies. The attacker then reuses your logged-in session, so they never need your password or your 2FA code. In March 2023, the Linus Tech Tips YouTube channels were hijacked this way after an employee opened a malicious file posing as a sponsor’s PDF.
Fix it: Use a separate browser profile only for website admin work, never install cracked software, keep login sessions short, and log every user out if you suspect a stolen session. On WordPress, this ends every session for every user:
wp user list --field=ID | xargs -n 1 wp user session destroy --all
Note: After ending all sessions, change the affected passwords and scan the admin’s computer for malware. Otherwise the attacker can simply steal the new session too.
9. Third-Party Scripts That Change Owners
What teams actually do: The site loads a helpful script from a public CDN, added years ago and never reviewed.
Why security tools miss it: Your security trusts that domain completely. In 2024, the popular polyfill.io domain was sold to a new owner, and Sansec found it injecting malware into more than 100,000 websites. The malicious code even stayed hidden from logged-in admins.
Fix it: Self-host the scripts you depend on, remove the ones you no longer need, and add Subresource Integrity (SRI) so the browser refuses a file that has been changed:
https://cdn.example.com/library.min.js
A Content Security Policy (CSP) header adds another layer by limiting which domains can run scripts on your site:
add_header Content-Security-Policy "script-src 'self' https://cdn.example.com;" always;
Note: Test a new CSP on staging first. A policy that is too strict can block analytics, chat widgets, or payment scripts your site needs.
10. Exposed .git Folders and Admin Tools
What teams actually do: The site is deployed by copying the whole project folder, including the hidden .git directory, or phpMyAdmin is left open to the internet.
Why security tools miss it: A public .git folder lets anyone download your source code and its full history, including any secrets from habit 3. An open phpMyAdmin page invites password guessing against your database.
Fix it: Check whether your own site exposes its .git folder:
curl -s -o /dev/null -w "%{http_code}\n" https://www.example.com/.git/HEAD
A result of 200 means the folder is public. Block hidden files on Nginx, and restrict phpMyAdmin to trusted IP addresses or remove it:
location ~ /\.(git|env|svn) {
deny all;
}

Output
Here is what healthy and unhealthy results look like when you run two of the checks above on your own site:
$ curl -s -o /dev/null -w "%{http_code}\n" https://www.example.com/.git/HEAD
403
$ wp user list --role=administrator --fields=user_login,user_registered
+-------------+---------------------+
| user_login | user_registered |
+-------------+---------------------+
| siteowner | 2023-04-11 09:12:44 |
| agency-dev | 2024-01-08 15:30:02 |
+-------------+---------------------+
The 403 means the .git folder is blocked, which is what you want. The admin list shows an old agency account that should be removed. The values above are an example; your results depend on your own site.
Conclusion
Most websites get hacked through the gaps between security tools: shared passwords, forgotten accounts and sites, leaked keys, risky downloads, and third-party code nobody reviews. The good news is that every one of these gaps can be closed with clear habits and a few regular checks.
- Control access: one account per person, 2FA for every admin, and monthly clean-ups.
- Protect secrets: keep keys out of code and chats, scan Git history, and rotate anything that leaks.
- Shrink your attack surface: remove old staging sites, backups in the web root, unused plugins, and exposed admin tools.
- Trust less: official plugins only, Subresource Integrity, a Content Security Policy, and a separate browser for admin work.
- Check regularly: run the self-checks in this guide every month and after every team change.
FAQs
1. Can a website be hacked even with an SSL certificate and a firewall?
Yes. SSL encrypts traffic and a firewall blocks known attack patterns, but neither stops someone who logs in with a stolen password, reuses a stolen session, or loads malicious code through a script you already trust.
2. How do I know if my website has been hacked?
Common signs include unknown admin users, unexpected redirects (especially on mobile), new files you did not upload, spam pages in Google search results, browser or Google Search Console warnings, and sudden traffic or email spikes.
3. Does two-factor authentication stop all account takeovers?
No. 2FA stops attackers who only have your password, but infostealer malware can steal the session cookie created after you log in, which lets attackers skip 2FA entirely. Keep admin devices clean and keep sessions short.
4. How often should I check my website security?
Review admin accounts, plugins, and backups at least once a month, and immediately whenever someone joins or leaves the team, an agency project ends, or you notice anything unusual.
5. What should I do first if my website is hacked?
Take a backup of the current state for investigation, change all passwords, end every active session, remove unknown admin users, and then clean or restore the site from a known-good backup before updating everything.
Related Articles
- WordPress Website Protection: 7 Essential Steps
- PHP2Shell Vulnerability: How to Protect Your PHP Server
- Architecting a Secure Authentication System for Modern Web Applications
- Create a Custom WordPress Plugin in 2026: 7 Easy Steps
Official Documentation
- OWASP Top 10
- Hardening WordPress
- OWASP Session Management Cheat Sheet
- Gitleaks
- Subresource Integrity (MDN)
- Content Security Policy (MDN)
- GitGuardian State of Secrets Sprawl 2026
- Sansec: Polyfill Supply Chain Attack
Talk to Website Security Experts
Security tools are only half the job; the other half is the habits around them. At Pheonix Solutions, our ISO 27001 certified team has more than 10 years of experience securing, maintaining, and recovering business websites.
We can help you with:
- Security services, including security reviews, hardening, and malware clean-up for hacked websites.
- Software maintenance and support with monthly updates, account reviews, and monitoring.
- DevOps and cloud services for secure deployments, secrets management, and backups.
- VPS hosting with firewalls and hardened server configuration.
Worried your website might already have one of these gaps? Talk to our website security experts and get a free consultation.
