Add a check that recommends the WordPress 7.2 Secrets API for all stored credentials

オープン
#1,532 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@faisalahammad がすでに取り組んでいます。

2026年11月11日 から。

  • #1534 @faisalahammad による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php, wordpress
領域
backend, security

調査の方向性

Start by reading the Plugin Check rules that inspect calls such as update_option() and register_setting(), then check how existing security warnings are registered and tested. The issue specifies credential patterns, APIs to detect, and false-positive cases, but the detection scope spans option names, stored values, custom transformations, fallback handling, and cross-call suppression. Done means the warning identifies credential storage outside the Secrets API while honoring the listed exceptions.

索引モデルが issue の本文から書いたものです。

説明

Summary

WordPress 7.2 adds a core Secrets API (Trac #66187, committed in r64337) that gives plugins a standard way to store credentials encrypted at rest. Today plugins store API keys, tokens and passwords with update_option(), either in plain text or encrypted, encoded or hashed with their own implementation. Plain text is readable in database dumps, backups and SQL-read vulnerabilities. Custom encryption varies widely in quality, often keeps the key next to the data, and can't benefit from key rotation or external storage providers.

I'd like to propose a Plugin Check rule that reports any credential storage not done through the Secrets API, whether plain text or custom encryption, and asks plugin authors to switch, so that plugins converge on one audited approach.

cc @ericmann as the author of the Secrets API, for input on the recommended usage and messaging.

Proposal: https://make.wordpress.org/core/2026/08/25/proposal-a-secrets-api-for-wordpress-7-2/

Proposed check

  • Name: credential_storage (open to suggestions)
  • Category: security (possibly also plugin_repo)
  • Type: WARNING

It should be a warning rather than an error because plugins still need a fallback for sites running WordPress < 7.2 and sites without WP_SECRETS_KEY defined.

What to detect

Flag calls to update_option(), add_option(), update_site_option(), add_site_option() and register_setting() where the option name (or a known array key in the stored value) matches a credential pattern, for example:

  • *api_key*, *apikey*, *api_secret*
  • *secret*, *client_secret*
  • *token*, *access_token*, *refresh_token*
  • *password*, *passwd*, *pwd*
  • *private_key*, *license_key* (maybe)

This applies regardless of whether the value is stored as-is or first passed through custom encryption, encoding or hashing (e.g. openssl_encrypt(), sodium_crypto_*(), base64_encode(), wp_hash_password()).

Suggested message

The option "%s" appears to store a credential outside the Secrets API. Since WordPress 7.2, use wp_set_secret() / wp_get_secret() so the value is encrypted at rest with core's key management and rotation, instead of plain text or custom encryption. Feature-detect with function_exists( 'wp_set_secret' ) and keep your current storage only as a fallback for older WordPress versions.

Reducing false positives

  • Skip the warning if the plugin stores the same credential through wp_set_secret() or wp_import_option_as_secret() and only uses the option as a fallback.
  • Ignore obvious non-secret names such as *_token_expires, *_api_key_set or *_key_valid.
  • If a plugin's Requires at least is 7.2 or higher, the message could drop the fallback advice.
主要言語
PHP
スター
365
フォーク
135
平均マージ
1日 8時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WordPress/plugin-check のほかの issue

WordPress/plugin-check の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。