Http Api Ssrf Preventionのロゴ

Http Api Ssrf Prevention

組織
wpultimatesecurity
http-api-ssrf-prevention

プラグインやテーマがWordPress HTTP API(wp_remote_get、wp_remote_post、wp_remote_request)を使って外部にHTTPリクエストを送信するときに使用します。特に、URLの一部がユーザー入力、設定値、Webhookに由来する場合に有効です。wp_http_validate_urlで検証しながらwp_safe_remote_*を使用し、ホストの許可リストを設定して、内部アドレスやメタデータ用アドレスへのアクセスをブロックします。また、is_wp_errorとレスポンスコードを確認します。サーバーサイドリクエストフォージェリ(SSRF)を防ぎます。

Add to TypingMind

概要

公開者wpultimatesecurity
リポジトリWordPress-Security-Skills
スキル名http-api-ssrf-prevention
スター
54
フォーク
3
同梱ファイル
2
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    wpultimatesecurityがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Http Api Ssrf Prevention」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/http-api-ssrf-prevention
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをその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/http-api-ssrf-prevention .claude/skills/http-api-ssrf-prevention
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでHttp Api Ssrf Preventionを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にHttp Api Ssrf Preventionを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Http Api Ssrf Preventionは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

HTTP API & SSRF prevention

When to use this skill

Use this skill whenever code makes an outbound HTTP request:

  • Fetching a user-supplied URL (webhook, import, avatar, feed, oEmbed-like lookup).
  • Calling an external API from a setting, form, or scheduled job.
  • Using wp_remote_get(), wp_remote_post(), or wp_remote_request().
  • Building a URL from $_GET, $_POST, options, or remote configuration.

If any part of the URL is influenced by users or remote state, treat it as an SSRF sink. wp_safe_remote_*() runs wp_http_validate_url() on the URL and every redirect, blocking private/loopback ranges by default.

Related: see the rest-api-security skill for inbound REST endpoints and the input-sanitization-validation skill for general URL sanitization.

Core principles (and why they matter)

  1. wp_safe_remote_*() for untrusted URLs. wp_safe_remote_get() and wp_safe_remote_post() set reject_unsafe_urls, which validates the URL and redirects against private/loopback ranges.
  2. Allowlist hosts, don't blocklist. A blocklist will miss metadata.google.internal, localhost aliases, IP-encoding tricks, and redirect chains. Allow only the hosts and ports you intend to call.
  3. Validate before the request. Run wp_http_validate_url() or compare the parsed host against an allowlist before calling the HTTP API.
  4. Check is_wp_error() and the response code. A failed request can leak internal error messages or be confused with valid data.
  5. Escape fetched data before output. The response body is untrusted input; escape or sanitize it before rendering.
  6. Don't follow redirects blindly. wp_safe_remote_*() validates redirect targets, but if you manually chase redirects you may re-enter internal space.

Step-by-step implementation

  1. Determine whether the URL is trusted (hardcoded, signed) or untrusted (user input).
  2. For untrusted URLs:
    • Parse the host and compare it to an explicit allowlist.
    • Run wp_http_validate_url() as an additional guard.
    • Use wp_safe_remote_get() / wp_safe_remote_post().
  3. For trusted URLs, wp_remote_*() is acceptable but still validate the shape.
  4. Handle is_wp_error() and check the response code with wp_remote_retrieve_response_code().
  5. Sanitize or escape the response body before use/output.
  6. Log failures without exposing secrets or internal network details.

Supporting references

ReferenceLoad when
HTTP API & SSRF prevention checklistBefore final verification of the http api & ssrf prevention controls.
Secure outbound HTTP requestImplementing allowlisted webhook delivery with safe HTTP requests and response handling.

Common AI mistakes / anti-patterns

Mistake 1 — wp_remote_get() on user input with no validation

php
// ❌ Insecure: SSRF to internal services, metadata endpoints, or localhost.
$response = wp_remote_get( $_POST['url'] );
php
// ✅ Secure: allowlist host, validate URL, use safe remote, check errors.
$url = isset( $_POST['url'] ) ? esc_url_raw( wp_unslash( $_POST['url'] ) ) : '';
$allowed_hosts = array( 'api.example.com', 'hooks.example.com' );
$host          = wp_parse_url( $url, PHP_URL_HOST );

