DEV Community

Văn Tuấn Lê
Văn Tuấn Lê

Posted on • Originally published at ordinarymantrying.com

The AI Got It Wrong — Then Got It Right (WordPress Redirect Attack)

My website was secretly redirecting Chinese visitors to a virus site. I ran an AI-assisted investigation, found a suspicious analytics script (51.la), removed it — and declared victory.

We were wrong.

The AI blamed 51.la because that's where the evidence pointed. But the real culprit was hiding somewhere file-level scans can never reach: the WordPress database, configured through a compromised plugin called Ad Inserter.

What made this attack so hard to catch

The attacker wasn't sloppy. This was carefully engineered to defeat investigators:

  • Only fires in WeChat's browser — detects MicroMessenger in the User-Agent
  • Once per device per day — cookie-based cooldown means repeat testing always looks clean
  • Invisible on desktop — no redirect, nothing to see
  • No trace in any file — payload stored in wp_options database table, not on disk

Without AI, my only realistic option would have been a full WordPress reinstall. I would have fixed it without ever understanding what happened.

The real lesson

It's not that AI is too weak for security work. The person who built this malware was genuinely smart — money is a powerful motivator for clever engineering. This attack was specifically designed to defeat investigators, and it almost worked.

What failed wasn't AI capability. It was the search space I gave it: check these files. The payload wasn't in any file.

When I gave the AI the right input — rendered page HTML fetched with a WeChat User-Agent — it found the injected 83KB payload in seconds.

Three rules I changed:

  1. Don't let AI define the search space too early
  2. Give AI raw evidence (rendered HTML), not symptoms
  3. Never call an incident solved after one successful test — redirect stopped does not mean malware removed

Full investigation write-up, with screenshots of what victims actually saw:
The AI Got It Wrong — Then Got It Right

Part of an ongoing series on using AI for real IT problems as an ordinary person with no security background.

Top comments (0)