Download the PHP package generoi/gds-security-hardening without Composer

On this page you can find all versions of the php package generoi/gds-security-hardening. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gds-security-hardening

gds-security-hardening

Security hardening for WordPress that takes no per-site configuration.

Installs as an mu-plugin. Every module is unconditional: anything needing a per-site answer — a REST allowlist, an integration user, a CSP — belongs in that site's own mu-plugins, not here.

What it does

Module Control
XmlRpc Exits on XMLRPC_REQUEST before anything registers; filters xmlrpc_enabled off; removes the RSD link and X-Pingback
Rest Disables JSONP; refuses a read overridden into a write; removes REST discovery output
ApplicationPasswords Closes the remote authorization flow; keeps passwords to manage_options
Headers HSTS (no preload), nosniff, X-Frame-Options, Referrer-Policy on frontend, admin, login and REST
Uploads Keeps parser-heavy formats (PDF/EPS/SVG/HEIC/TIFF/macro-Office) to editors and above
UserEnumeration Blocks ?author=<id>, /wp/v2/users* and the REST _embed author link for anonymous callers; strips the author from oEmbed and the GTM4WP data layer; makes authentication, login and lost-password responses uniform
AuthorArchives Every author archive is a 404, existing name or not; drops core's users sitemap and Yoast's author sitemap
Embeds Turns off oEmbed discovery, so embeds come only from registered providers
Passwords 12-character minimum, enforced server side
Credentials A password reset revokes application passwords and destroys sessions
Roles Pins default_role
Version Removes the generator tag; replaces ?ver= with a site-salted token; drops Acorn's X-Powered-By
ContentSecurityPolicy Four no-upkeep directives on admin; a full Strict CSP (nonce + strict-dynamic) on wp-login.php
Filesystem Stops WordPress rewriting .htaccess

Off by default, opt in with the modules filter:

Module Control
TwoFactor Requires two-factor enrolment before any capability but read

A password reset revokes nothing in core

Worth spelling out because it is surprising. wp_set_password() (wp-includes/pluggable.php:3099) writes the hash, clears the activation key, cleans the cache and fires an action. That is all. Core contains no callers of wp_destroy_all_sessions(), and delete_all_application_passwords() is called from exactly one place — the REST controller's manual DELETE.

So the single action a site owner takes on suspicion of compromise leaves the attacker's session cookie live, and their application password live. The application password survives two-factor too, because it is not a session. Credentials binds after_password_reset and revokes both. It fires gds_security_hardening_credentials_revoked so the revocation is not invisible to whoever runs the integration that just lost its credential.

Deliberately not bound to wp_set_password: a reset is someone locking an intruder out, a routine profile save is not.

login_errors is not enough to stop user enumeration

Core applies that filter in exactly one place, wp-login.php. Every other login form in WordPress renders core's own message, and core's message names the account: "The username bob is not registered on this site" (wp-includes/user.php:185). WooCommerce's my-account form calls wp_signon() and throws get_error_message() verbatim with no branch on the code (includes/class-wc-form-handler.php:1076-1079).

So UserEnumeration normalises at authenticate (priority 100, after every core authenticator and the spam check) and keeps login_errors as a second pass. It replaces the message and leaves the code alone on purpose — the code is never rendered, while plugins legitimately branch on it, and a brute-force limiter counting incorrect_password separately from invalid_username should keep working.

A timing oracle survives this: core returns before wp_check_password() when the account does not exist, so an unknown username answers faster. Closing that means burning a hash round on every invalid-username attempt — self-inflicted CPU amplification an attacker can trigger at will. Not worth it.

_embed does not pass through REST authentication

Whatever a site decides about /wp/v2/users, ?_embed=1 ignores it. WP_REST_Server::response_to_data() resolves every link marked embeddable by calling dispatch() itself, so an embed sub-request never goes through serve_request() and never fires rest_authentication_errors. A site whose mu-plugins close /wp/v2/users to anonymous callers still answers /wp/v2/posts?_embed=1 with the user record behind each published post — display name, nicename, author archive URL, and whatever fields plugins register on the users controller.

UserEnumeration drops the author link for anonymous callers, on every post type that opts into REST and supports authors. Dropping the link rather than filtering the user payload, because the link is what makes the sub-request happen at all.

The direct route is closed as well: /wp/v2/users* is removed from the route table for anonymous callers, so it answers rest_no_route like a site that never had it. Logged-in users keep both the route and the link, so the block editor's author panel and user search are unaffected. A theme or headless frontend that reads /wp/v2/users anonymously stops working — widen it from the site, at a later priority on rest_endpoints.

Author archives are closed outright

/author/<nicename>/ answers for a name that exists and 404s for one that does not, and the sitemaps list every name without guessing. None of our sites use author archives, so AuthorArchives turns every author request into a 404 at request — the pretty URL, ?author=N and ?author_name=, POST bodies included — before redirect_canonical() or Yoast can answer an existing name differently.

The admin is left alone: core runs wp() inside wp-admin to build its list tables, where author=<id> is the "Mine" filter, not an archive.

A site that does use author archives drops the module; UserEnumeration still closes ?author=<id> for it:

