Logo Secrets Credentials Management

Secrets Credentials Management

Tổ chức
wpultimatesecurity
secrets-credentials-management

Dùng khi xử lý mật khẩu, khóa API, token hoặc thông tin xác thực của bên thứ ba trong plugin hay theme WordPress. Băm mật khẩu bằng wp_hash_password / wp_check_password, tạo token bằng wp_generate_password, không để lộ bí mật trong mã hoặc lưu dưới dạng văn bản thuần trong cơ sở dữ liệu, và dùng Application Passwords để xác thực API. Ngăn rò rỉ thông tin xác thực và lưu trữ không an toàn.

Add to TypingMind

Tổng quan

Nhà phát hànhwpultimatesecurity
Kho mãWordPress-Security-Skills
Tên kỹ năngsecrets-credentials-management
Sao
54
Bản fork
3
Tệp đi kèm
2
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 2 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được wpultimatesecurity công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Secrets Credentials Management trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/secrets-credentials-management
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wpultimatesecurity/WordPress-Security-Skills.git /tmp/WordPress-Security-Skills
mkdir -p .claude/skills
cp -r /tmp/WordPress-Security-Skills/skills/secrets-credentials-management .claude/skills/secrets-credentials-management
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Secrets Credentials Management trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Secrets Credentials Management ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Secrets Credentials Management với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Secrets & credentials management

When to use this skill

Use this skill whenever code handles sensitive credentials:

  • Storing an API key, webhook secret, or service token from a settings form.
  • Building a custom login or token-verification flow.
  • Generating reset tokens, API keys, or one-time nonces that must stay secret.
  • Logging or exporting data that might accidentally include secrets.
  • Deciding whether to use the user's account password or an application-specific password for API/integration access.

Secrets in source code, reversible password storage, and plaintext API keys in options are common sources of credential leaks.

Related: see the nonces-csrf-protection skill for CSRF tokens and the settings-options-security skill for sanitizing option values.

Core principles (and why they matter)

  1. Never hardcode secrets. API keys and passwords committed to source control leak to anyone with repo access and often end up in public repositories.
  2. Never store user passwords reversibly. WordPress stores passwords as salted hashes via wp_hash_password(); use wp_check_password() to verify. Do not roll your own hash.
  3. Prefer wp-config constants or encrypted option storage for service keys. Put keys in wp-config.php constants or encrypt them at rest with libsodium so the database alone is not enough to recover them.
  4. Use Application Passwords for API auth. WordPress 5.6+ provides WP_Application_Passwords for machine-to-machine auth without exposing the user's account password.
  5. Never echo or log secrets. Tokens and keys should never appear in HTML, logs, error messages, shell history, or exported backups.
  6. Generate tokens with wp_generate_password() or wp_create_nonce(). They are designed for cryptographic strength (nonces are short-lived; passwords/tokens can be longer).

Step-by-step implementation

  1. For user passwords: hash with wp_hash_password() on save, verify with wp_check_password().
  2. For service/API keys:
    • Accept via a secure settings form (nonce + capability + sanitize).
    • Store in a wp-config.php constant if possible, or encrypt with sodium_crypto_secretbox() using a key derived from wp_salt() (or a dedicated constant) before update_option().
  3. For machine auth: use WP_Application_Passwords::create_new_application_password().
  4. For tokens: generate with wp_generate_password( $length, false ); store only a hash if you need to verify it later.
  5. Sanitize any log/export output to redact known secret keys.
  6. If a secret leaks, respond in this order:
    1. Rotate first. Assume compromise the moment the secret left your control — once pushed to a remote, treat it as captured (clones, forks, and scrapers may already hold it). Issue a new key at the provider, then update the wp-config constant or re-save the encrypted option, and revoke the old key; issuing a replacement alone may leave the leaked key usable. For active abuse, revoke immediately.
    2. Revoke what rotation cannot cover. Delete leaked Application Passwords (Users → Profile → Application Passwords) and destroy sessions for affected users with WP_Session_Tokens::get_instance( $affected_user_id )->destroy_all() for each trusted, verified affected user ID. wp_destroy_all_sessions() targets only the current user, not an arbitrary affected user. Session revocation does not revoke Application Passwords. If wp-config.php leaked, rotate all eight keys/salts and exposed database/service credentials. If an encryption key changes, re-encrypt retained secrets before discarding it; salt-derived keys also change when salts rotate. See wp-hardening-best-practices.
    3. Consider history cleanup after revocation, never instead. If needed, plan a git filter-repo rewrite with repository owners and collaborators. Do not automatically rewrite history or force-push: publishing rewritten history is destructive and requires explicit approval and coordinated protection of others' work. Old clones still contain the secret and can reintroduce it; arrange re-cloning or careful cleanup. Forks and cached views need separate coordination; consult GitHub Support's removal criteria where applicable.
    4. Add push protection to block supported secrets when pushing to GitHub, not when making local commits. Use local secret scanning/pre-commit checks for earlier feedback; neither catches every secret or replaces safe handling.

Supporting references

