Skip to content
Back to the Video Research Library

One Script, 507 Infected Rows: Cleaning a WordPress Database Loader

Real-World Case8:59
8:59

The player loads from YouTube (privacy-enhanced mode) only after you press play. No YouTube cookies are set before that.

Share:

What this session covers

A WordPress shop was reported by an external URL check for loading a script from an unknown domain. The file checks were clean: WordPress core matched its checksums, there was no PHP in uploads, no must-use plugins and no unexpected cron jobs. The problem was in the database. The same encoded script block had been appended to the end of 507 of the 588 rows in wp_posts, and not one post_modified date had changed, so sorting by date found nothing.

We rebuild the case in our isolated lab with a harmless replica of the block and walk through the cleanup in five steps: confirm the symptom from the outside, decode the block safely as text, map every post type and table it reached, prove with hashes that one exact cut is safe, and remove only those bytes, with backups and evidence first and every cache layer purged afterwards.

Key takeaways

  • Clean files do not mean a clean site. When a page loads a script that no file contains, search the database by content, never by date.
  • Decode as text, never in a browser. The block hides one String.fromCharCode inside another and ends in eval. The decoded loader adds a second tag with a different id, so search for both names.
  • Clean every row, not only the visible ones. Revisions, templates, orders, coupons, menu items and a WooCommerce transient all carried the block. A restored revision brings it straight back.
  • Hash the tail before you cut. One variant, always at the very end, exactly one copy per row: those three answers make a single hash-guarded UPDATE safe, and anything slightly different is left for manual review.
  • Purge every cache layer. The database was clean while the page cache still served the infected HTML.
  • Use CHAR_LENGTH, not LENGTH. On a multilingual shop, bytes and characters differ, and the cut must be counted in characters.
  • Tell look-alikes apart by evidence. Analytics tags and site seals build script tags too, but they sit in one place, are readable and come from a known vendor.

About the lab

Everything shown runs in an isolated container lab with no network access. The script block is a harmless replica written for this video, and its address is a placeholder that goes nowhere. Database commands run as the site user, and every write happens only after a full backup and an evidence dump of the rows being changed.

Files clean, but the site still loads something odd?

We find and remove malware wherever it lives, files or database, and verify every cache layer afterwards.

Malware removal