I let Claude Code write my posts and push the body to WordPress through the REST API. Every so often an update is rejected with a 403 — but only when the body contains certain things, like a PowerShell snippet or a Linux path. Reading posts works, authentication is fine, and the same body goes through once I change one line.
The short version: a WAF (SiteGuard Lite, which ships with several Japanese hosts such as ConoHa WING) reads strings like .Substring(, select ... from and /etc/ in the post body as SQL injection or directory traversal, and blocks the request. The fix is not to weaken the WAF, but to write the same thing a different way. Here is the rewrite cheat sheet.

What happened
What gets blocked is the update that sends the body (content), not reading or listing posts. The response is not a WordPress JSON error but SiteGuard's own 403 page. Sending the body in pieces narrows it down to a few fixed patterns: a PowerShell command or a file path, pasted in as-is, is enough to trip it. The same post goes through after one line is reworded.
<TITLE>Forbidden access</TITLE> Powered by SiteGuard Lite
(A separate cause, if your whole /wp-json/wp/v2/ path returns 403 from a cloud IP, is the host's overseas-access restriction, which the ?rest_route= form gets around. That one is a different problem from the body content being flagged.)
What trips the WAF, and what passes
This is what I found by sending the body to a draft a bit at a time. Left is what was blocked, right is the same thing in a form that passed. The WAF settings were never touched.
| What I wrote | What the WAF reads it as | Form that passes |
PowerShell .Substring(3) |
SQL SUBSTRING function | .Remove(0, 3) |
(Get-Date).ToString('yyyyMMdd') |
SQL function call | Get-Date -Format 'yyyyMMdd' |
select ... from (SQL or prose) |
SQL injection | Put the code in an image, or describe it in words |
rename ... to in a sentence |
SQL RENAME ... TO | change ... into / Rename-Item a.txt b.txt (no "to") |
Leading-slash path /etc/hosts |
Directory traversal | Drop the leading slash (etc/hosts) / Windows form C:\Windows\System32\drivers\etc\hosts passes as-is |
Two-level relative path ../../logs |
Directory traversal | One level (../logs), or write the full path |
netstat -ano |
(flagged as network probing) | Get-NetTCPConnection -State Listen |
Single quote then # comment |
(quote + comment) | Use a double quote ("abc" # comment passes) |
'-- / "-- in prose |
SQL comment | Drop the quote and write --force |
| Triple backticks (Markdown code) | (flagged even when empty) | Use a raw-HTML code block (Enlighter) |
Same token, different context
The tricky part is that the same word passes or fails depending on what sits next to it. Select-Object, union all select and between 1 and 10 all pass; only select and from run together as one phrase is blocked. PowerShell's .Substring( is blocked, but .Remove( and .ToString() (no argument) pass. /etc/ is blocked, yet the same letters in the Windows path ...\drivers\etc\hosts go through.
So it isn't "this word is banned" — it's "this looks like attack syntax." Break up the shape without changing the meaning and it passes: .Substring(3) to .Remove(0, 3), (Get-Date).ToString('…') to Get-Date -Format '…', the sentence rename the file to backup to change the file into backup. None of these cost the reader anything.
How to find where it stops
When a whole post returns 403, keep an empty draft around, send the first half and the second half of the body separately, and bisect until you reach the paragraph that fails. Then match it against the table above and reword it. Send the full body once more at the end to overwrite.
The detections add up, so a long post can be blocked by several patterns that would each pass on their own. Fix them one at a time from the table and, at some point, the whole thing goes through.
Don't disable the WAF
You could just turn off SiteGuard's SQL-injection or directory-traversal rules in the server panel and make the 403 disappear. But those rules are also stopping real attacks. Your post only happens to look like one, so rewording the body is safer than switching protection off. I leave the WAF alone and get everything through by wording alone.
Summary
When a WordPress REST API update returns 403, it may be the body, not your credentials. A WAF can read .Substring(, select ... from or /etc/ as SQL injection or traversal. Leave the WAF on and rewrite the string to an equivalent form.

Comments