Three things worth knowing before you change anything

JSONP and nosniff are one control, not two. Core validates the ?_jsonp= callback against [\w.]+ — dots included — so ?_jsonp=window.opener.approve.click executes as a method call in your origin. That is a Same Origin Method Execution primitive on every reachable route, and it is the step CVE-2026-64638 used. With JSONP off a REST response is application/json, and nosniff is what makes <script src="/wp-json/..."> fail rather than be sniffed into script.

Only a read promoted to a write is refused. @wordpress/api-fetch ships httpV1Middleware in its default middleware chain, rewriting every PATCH, PUT and DELETE into a POST with X-HTTP-Method-Override. Refusing overrides outright breaks every save of an existing post. See tests/Integration/RestTest.php.

The application-password gate cannot call user_can(). It runs inside wp_validate_application_password(), hooked on determine_current_user, so the current user is still being resolved; a capability check re-enters that through any user_has_cap callback and recurses until PHP runs out of memory. It reads $user->allcaps, which WP_User::get_role_caps() builds with no filters.

Turning a module on or off

TwoFactor is off by default because it needs the two-factor plugin and locks every account out of everything but their profile until they enrol — a decision a site makes, not a package. Without that plugin active it is inert rather than locking people out of a site with no way to enrol.

It applies to every logged-in user. Narrow it with gds_security_hardening_two_factor_required on a site with WooCommerce customers or integration users — see TwoFactor::FILTER_REQUIRED.

The CSP is asymmetric on purpose

wp-admin gets only directives that need no per-site verification, and says nothing about scripts. It cannot take a nonce policy — core alone prints around a dozen un-nonced inline scripts per screen (core #59446) and the media library needs eval (core #62894) — and the nonce-free alternative, script-src-elem 'self' 'unsafe-inline', blocks the external <script src> that plugins legitimately use on their own screens. Enforcing that safely needs a per-site plugin sweep, which is what this package does not do.

object-src is 'self' there rather than 'none', because core's own core/file block renders a PDF preview as <object type="application/pdf">, in the editor canvas as well as on the frontend. Under 'none' the editor shows a silent gap the height of the block where the document used to be, on any site that attaches documents to posts. 'self' still refuses an injected <object> pointing at an attacker's host. wp-login.php embeds no documents, so it keeps 'none'.

wp-login.php gets a full Strict CSP: script-src 'nonce-…' 'strict-dynamic', no unsafe-inline. Nothing without that request's nonce executes — injected script tags, inline handlers, javascript: URIs and eval all fail — which is what stops an injected script reading the password field on submit. The credential-entry page is worth the stricter policy.

⚠️ The known cost: a plugin printing a raw <script> on the login screen stops working. limit-login-attempts-reloaded does exactly that when credentials are submitted, so it needs a patch or needs to go through wp_print_inline_script_tag(). tests/e2e/login-csp.spec.js drives a real browser through a successful and a failed login and fails on any CSP violation, so a site can find out before its users do.

A site that cannot take it removes the module with the filter; a site wanting more appends through gds_security_hardening_csp_directives.

Widening a control for one site

Never fork this package. Widen from the site's own mu-plugins at a later priority — for an integration user whose role has no manage_options:

Core normalises $user to a WP_User and bails on a missing one before any filter runs, so the object is safe to rely on.

Testing

The suite is integration-shaped on purpose. Every defect this package was written to avoid was invisible to a unit test: the recursion above needed real user_has_cap callbacks, the override rejection being discarded needed another plugin on the same filter, and an earlier version of the upload gate broke public Gravity Forms uploads through a path no mock would model. Polylang is installed in the test environment because it registers four rest_pre_dispatch callbacks.

The test environment installs the plugins the controls actually have to work with — woocommerce, two-factor, limit-login-attempts-reloaded, wordfence and polylang — and tests/bootstrap.php loads WooCommerce and two-factor into the phpunit run. Several controls exist because of what those plugins do, so testing them against doubles would assert our reading of the plugin rather than the plugin.

That is why the suite needs -d memory_limit=1024M: WooCommerce does not fit in the default 128M alongside the test harness.

Concretely, these run against the real thing rather than a mock:

What the login policy blocks, measured

Core is clean: every route it uses to emit script on wp-login.php carries the nonce — wp_script_attributes for tags, and wp_print_inline_script_tag() for localized data (class-wp-scripts.php:247), inline before/after scripts (:612) and translations (:366, :773).

Two environment notes, both of which shape the tests rather than the code. WordPress only loads mu-plugins sitting directly in WPMU_PLUGIN_DIR, so a package installed into a subdirectory needs something to require it — Bedrock's autoloader does that in production, and tests/loader.php stands in for it here. And wp-env's Apache ships AllowOverride None, so .htaccess is ignored and /wp-json/ never routes; the specs use the ?rest_route= form, and the editor spec asserts that a save is not refused by us rather than that it returns 200.

Deliberately out of scope

This package covers what a plugin can enforce. The rest of the WordPress hardening guidance lives elsewhere, and is listed here so the gap is explicit rather than forgotten:


All versions of gds-security-hardening with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package generoi/gds-security-hardening contains the following files

Loading the files please wait ...