18. Security

For developersVersion 1.0.0Last updated:

BuilderOS → Security (rail; with the rail off, top bar) protects the site without third-party plugins, paid third-party services or external accounts. The scanner compares against wordpress.org checksums and the firewall can receive signed daily rules, which are optional: if they don’t arrive, the firewall continues with its local rules with no notices or blocks. The essentials are on by default and never block whoever edits the site.

How it works

The module (includes/modules/class-builder-os-security.php and includes/modules/security/) is the first of the modules to load. Its firewall decides at plugin load, before WordPress processes the request. The rest hooks in with WordPress actions and filters.

In this chapter

Two-step verification

  • Set up: Users → Profile → “Two-step verification” → Set up. A QR code (generated on the server, with no external services) and the key to type by hand appear. You type a code from the app and click Activate.
  • Recovery codes: 10 single-use codes in the format 12345-67890, stored hashed. They are shown only once. New ones can be generated with a code from the app.
  • On entry: after the correct password, the just-created session is voided and the code is requested in a second step with the BuilderOS login design. After 5 wrong codes you have to start over, and the failures count toward the attempt limit.
  • Required for administrators: anyone who doesn’t have it can only use their profile until they set it up. If an administrator loses their phone and codes, another administrator can deactivate it from their profile.
  • Other access routes: it works with any form that uses wp_signon(). XML-RPC with the normal password is closed for these accounts; application passwords keep working.
  • Passkeys (WebAuthn): an alternative to the code in the second step (Builder_OS_Sec_Passkeys, admin/js/builder-os-passkeys.js). They require TOTP verification to be on; up to 10 per user; adding or deleting requires a TOTP code. Verification in PHP with no dependencies: minimal CBOR, ES256, RS256 and EdDSA keys (with sodium), signature with openssl_verify, type check, challenge, origin, rpIdHash, user-presence flag and signature counter (if it doesn’t advance, access is rejected and a possible-clone notice is logged). “none” attestation. 32-byte challenges, single-use, tied to the user and the pending verification, expiring after 5 minutes (transients bos_2fa_pkc_*). The site identifier is the host of site_url(): with an IP the option is hidden. Failures count toward the attempt limit just like a wrong code. BUILDEROS_DISABLE_2FA deactivates them along with everything else; deactivating a user’s verification also deletes their keys.
  • The secret: it is stored encrypted (AES-256 with the wp-config.php salts). If the salts are changed, it has to be set up again.

Custom login URL

With the setting on, for example with acceso-equipo:

  • /acceso-equipo/ serves the login form. Without pretty permalinks, /?acceso-equipo is used.
  • wp-login.php and /wp-admin/ return the site’s 404 page to anyone who isn’t logged in. /login, /admin and /dashboard no longer redirect to the login.
  • These keep working:
    • logging out;
    • password recovery and reset;
    • registration;
    • postpass;
    • the embedded login (interim-login);
    • admin-ajax.php and admin-post.php;
    • the REST API and WP-Cron;
    • WordPress recovery mode.
  • WordPress links (site_url, wp_login_url, logout_url, lostpassword_url, register_url, redirects) and those in reset and new-user emails point to the new address.
  • When it is changed, an email is sent to the administrator with the new address and the emergency line. The screen shows it with a copy button.
  • The slug is validated: 3 to 50 characters, not colliding with pages, posts, categories, tags, content types, WordPress query variables or language codes. It also can’t be a reserved address (wp-admin, admin, wp-login, dashboard, feed…). login is allowed.
  • It isn’t available on multisite.

