/kivo-wise:wp-security-escapingfrom kivo-wise
Guides WordPress + Acorn developers through output escaping, input sanitization, capability checks, and SQL safety. Covers Blade vs WordPress escape chains, nonces, permission callbacks, and file uploads.
Ships in kivo-wise. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Three rules cover most findings in Acorn projects: escape output exactly once (Blade or WordPress, never both), sanitise and validate input at the entry point, and pair every state change with a capability check (a nonce proves intent, a capability proves authority).
Runner placeholders come from the session context: {{runner.wp}} (Lando default lando wp), {{runner.test}} (the project's test command), {{runner.cache}}. Never run wp, composer or php on the host.
permission_callback.$wpdb or the query builder, file uploads, secrets.Blade {{ $x }} compiles to e($x): htmlspecialchars(…, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', double_encode = true). WordPress escapers already return HTML-safe text. Wrapping one in the other escapes twice: {{ esc_url($url) }} turns ?a=1&b=2 into a visible & and breaks the link.
| Value | Write | Never |
|---|---|---|
| Plain text from PHP | {{ $title }} | {{ esc_html($title) }} |
Text that may already hold entities (get_the_title(), ACF formatted text) | {!! esc_html($title) !!} (WordPress does not double-encode) | {{ get_the_title() }} when you see & |
URL in href / src | {!! esc_url($url) !!} | {{ esc_url($url) }} |
| Attribute from WordPress | {!! esc_attr($label) !!} or {{ $label }} | {{ esc_attr($label) }} |
| Trusted rich HTML (post content, WYSIWYG) | {!! wp_kses_post($html) !!} | {!! $html !!} unfiltered |
| Data for JavaScript | @json($data) (hex-escapes <, >, ', ", &), or wp_add_inline_script() with wp_json_encode() | string-built JS |
| Component attributes | $attributes->merge(['href' => $url]) escapes the defaults with e(); pass false as the second argument when the value comes from esc_url() / esc_attr() | merging an esc_url() value with escaping on |
Bound attributes on a component tag (<x-link :href="$url">) that land in the attribute bag are already escaped with e() at compile time; do not pass esc_url() output there either. Details and a guard test: references/blade-escaping.md.
$_POST; wp_unslash() before sanitising superglobals.sanitize_text_field, sanitize_textarea_field, sanitize_email, absint, sanitize_key, esc_url_raw, wp_kses_post). In Acorn controllers, $request->validate([...]) checks shape; still sanitise what you store.acf_save_post() already filters posted values with wp_kses_post_deep() for users without unfiltered_html; add acf/update_value/key=… for type-specific sanitising and acf/validate_value for rules (acf-native). Without ACF, register_post_meta() with sanitize_callback and auth_callback.wp_nonce_field('action', '_name') + check_admin_referer('action', '_name') or wp_verify_nonce(); AJAX: check_ajax_referer(); REST with cookie auth: the X-WP-Nonce header (wp_rest nonce) is checked by core.current_user_can() with the most specific capability (meta capabilities like edit_post take the object ID).permission_callback (WordPress logs _doing_it_wrong when it is missing); __return_true only for public reads.wp_ajax_nopriv_* and public Acorn routes are attacker-controlled traffic: validate everything, expose nothing private.$wpdb->prepare() with %s, %d, %f, and %i for identifiers; $wpdb->esc_like() for LIKE. Eloquent and the query builder bind parameters; DB::raw(), whereRaw() and selectRaw() must take bindings (whereRaw('title = ?', [$input])).
sage-theme | acorn-mu-plugin | radicle-app | |
|---|---|---|---|
| Views to audit | theme resources/views/** | plugin resources/views/** (namespaced views) | project resources/views/**, including native block render views |
| Extra input surface | ACF fields, theme forms | ACF fields, Livewire components, plugin REST/Acorn routes | block attributes saved from the editor (escape them at render), REST/Acorn routes; no ACF by default |
| Meta sanitising | ACF hooks | ACF hooks | register_post_meta() sanitize_callback / auth_callback |
| Guard test location | theme tests | plugin tests/ | project tests/ (Pest) |
rg -n "\{\{\s*esc_(url|attr|html|textarea|js)(__|_x)?\(" <app>/resources/views returns nothing; better, keep the guard test from the reference running in {{runner.test}}.rg -n "\{!!" <app>/resources/views and justify each hit (an esc_*, wp_kses*, @json, or a trusted Htmlable).current_user_can().rg -n "\$wpdb->(query|get_(results|row|var|col))\(" <app>/app hits all go through prepare().{{runner.wp}} user create test-sub [email protected] --role=subscriber); expect 401/403.| Symptom | Cause | Fix |
|---|---|---|
& or &amp; visible in links or titles | Escaped twice ({{ esc_url() }}, or {{ }} on text that already has entities) | {!! esc_url($url) !!} / {!! esc_html($text) !!}; add the guard test |
| XSS through a WYSIWYG or block attribute | {!! $html !!} without filtering | {!! wp_kses_post($html) !!} or wp_kses() with an allow-list |
CSRF on an Acorn web route | Acorn's default web middleware group ships with the CSRF middleware commented out; @csrf alone verifies nothing | Use WordPress nonces in the controller, or append the CSRF middleware with withMiddleware() (see acorn-routes-api) |
| Subscriber can call an admin action | Nonce checked, capability not | Add current_user_can() before acting |
| REST route open to everyone | permission_callback missing or __return_true on a write | Capability-based callback |
current_user_can('edit_project', $id) always false | CPT with custom capability_type and map_meta_cap false | Set map_meta_cap => true and grant the primitive caps |
| SQL injection | Interpolated input in $wpdb or whereRaw() | prepare() / bindings |
| Secret in the repo | Hard-coded key or committed .env | Move to the environment, rotate the key, check .gitignore |
What SKILL.md sets; muted values are Claude Code's defaults
25 skills in this plugin
/acf-nativeUse when building or reviewing ACF field behaviour or the post save flow - validate before publish, required/maxlength settings, hiding a field (conditional_logic), dynamic choices, running code after save - acf/validate_value, acf/load_field, acf/prepare_field, acf/save_post, acf.getField, wp_insert_post_data, save_post - including projects where ACF may not be installed (Radicle). Maps each need to the native mechanism verified in local source. For ACF Composer scaffolding use acorn-scaffolding; for escaping ACF output use wp-security-escaping./acorn-backgroundUse when work must run outside the request, on a schedule, or be logged in an Acorn project - WP-Cron vs Action Scheduler vs Laravel queues (make:job, ShouldQueue, queue:work, failed_jobs), console commands (make:command, wp acorn <command>), Schedule::command and schedule:run from system cron, Laravel Redis and Cache vs transients, logging channels (Log::, LOG_CHANNEL, stderr, storage/logs). For tables use acorn-data; for object cache tuning use wp-performance./acorn-dataUse when storing or querying data through Acorn's database layer - Eloquent models (app/Models, models over wp_posts, postmeta, users), custom tables, migrations (make:migration, migrate --force on deploy), seeders and factories, the DB facade, table prefix errors ("Table wp_wp_x doesn't exist"), and choosing post meta vs options vs a post type vs a custom table. For queues use acorn-background; for endpoints use acorn-routes-api; for post type registration use acorn-scaffolding./acorn-livewireUse when creating, wiring or fixing a Livewire 4 component in an Acorn app - make:livewire --class, app/Livewire, wire:model modifiers (.live, .blur, .debounce), wire:key, attributes (#[Locked]/#[Computed]/#[Validate]/#[On]), lifecycle hooks, @livewireScripts, the /livewire-<hash>/update route, installing livewire/livewire on Radicle. For errors that start after a deploy (419, RangeError, stale HTML) use roots-debugging; for JSON endpoints use acorn-routes-api; for Alpine-only UI use tailwind-vite-assets./acorn-routes-apiUse when adding or fixing an HTTP endpoint or virtual page in an Acorn project - Acorn routes (routes/web.php, routes/api.php, withRouting, Route::get, controllers, middleware, route:list) versus register_rest_route (permission_callback, /wp-json, X-WP-Nonce); webhooks, JSON APIs, CORS, throttle, API-key or JWT auth, "Target class [auth] does not exist", 404 on a defined route. For Livewire use acorn-livewire; for models use acorn-data; for nonces and capabilities in depth use wp-security-escaping./acorn-scaffoldingUse when generating a new artifact in an Acorn project - a Gutenberg block (ACF Composer acf:block, InnerBlocks, $styles, or a native block.json block via make:block), a post type or taxonomy (Poet config/poet.php, config/post-types.php), an ACF field group, partial or options page (acf:field, acf:options), a provider, View Composer, Blade component or command (make:provider, make:composer, make:component). For changing existing Acorn code use acorn-stack; for ACF hooks use acf-native; for block CSS and JS use tailwind-vite-assets.npx claudepluginhub hekivo/kivo-wise --plugin kivo-wiseOther plugins' skills for the same job