WordPress 7.2 Secrets API: Encrypted API Keys Explained

WordPress 7.2 adds a Secrets API to encrypt plugin API keys, but upgraded sites need a WP_SECRETS_KEY first. Release is set for December 8.

By Vivek • • 5 Min Read • 0 • Follow on Google News Add to Preferred Source
WordPress 7.1.4 security update

WordPress 7.2, due on December 8, 2026, adds a Secrets API that lets plugins store API keys, tokens and passwords encrypted in the database instead of as plain text in the options table, according to the November developer roundup published on the WordPress Developer Blog on November 13. The feature stays switched off on existing sites until the owner adds a new encryption key to wp-config.php, and a longtime core contributor has asked for it to be backed out of the release, a concern WordPress co-founder Matt Mullenweg said he shares.

Plugins get four functions: wp_set_secret(), wp_get_secret(), wp_delete_secret() and wp_retire_secret_version(). A stored credential comes back as a WP_Secret object whose value stays masked in logs and debug output until the code calls reveal(), and WordPress keeps one previous version of each secret so a key can be rotated without downtime. Secrets are named in the form plugin-slug/secret-name.

Under the hood, values are encrypted with libsodium’s XChaCha20-Poly1305 cipher and still live in the options tables, per the developer note written by core contributor Eric Mann on November 11. A random root key protects each secret’s own key, and that root key is itself encrypted with a new WP_SECRETS_KEY constant in wp-config.php.

The protection has a clear boundary. A database dump, a leaked backup or a read-only SQL injection now yields ciphertext, but the note states that any code running on the site can read any secret, and the key sits on the same server as the data it protects. A malicious or compromised plugin is not stopped.

Upgraded sites start without a key

The roundup says new installs get WP_SECRETS_KEY automatically, and that Site Health tells existing sites how to add it. The Make WordPress Hosting team’s call to test, posted on November 12, is more specific: only the browser-based installer writes the key. WP-CLI’s wp config create, one-click installers, and host provisioning scripts do not yet, and a site upgraded from 7.1.4 gets no key at all.

That matters because Beta 5 removed the earlier fallback to the login salts. Without a valid key, every read and write returns a secret_key_unavailable error. One tester, Ssebuwufu Moses, reported on November 14 that a Softaculous install on shared cPanel hosting had no key after upgrading to 7.2 Beta 5, and that Site Health rated the gap as “Recommended” instead of “Critical”. Once he added a key, the stored value could not be found in plain text anywhere in the database across six runs.

Site owners who want the feature working on day one need to generate a random 32-byte, base64-encoded value (openssl rand -base64 32 does it) and define it as WP_SECRETS_KEY in wp-config.php. The key must travel with the site through migrations, staging clones and restores. Changing or deleting it makes every stored secret unreadable until the original value is put back.

Plugin developers are told to check wp_is_secrets_api_available() before moving anything, and to use wp_import_option_as_secret() to copy an existing option across. Imported credentials are flagged for rotation, because the old plain-text value has already been written into backups.

A request to pull it from 7.2

The API’s place in the release is contested. In comments on the developer note, core contributor Ryan McCue called for it to be backed out of 7.2, arguing that “secrets are things that are provided to the application, not managed by it” and that encrypted-at-rest databases already offer similar protection. Mullenweg agreed with those concerns and said it was a poor time to make sensitive data a target.

Mann replied that the feature should stay, that the storage layer had been reworked so hosts can supply read-only, platform-managed secrets through a secrets.php drop-in, and that most WordPress sites have no separate channel for delivering credentials. The hosting team has asked testers to try the API on Beta 5 before Release Candidate 1 on November 17, after which changes need committer sign-off.

The debate follows a run of core security releases. WordPress 7.1.4 fixed 22 vulnerabilities on October 28, weeks after 7.1.3 patched a SQL injection and 7.1.2 closed a critical file inclusion flaw. Encryption at rest would blunt the SQL injection class, but the year’s worst core bug, the WP2Shell pre-authentication chain, ended in code execution, which is exactly where the Secrets API’s protection stops.

Other 7.2 changes that can break existing code are smaller. Admin bar and sidebar icons become inline SVGs in place of Dashicons, so CSS that styles or hides icons through ::before may stop working. Admin scripts and styles now load individually, with load-scripts.php and load-styles.php deprecated. A new /random URL redirects visitors to a random published post.

There is no admin screen for managing secrets in 7.2; the roundup says one is planned for a later release. WordPress has not said whether the API will change before RC1, which ships alongside the 7.2 Field Guide.

Community Discussion

Join the conversation. Ask questions, share solutions, and help others.

0 Comments

Be the first to start the discussion!

Leave a Comment

Your email address will not be published. Required fields are marked *

We respect your privacy, your information is safe with us.

Latest Articles

View all