ReferenceLoad when
Secrets & credentials management checklistBefore final verification of the secrets & credentials management controls.
Secure secret storageImplementing service API-key storage through wp-config.php constants or encrypted options.

Common AI mistakes / anti-patterns

Mistake 1 — API key as a string literal

php
// ❌ Insecure: key is in source control and readable by anyone with file access.
$api_key = 'sk-live-abc123';
php
// ✅ Secure: read from a wp-config constant or an encrypted option.
if ( ! defined( 'MY_PLUGIN_API_KEY' ) ) {
    wp_die( esc_html__( 'API key is not configured.', 'my-plugin' ) );
}
$api_key = MY_PLUGIN_API_KEY;

Mistake 2 — Storing user passwords in plaintext or with a weak hash

php
// ❌ Insecure: reversible or weak storage.
update_option( 'my_plugin_user_password', $_POST['password'] );
update_option( 'my_plugin_user_password', md5( $_POST['password'] ) );
php
// ✅ Secure: use WordPress password hashing.
$hash = wp_hash_password( $_POST['password'] );
update_option( 'my_plugin_user_password_hash', $hash );

// Verify later:
if ( wp_check_password( $submitted, $stored_hash ) ) { /* ... */ }

Mistake 3 — Logging tokens or API keys

php
// ❌ Insecure: secret lands in error_log / shell history.
error_log( 'Request failed with token: ' . $api_key );
php
// ✅ Secure: log an identifier or redacted value.
error_log( 'Request failed for token ending in: ' . substr( $api_key, -4 ) );

Mistake 4 — Reusing nonces as long-lived secrets

php
// ❌ Insecure: nonces expire and are not designed for persistent auth.
$token = wp_create_nonce( 'my_api' );
update_user_meta( $user_id, 'my_api_token', $token );
php
// ✅ Secure: generate a dedicated token and hash it for storage.
$token      = wp_generate_password( 32, false );
$token_hash = wp_hash_password( $token );
update_user_meta( $user_id, 'my_api_token_hash', $token_hash );
// Hand the plaintext token to the user once, then verify with wp_check_password().

Mistake 5 — Storing service keys in plaintext options

php
// ❌ Insecure: database dump exposes the key.
update_option( 'my_plugin_stripe_key', $_POST['stripe_key'] );
php
// ✅ Secure: encrypt at rest with libsodium (PHP 7.2+).
function my_plugin_encrypt_secret( $plaintext ) {
    $key    = sodium_base642bin( MY_PLUGIN_ENCRYPTION_KEY, SODIUM_BASE64_VARIANT_ORIGINAL );
    $nonce  = random_bytes( SODIUM_CRYPTO_SECRETBOX_NONCEBYTES );
    $cipher = sodium_crypto_secretbox( $plaintext, $nonce, $key );
    return base64_encode( $nonce . $cipher );
}

function my_plugin_decrypt_secret( $encoded ) {
    $raw   = base64_decode( $encoded );
    $nonce = substr( $raw, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES );
    $cipher = substr( $raw, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES );
    $key    = sodium_base642bin( MY_PLUGIN_ENCRYPTION_KEY, SODIUM_BASE64_VARIANT_ORIGINAL );
    return sodium_crypto_secretbox_open( $cipher, $nonce, $key );
}

Correct code examples

A complete settings-page snippet that stores an API key either as a wp-config constant or encrypted in options is in references/secure-secret-storage.php.

Checklist

  • No secrets, API keys, or passwords are hard-coded in source files.
  • User passwords are hashed with wp_hash_password() and verified with wp_check_password().
  • Service/API keys are stored in wp-config.php constants or encrypted at rest.
  • Machine-to-machine auth uses Application Passwords where possible.
  • Tokens are generated with wp_generate_password() (or wp_create_nonce() for short-lived CSRF).
  • Stored tokens are verified against a hash, not compared in plaintext.
  • Secrets are never echoed, logged, exported, or sent to the browser.
  • Leaked credentials are revoked/rotated; affected users' sessions are revoked when warranted.
  • Any history rewrite/publication has explicit approval and coordinated clone/fork cleanup.
  • Settings forms that collect secrets use nonce + capability + HTTPS.

Official references

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Secrets Credentials Management làm được gì?

Dùng khi xử lý mật khẩu, khóa API, token hoặc thông tin xác thực của bên thứ ba trong plugin hay theme WordPress. Băm mật khẩu bằng wp_hash_password / wp_check_password, tạo token bằng wp_generate_password, không để lộ bí mật trong mã hoặc lưu dưới dạng văn bản thuần trong cơ sở dữ liệu, và dùng Application Passwords để xác thực API. Ngăn rò rỉ thông tin xác thực và lưu trữ không an toàn.

Vì sao nên dùng Secrets Credentials Management trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Secrets Credentials Management là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Secrets Credentials Management trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/secrets-credentials-management. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Secrets Credentials Management?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Secrets Credentials Management với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Secrets Credentials Management với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Secrets Credentials Management có miễn phí không?

Có. Kỹ năng này được wpultimatesecurity phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