Logo di Http Api Ssrf Prevention

Http Api Ssrf Prevention

Organizzazione
wpultimatesecurity
http-api-ssrf-prevention

Usa questa skill quando un plugin o un tema effettua richieste HTTP in uscita con l'API HTTP di WordPress: wp_remote_get, wp_remote_post, wp_remote_request, soprattutto se una parte dell'URL proviene dall'input dell'utente, dalle opzioni o dai webhook. Usa wp_safe_remote_* con wp_http_validate_url, definisce una lista consentita di host, blocca gli indirizzi interni e quelli dei metadati e controlla is_wp_error e il codice di risposta. Previene le richieste lato server contraffatte (SSRF).

Add to TypingMind

Panoramica

Pubblicato dawpultimatesecurity
RepositoryWordPress-Security-Skills
Nome della skillhttp-api-ssrf-prevention
Stelle
54
Fork
3
File inclusi
2
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 2

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da wpultimatesecurity su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Http Api Ssrf Prevention in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/http-api-ssrf-prevention
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

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
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Http Api Ssrf Prevention in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Http Api Ssrf Prevention non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Http Api Ssrf Prevention non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Http Api Ssrf Prevention?

Usa questa skill quando un plugin o un tema effettua richieste HTTP in uscita con l'API HTTP di WordPress: wp_remote_get, wp_remote_post, wp_remote_request, soprattutto se una parte dell'URL proviene dall'input dell'utente, dalle opzioni o dai webhook. Usa wp_safe_remote_* con wp_http_validate_url, definisce una lista consentita di host, blocca gli indirizzi interni e quelli dei metadati e controlla is_wp_error e il codice di risposta. Previene le richieste lato server contraffatte (SSRF).

Perché usare Http Api Ssrf Prevention su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Http Api Ssrf Prevention è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Http Api Ssrf Prevention in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/wpultimatesecurity/WordPress-Security-Skills/tree/dev/skills/http-api-ssrf-prevention. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Http Api Ssrf Prevention?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Http Api Ssrf Prevention?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Http Api Ssrf Prevention: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Http Api Ssrf Prevention è gratuita?

Sì. È pubblicata su GitHub da wpultimatesecurity con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