Integrity scanner

  • What it compares:
    • WordPress files against api.wordpress.org/core/checksums/1.0/ (first with the site’s language and, failing that, with en_US);
    • wordpress.org plugins against downloads.wordpress.org/plugin-checksums/.
  • What it reports:
    • modified files;
    • files missing in wp-admin and wp-includes;
    • unknown files in wp-admin and wp-includes;
    • PHP inside uploads (except empty index.php files).
  • Plugins not from wordpress.org (your own or paid ones, BuilderOS included) appear as “Not verifiable”.
  • How it works:
    • In batches of about 3 seconds, with a progress bar. If the page is closed, WP-Cron finishes it.
    • Weekly with WP-Cron. If it finds something, it emails the administrator.
  • It deletes nothing.
  • With no internet access, the report says so clearly and doesn’t wait plugin by plugin.
  • Truthful messages and retry:
    • Each request to wordpress.org is retried once. If HTTPS fails (old root certificates on the host or a proxy that intercepts TLS), it is repeated over HTTP, as WordPress’s get_core_checksums() does, and the report says so.
    • The error states the cause: timeout (“it will retry on its own”), TLS (“ask your host to update the certificates”) or no connection. A 403, 429 or 5xx from a proxy counts as a network failure. A plugin without Version is “Not verifiable”, not a network failure. A WordPress version with no published checksums (development) has its own notice.
    • If something couldn’t be compared, BuilderOS retries only what was missed (the WordPress checksums, the plugins with errors, or both) at 1, 3 and 12 hours (WP-Cron builder_os_sec_scan_retry) and merges it with the last scan, without going through uploads again. The Retry what was missed button does the same immediately (?bos_scan=retry).
    • On Home, a recent scan that couldn’t verify WordPress says “The last scan couldn’t connect to wordpress.org… It retries on its own”, with Retry. Before, it fell under “The scanner hasn’t run in more than 7 days”. The scanner’s 25 points are deducted only if WordPress was left unverified; plugins that weren’t compared are flagged without penalty.

Antispam and SVG files

