How to Detect and Remove SEO Injection Attacks on WordPress
Picture this: you run a legitimate water safety company, and one day a client searches your domain on Google — only to find an indexed page titled "Poker Card Dimensions — Free Online Casino". That is exactly what happened to sosmalaga.es, a lifeguard services company in Málaga, Spain. And it happens far more often than most website owners realize.
This article walks you through what an SEO Injection attack is, how to spot one before it spirals out of control, and how to clean and harden your WordPress site against future compromises.
What Is an SEO Injection Attack?
An SEO Injection (also called a Pharma Hack or Casino Hack) is a type of cyberattack where a malicious actor gains access to your site and silently injects spam content — casino pages, counterfeit pharmaceuticals, adult material — to exploit your domain's hard-earned authority for their own SEO gain.
The attacker does not want to take your site down. They want your domain to do their dirty SEO work. The consequences for you are severe:
- Reputation damage with users and search engines.
- Diluted domain authority from thin, irrelevant content.
- A potential manual action (penalty) from Google.
- Loss of organic rankings across your entire site.
These attacks typically succeed when WordPress core, plugins, or themes are outdated, or when admin credentials are weak.
How to Detect an SEO Injection
The most dangerous aspect of this attack is that injected content is often invisible to site owners. Hackers use cloaking techniques to show spam content only to search engine crawlers, hiding it from regular visitors and admins.
1. Google Search Operators
Use the site: operator with suspicious keywords:
site:yourdomain.com casino
site:yourdomain.com poker
site:yourdomain.com viagra
If you see URLs or page titles you do not recognize, your site is likely compromised. In the case of sosmalaga.es, the URL /medidas-de-una-carta-de-poker/ was fully indexed with casino content.
2. Google Search Console
Go to Search Console → Performance → Search results and filter by queries. Unexpected keywords like "online casino", "free slots", or "buy pills" appearing alongside your brand are red flags. Check the Coverage report for indexed URLs that should not exist.
3. External Security Tools
- Sucuri SiteCheck (sitecheck.sucuri.net): scans your URL for malware, blacklists, and known injections.
- VirusTotal: analyze suspicious URLs with multiple antivirus engines.
- Screaming Frog: crawl your entire site to surface injected URLs.
Step-by-Step Cleanup Process
Once confirmed, act quickly and methodically.
Step 1: Enable Maintenance Mode
Prevent visitors from encountering compromised content while you clean up.
Step 2: Scan with Wordfence or Sucuri
Install Wordfence Security or Sucuri Security and run a full scan. These plugins identify modified core files, hidden backdoors, and injected content.
# Via WP-CLI (if SSH access is available):
wp plugin install wordfence --activate
wp wordfence scan
Step 3: Remove Infected Files and Spam Pages
- Replace WordPress core files with a clean download from wordpress.org.
- Delete injected posts/pages from the WordPress dashboard or directly from the
wp_postsdatabase table. - Review the
wp_optionstable for suspicious entries.
Step 4: Change All Credentials
- All WordPress admin passwords.
- Database password (update
wp-config.phpaccordingly). - WordPress secret keys and salts (regenerate via the official API).
- FTP/SFTP and hosting panel passwords.
Step 5: Request a Google Review
Once the site is clean, go to Search Console → Security & Manual Actions and submit a review request. Describe every remediation step taken. Google typically responds within one to four weeks.
Step 6: Remove Spam URLs from the Index
Use the URL Removal tool in Search Console to temporarily delist infected pages while the full cleanup is processed by Google.
Prevention: Hardening Your WordPress Site
Cleaning up an attack is expensive. Prevention is dramatically cheaper.
Keep Everything Updated
The vast majority of WordPress hacks exploit known vulnerabilities in outdated plugins or themes. Enable automatic updates for WordPress core and audit your plugins regularly. Remove anything unused.
Use Active Security Plugins
- Wordfence: firewall, malware scanning, IP blocking.
- iThemes Security: login protection, file change detection.
- WP Activity Log: full audit trail of user actions.
Strengthen Admin Access
- Enable two-factor authentication (2FA) for all admin accounts.
- Change the default
/wp-admin/login URL. - Limit failed login attempts.
- Use randomly generated passwords of 16+ characters.
Server-Level Hardening
- Disable PHP execution in
/wp-content/uploads/. - Set proper HTTP security headers (Content-Security-Policy, X-Frame-Options).
- Use a Web Application Firewall (WAF) via Cloudflare or your hosting provider.
Schedule Regular Security Audits
Do not wait for an attack to happen. Monthly scans and weekly Search Console reviews allow you to catch anomalies before they become crises.
Conclusion
The sosmalaga.es case is a real-world reminder that SEO Injection attacks target any domain with authority — regardless of industry or size. Early detection, fast action, and consistent prevention are the three pillars of recovery and protection.
If you suspect your WordPress site may be compromised — or simply want to make sure it is properly secured — do not wait for a Google penalty to confirm it.
Need a professional security audit? Check out our Bug Shield service and protect your domain before the damage is done. You can also contact us directly for a free initial assessment.