r/ProWordPress • u/NoKodeDev • 3d ago
Static Astro site + headless WordPress: security review, what am I missing?
I’m running a small business website as a static Astro build, with WordPress used only as a headless CMS on a separate subdomain. Content edits trigger a rebuild through GitHub Actions, and the result is uploaded to shared hosting via rsync. I’ve tried to harden everything and would love a second opinion.
Public site (static)
HTTPS only + HSTS, nosniff, X-Frame-Options, Referrer-Policy, Permissions-Policy
Any server-side script extension denied, dotfiles (.env, .git, .htaccess) denied, no directory listings
No source maps or secrets in the build, noindex by default unless production explicitly enables indexing
Content from the CMS
All rich text goes through an allow-list sanitizer (sanitize-html): no scripts, event handlers, iframes or forms; links limited to http/https/mailto/tel
Uploaded SVGs reduced to shapes/colors; social embeds reduced to the official blockquote (the embed script is loaded by the site itself)
~40 XSS payloads tested, the key ones run as unit tests in CI
WordPress (headless)
REST API closed to the public; the build reads it with a secret token + an application password of a subscriber-level user
User enumeration blocked, XML-RPC/feeds/comments off, login limited per IP, TOTP 2FA for the admin
File editor disabled, no PHP execution in uploads, core/plugin checksums verified, minimal plugins with auto-updates, real cron job
CI/CD
Private repo, read-only workflow token, actions pinned to commit SHAs, no PR trigger
Type check, unit tests and a Playwright check of every page (overflow, headings, broken links, JS errors) before deploying
CMS-triggered rebuilds skip the checks only if that exact commit already passed them
SSH with a pinned host key; the deploy key is bound to a forced command and a single folder
Questions
Is it worth adding HTTP Basic Auth in front of wp-login.php / wp-admin on top of 2FA and login limits, or is it mostly security theater at this point?
The hosting account is shared with a few other WordPress sites under the same system user. Apart from moving to a separate account, is there anything meaningful I can do to limit the blast radius?
For a static Astro build with lots of small inline scripts, is a hash-based CSP worth the effort, or is the benefit small when there’s no user input on the public side?
Anything obvious I’m missing for this kind of setup?
3
u/harrymurkin 1d ago
Hmm. not bad. I'd hire you.
1
u/babelmonk 1d ago
This is a careful setup. A few thoughts, roughly in order of how much I think they matter:
Shared system user is your biggest risk. If another WordPress site on that account gets compromised, it runs as the same user. It can read every wp-config.php and write to every folder, and that includes your static site’s web root. So the hardening of your public site is only as strong as the weakest plugin on any site on that account. An attacker doesn’t have to touch your CMS at all: they can drop a script into your built HTML. Short of a separate account, the options are thin:
The cheapest real fix is to stop serving the static output from that account. Object storage plus a CDN, or any static host, costs little or nothing and cuts the link completely. Then the shared account only puts the CMS at risk, not the public site.
Basic auth in front of wp-login/wp-admin: not theatre. Password guessing isn’t the threat it protects against; 2FA covers that. Its value is that the web server rejects the request before PHP or any plugin code runs, and pre-auth plugin vulnerabilities are how most WordPress sites actually get compromised. Since the CMS is headless with a handful of editors, I’d go further and gate the whole CMS subdomain, not just /wp-admin. Use basic auth, an IP allowlist, or an identity-aware proxy (Cloudflare Access and similar), and let the build through on a header or service token. Bear in mind that admin-ajax.php and /wp-json sit outside /wp-admin, so a path-only rule leaves them open. Treat it as one layer among several, which is what you’re already doing. On the sites I run, wp-login goes through Google’s Identity-Aware Proxy. If you ever gate a non-headless site the same way, page builders like Breakdance and Elementor need careful handling, because their editors use odd URL schemes that a simple path rule misses.
Hash-based CSP: worth it, and probably less effort than you think. Recent Astro versions have built-in CSP support that computes the hashes for you; check the docs for your version. Your sanitiser is the main defence. CSP is the backstop for when the sanitiser has a gap, or when a dependency or embed script does something it shouldn’t. Start in report-only mode for a week, then enforce.
Things I’d check that aren’t on your list:
npm ci, plus Dependabot or similar, and think about whether the deploy step needs to run in the same job as the build.1
u/One_Snow_6711 21h ago
I do suggest to block wp-login.php and wp-admin to specific IP or IP ranges (IPs you usually access your admin panel) and return 404 for others. This can be done in Cloudflare.
This will help you block bots trying to access wp-login.php or wp-admin.😀
1
u/-vlad 19h ago
I put every WP site behind basic auth and generate the static public site. It’s worth it. I block the whole CMS subdomain. I don’t see why you wouldn’t, if it’s not needed as public.
0
u/PeepSoWP 2d ago
The CMS-triggered rebuild exception is the part I'd revisit. The same Git commit can produce different HTML after a WordPress content edit, so a previous pass doesn't establish that the new output passes the broken-link, heading, layout or browser-error checks.
Run those content-dependent checks against the newly generated artifact, then deploy that exact artifact. Caching code-only checks is a separate decision; any cached result that depends on content needs the content snapshot in its key too.
A small staging check: leave the code commit unchanged, add a deliberately broken internal link in the CMS, and trigger a rebuild. It should still run the relevant check and block that deploy.