The Security tab ends with two sections, Antispam (#bos-antispam) and SVG files (#bos-svg), before “Activity log”. They are hosted with the builder_os_admin_security action: any module can add a security section with add_action( 'builder_os_admin_security', … ). The details are in chapter 19.

Activity log

  • Where: in its own table {prefijo}bos_security_log.
  • What it stores:
    • successful logins (indicating whether they used two steps) and failed ones;
    • blocks;
    • activations and deactivations of two-step verification and use of recovery codes;
    • role changes, new and deleted users;
    • plugins activated and deactivated;
    • changes to BuilderOS settings (with the keys changed, never the values);
    • changes to the login URL;
    • scans;
    • firewall blocks.
  • Rotation: anything older than 30 days and anything beyond 5,000 rows is deleted.
  • On screen: it is filtered by type and searched by IP, user or text (also in the extra data, such as the user agent).
  • On uninstall the table, settings, users’ two-step data, blocks, scheduled tasks and the uploads/.htaccess block are deleted. On deactivating the plugin, the tasks and the uploads rules are removed.

Audit

A score from 0 to 100, weighted like the SEO one. Each problem carries its recommendation and each correct item is shown as correct. Whatever can’t be checked (no update data, for example) doesn’t count.

It checks:

  • HTTPS;
  • the WordPress version;
  • PHP 8.2 or higher;
  • plugins and themes not updated;
  • the “admin” user;
  • administrators’ two-step verification;
  • the file editor;
  • the login URL;
  • the headers;
  • the firewall;
  • the attempt limit;
  • XML-RPC;
  • on-screen errors (WP_DEBUG);
  • uploads;
  • exposed files;
  • the last scan.

If you get locked out (emergency routes)

Add the line to wp-config.php (by FTP or with the host’s file manager), log in, fix the problem and remove it:

ProblemLine
I lost my phone and recovery codesdefine( 'BUILDEROS_DISABLE_2FA', true );
I don’t remember the custom login URLdefine( 'BUILDEROS_DISABLE_LOGIN_SLUG', true ); (wp-login.php works again; the setting is kept)
The attempt limit has blocked medefine( 'BUILDEROS_DISABLE_LOGIN_LIMIT', true ); (or wait for it to expire: 30 min the first time)
The firewall blocks something legitimatedefine( 'BUILDEROS_DISABLE_FIREWALL', true ); (better still: add the IP to the allowlist)
Country restriction locks me outdefine( 'BUILDEROS_DISABLE_COUNTRY_BLOCK', true ); (an open session is never cut; an IP on the allowlist isn’t locked out either)

The Security screen shows this table. When a constant is active, the measure appears as “paused” or “turned off by …”.

What it doesn’t cover

It is practical protection, comparable to the free version of a plugin WAF, but not to a commercial WAF:

  • No IP reputation network or real-time updated malicious IP lists. Country blocking is optional, login only, and is described under “Country restriction”.
  • No malware signatures: the scanner compares against the official checksums, but doesn’t analyze the contents of theme files, of plugins that aren’t from wordpress.org, or of the database looking for malicious code.
  • Fixed rules (no automatic rule updates or virtual patches for specific plugin flaws).
  • No network firewall: the firewall acts when the request already reaches PHP. Files that exist (for example, a real debug.log) are served directly by the server: that’s why the exposed files check exists. It doesn’t stop denial-of-service (DDoS) attacks; for that you need a CDN or the host’s firewall.
  • It doesn’t inspect cookies, headers (except the user agent), uploaded files, admin-ajax or requests from logged-in users.
  • Signed REST routes. Notices coming from external services that are already signed and verified (Twilio SMS, WhatsApp, Brevo, Amazon SES, the incoming automation webhook, license notices) may carry something resembling code in the body (an SMS with <script>): the firewall doesn’t block them so the message isn’t lost. Each module declares its routes with the builder_os_firewall_signed_routes filter; the signature is still verified inside each route (bad or missing signature = 403 from the route itself) and everything else (forms, A/B measurement, appointment bookings, carts, private review comments) is still inspected.
  • The custom login URL appears in the public links WordPress generates for commenting while logged in. It is a layer against automated traffic, not a secret.

Enumeration, firewall, real IP and defaults

User enumeration

With “Make user enumeration harder” (on by default), anyone who hasn’t logged in:

  • gets a 404 on ?author=N and ?author_name=;
  • doesn’t see the author field or the author link in the REST API (posts, pages, other types and comments), and ?author= and orderby=author are ignored;
  • doesn’t get author_name or author_url in oEmbed;
  • doesn’t find users in the sitemap or in /wp/v2/users;
  • doesn’t see comment-author-<usuario> in the comment classes.

Author archives (author_archives). Off on new installs: /author/<usuario>/ gives a 404 to anyone who hasn’t logged in, the theme’s author links go to the home page and feeds sign with the site name. On: those pages are public and indexable and feeds sign with the author. On a site that already existed, it stays on if it has more than one published post.

What it doesn’t close: WordPress’s password recovery still distinguishes whether the account exists, and what the theme shows on purpose (author byline) is visible. BuilderOS’s Article schema publishes the author’s display name.

Firewall

It acts when WordPress loads the plugin, on requests that reach PHP. It doesn’t see what the server delivers without PHP (images, .log or .sql files) or already-cached pages. That’s why the server rules and the HTTP check under Hardening exist: wp-content/.htaccess closes debug.log on Apache and LiteSpeed, and Nginx has its rules in the panel.

  • Block inspection: each text is scanned in 128 KB blocks with 4 KB overlap. Padding no longer hides what comes after it.
  • Fail closed: a text body over 4 MB (builder_os_firewall_max_body), more than 1.5 s inspecting (builder_os_firewall_max_seconds) or exhausted PCRE gives 403 with the oversize category. php://input is read with that cap, and isn’t read on forms, multipart, XML or binary types.
  • Exempt: only those who can edit (edit_posts; filter builder_os_firewall_exempt_user). A subscriber or a customer is inspected like any visitor.
  • admin-ajax: it is now inspected. WP-Cron and WP-CLI stay out; builder_os_firewall_exclude excludes anything else.