TL;DR
Your old project is being hacked. This guide helps you quickly find and fix the biggest security holes, focusing on practical steps to protect your data and users.
1. Understand What’s Been Compromised
- Check Logs: Look at server logs (Apache, Nginx, database logs) for unusual activity – failed logins, strange requests, unexpected errors.
- Review Code Changes: If you have version control (Git), examine recent code commits for anything suspicious or potentially vulnerable.
- Identify Affected Data: What data has the attacker accessed? User details? Financial information? This will determine your next steps.
2. Immediate Containment
- Isolate the System: Take the affected server(s) offline if possible to prevent further damage. If you can’t take it fully offline, restrict access as much as possible.
- Change Passwords: Reset passwords for all user accounts (especially admin accounts), database users, and any service accounts. Use strong, unique passwords.
- Revoke API Keys/Tokens: If your project uses APIs, revoke any compromised keys or tokens. Generate new ones.
3. Find the Vulnerability
- Scan for Malware: Use a reputable malware scanner (e.g., ClamAV) to check server files for malicious code.
clamscan -r /path/to/your/project - Check for Common Web Vulnerabilities: Use an automated vulnerability scanner like OWASP ZAP or Nikto. These tools can identify issues like SQL injection, cross-site scripting (XSS), and file inclusion.
Note: Be careful when running scanners on live systems as they can sometimes cause disruption.
- Review Input Validation: Poorly validated user input is a common source of vulnerabilities. Make sure all data entered by users is properly sanitised before being used in your code.
- Escape output to prevent XSS
- Use prepared statements or parameterized queries to prevent SQL injection
- Dependency Check: Outdated libraries and frameworks often have known vulnerabilities. Use a dependency checker (e.g., Snyk, Dependabot) to identify and update vulnerable components.
npm audit
4. Fix the Vulnerability
- Apply Patches: Install security updates for your operating system, web server, database, and all other software.
- Code Changes: Implement fixes to address any identified vulnerabilities in your code (e.g., input validation, output encoding).
- Web Application Firewall (WAF): Consider using a WAF (e.g., ModSecurity) to protect against common web attacks.
Note: A WAF is not a replacement for fixing the underlying vulnerabilities but can provide an extra layer of security.
5. Ongoing Security
- Regular Backups: Regularly back up your data and code to a secure location. Test your backups to ensure they are working correctly.
- Security Monitoring: Implement security monitoring tools (e.g., intrusion detection systems) to detect suspicious activity.
- Penetration Testing: Hire a cyber security professional to perform regular penetration testing to identify vulnerabilities before attackers do.
- Keep Software Updated: Regularly update all software components to the latest versions.

