# Ai Llm Integration Security > Úsalo al construir o revisar funciones de plugin o tema de WordPress que llaman a un LLM: chatbots, generación de contenido, RAG, agentes con herramientas, Abilities API o exposición MCP. Fuente: https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/ai-llm-integration-security Markdown: https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/ai-llm-integration-security.md Repositorio: https://github.com/wpultimatesecurity/WordPress-Security-Skills Autor: wpultimatesecurity Licencia: MIT Actualizado: hace 2 meses Coste de contexto: 125 tok instalada, 3.6k tok al activarse, 4.3k tok con todos los archivos del bundle Bundle: 2 archivos, 17 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent claude-code # Cursor npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent cursor # Codex npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent codex # Gemini CLI npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent gemini # Windsurf npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent windsurf # Cline npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill ai-llm-integration-security --agent cline ``` ## Qué hace - Trata la salida del modelo y todo el contexto como entrada no confiable que debe escaparse y validarse - Vincula cada acción de herramienta a las capacidades del usuario humano con current_user_can() - Exige confirmación verificada por el servidor para acciones destructivas o de salida - Limita la recuperación de contenido a lo que el usuario puede leer según read_post - Mantiene las claves del proveedor en el servidor y limita el gasto de usuarios anónimos o de bajo rol ## Cuándo usarla - Construyes o revisas un chatbot, generador de contenido o botón de resumir/traducir en wp-admin o el frontend - Implementas búsqueda IA o RAG sobre posts, productos, pedidos o tickets - Creas un agente que llama herramientas: funciones de plugin, rutas REST, Abilities API o un servidor MCP - Almacenas claves de API de proveedores de IA o expones funciones de IA a usuarios anónimos o de bajo rol ## Cuándo no - Peticiones HTTP salientes ordinarias sin modelo (usa http-api-ssrf-prevention) - Almacenamiento genérico de secretos (usa secrets-credentials-management) - Rutas REST sin ningún modelo en el flujo (usa rest-api-security) ## Qué la activa - "Revisa la seguridad de mi chatbot de WordPress que usa un LLM" - "Quiero añadir una ability que resuma comentarios con IA, ¿cómo la protejo?" - "Voy a exponer acciones del sitio a un cliente MCP externo, ¿qué controles necesito" - "Cómo evito que un usuario con pocos privilegios borre posts a través del asistente de IA" ## Antes de instalar - La Abilities API requiere WordPress 6.9 o posterior; los ejemplos usan sintaxis PHP 7.4 y los SDK de proveedores o el adaptador MCP pueden cambiar. ## Archivos - SKILL.md — 14 KB - references/threat-model.md — 3 KB ## SKILL.md Reproducido tal cual desde wpultimatesecurity/WordPress-Security-Skills bajo MIT. Esta sección es el documento original y está en inglés. # AI and LLM integration security ## When to use this skill Use this skill when WordPress code sends data to, or acts on output from, a language model: - A chatbot, assistant, or "generate/summarize/translate" button in wp-admin or on the front end. - AI search or retrieval-augmented generation (RAG) over posts, products, orders, or tickets. - An agent that calls tools: plugin functions, REST routes, Abilities API abilities, or an MCP server that exposes site actions to external AI clients. - Storing AI provider API keys, or exposing AI features to anonymous or low-role users. Do **not** use it for ordinary outbound HTTP (use `http-api-ssrf-prevention`), generic secrets storage (use `secrets-credentials-management`), or REST routes with no model in the loop (use `rest-api-security`). ## Core principles (and why they matter) 1. **Model output is untrusted input.** It can contain HTML, script, SQL fragments, URLs, shell text, or function names chosen by whoever influenced the prompt. Escape it for its output context and validate it before any use, exactly like `$_POST`. 2. **Everything in the context window can carry instructions.** Post content, comments, reviews, order notes, uploaded documents, fetched web pages, and earlier tool results are attacker-writable in most sites (prompt injection). A system prompt telling the model to ignore them is not a security control. 3. **Authorization belongs to the human, not the model.** Every tool or ability checks `current_user_can()` for the specific object when it executes, with the same capability the equivalent UI action requires. The model cannot grant capabilities, and a tool must never run as a more privileged user than the one chatting. 4. **Destructive or outward actions need server-enforced confirmation.** Deleting, publishing, emailing, refunding, changing roles, or installing code requires the user to approve the exact action and arguments; the server verifies that approval, not a flag the model sets. 5. **Only put into context what this user may read.** Retrieval, tool results, and system-prompt data must respect `read_post`/`read_private_posts` and object ownership; anything in the context can be echoed back by the model. 6. **Provider keys and spend stay server-side.** Keys never reach the browser. Anonymous and low-role access is rate-limited and quota-capped, because each request costs the site owner money. ## Step-by-step implementation 1. **Map the flow.** List each entry point (REST/AJAX route, admin page, cron, MCP), who can reach it, every source that enters the prompt, every tool the model can call, and every place the output lands (HTML, post content, email, options, database queries). 2. **Gate the entry point.** Nonce plus capability for admin features; for public chat, a nonce, a per-user/IP rate limit, message size limits, and a daily spend cap. 3. **Assemble context by permission.** Retrieve only posts and records the current user can read; strip secrets and other users' PII; mark untrusted content as data (delimiters help the model but are not a control). 4. **Register tools narrowly.** One purpose per tool, strict JSON input schemas, a `permission_callback` that checks the real capability for the specific object, and argument validation in the callback itself. Keep dangerous capabilities (code, files, users, plugins, settings) out of model-callable tools. 5. **Confirm before effects.** For destructive or outward tools, return a proposal with a server-stored, single-use confirmation token bound to the user, tool, and arguments; execute only when the user approves that token through a separate nonce-protected request. 6. **Treat output as input.** Escape with `esc_html()` or `wp_kses_post()` for display, sanitize before storage, and never pass it to `eval`, `call_user_func` with a model-chosen name, SQL, `include`, `wp_remote_get()` on model-chosen URLs, or redirects. 7. **Protect keys and log safely.** Store keys in a `wp-config.php` constant or an encrypted option, call the provider only from PHP, set request timeouts, and log metadata rather than full prompts containing PII. 8. **Test denied paths.** Exercise a subscriber asking for admin tools, an injected instruction inside a post being summarized, a model reply containing `