if ( ! $host || ! in_array( strtolower( $host ), $allowed_hosts, true ) ) {
    wp_die( esc_html__( 'Invalid URL.', 'my-plugin' ), 400 );
}

if ( ! wp_http_validate_url( $url ) ) {
    wp_die( esc_html__( 'URL is not safe.', 'my-plugin' ), 400 );
}

$response = wp_safe_remote_get( $url );
if ( is_wp_error( $response ) ) {
    wp_die( esc_html__( 'Request failed.', 'my-plugin' ), 502 );
}
$code = wp_remote_retrieve_response_code( $response );
if ( 200 !== $code ) {
    wp_die( esc_html__( 'Unexpected response.', 'my-plugin' ), 502 );
}
$body = wp_remote_retrieve_body( $response );

Mistake 2 — Trusting the URL scheme without checking

php
// ❌ Insecure: file://, ftp://, gopher://, or php:// wrappers may be reachable.
$response = wp_remote_get( $_POST['url'] );
php
// ✅ Secure: wp_http_validate_url() allows only http/https.
if ( ! wp_http_validate_url( $url ) ) {
    wp_die( esc_html__( 'Only HTTP/HTTPS URLs are allowed.', 'my-plugin' ), 400 );
}

Mistake 3 — Reflecting fetched body unescaped

php
// ❌ Insecure: fetched HTML/JSON may contain XSS payloads.
echo wp_remote_retrieve_body( $response );
php
// ✅ Secure: treat the body as untrusted and escape for the output context.
$body = wp_remote_retrieve_body( $response );
echo '<pre>' . esc_html( $body ) . '</pre>';

Mistake 4 — Allowing internal IPs through a host allowlist bypass

php
// ❌ Insecure: resolves to 127.0.0.1 or metadata service.
$allowed_hosts = array( 'localhost', '169.254.169.254' );
php
// ✅ Secure: do not allow localhost or link-local ranges; rely on wp_http_validate_url.
$allowed_hosts = array( 'api.example.com' );

Mistake 5 — Ignoring is_wp_error()

php
// ❌ Insecure: $response['body'] may not exist; errors may leak internals.
$body = $response['body'];
php
// ✅ Secure: branch on is_wp_error() before reading the response.
if ( is_wp_error( $response ) ) {
    error_log( 'HTTP request failed: ' . $response->get_error_message() );
    return false;
}
$body = wp_remote_retrieve_body( $response );

Correct code examples

A complete, copy-paste-ready webhook fetch handler with host allowlist + safe remote + response validation is in references/secure-http-request.php.

Checklist

  • Untrusted URLs use wp_safe_remote_get() / wp_safe_remote_post().
  • The host is allowlisted before the request is made.
  • wp_http_validate_url() is used as an additional guard.
  • Only http/https schemes are accepted.
  • is_wp_error() is checked before reading the response.
  • The response code is validated.
  • Fetched data is sanitized/escaped before output or storage.
  • Failures are logged without exposing secrets or internal network details.
  • Redirect chains are validated (safe remote does this automatically).

Official references

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Http Api Ssrf Prevention」では何ができますか?

プラグインやテーマがWordPress HTTP API(wp_remote_get、wp_remote_post、wp_remote_request)を使って外部にHTTPリクエストを送信するときに使用します。特に、URLの一部がユーザー入力、設定値、Webhookに由来する場合に有効です。wp_http_validate_urlで検証しながらwp_safe_remote_*を使用し、ホストの許可リストを設定して、内部アドレスやメタデータ用アドレスへのアクセスをブロックします。また、is_wp_errorとレスポンスコードを確認します。サーバーサイドリクエストフォージェリ(SSRF)を防ぎます。

TypingMindでHttp Api Ssrf Preventionを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Http Api Ssrf Preventionはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにHttp Api Ssrf Preventionをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/http-api-ssrf-preventionを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Http Api Ssrf Preventionを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Http Api Ssrf Preventionで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもHttp Api Ssrf Preventionを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Http Api Ssrf Prevention」は無料ですか?

はい。wpultimatesecurityがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