Back to skill

Security audit

wordpress-theme

Security checks for vulnerabilities and agentic risk

Overview

This is a straightforward WordPress theme-conversion guide, but some example code should be reviewed for WordPress escaping and sanitization before reuse.

Install only as a WordPress theme-conversion reference. Before using generated code in production, require standard WordPress escaping, sanitization callbacks, nonce and capability checks, and extra review for anything involving forms, authentication, custom database access, or untrusted content.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:158
Finding

Unescaped Custom Field Value in an HTML Attribute

Content
View full analysis
``` ### Technical Analysis The example prints an Advanced Custom Fields sub-field directly into the `id` attribute using `the_sub_field()`. This function outputs the stored value without applying context-appropriate HTML attribute escaping. If an attacker or an insufficiently trusted content editor can control `section_id`, a value containing quotes may terminate the `id` attribute and introduce additional attributes or markup. Because the Skill instructs users to reproduce this pattern in generated WordPress themes, it may create a stored cross-site scripting condition. ### Attack Path 1. An attacker obtains access to an account or workflow that can modify the relevant custom field. 2. The attacker stores a payload containing an attribute terminator and injected event handler or markup in `section_id`. 3. WordPress saves the attacker-controlled custom-field value. 4. A visitor opens a page rendered by the affected template. 5. `the_sub_field()` prints the value directly into the `section` element. 6. The browser interprets the injected HTML or event handler, potentially executing script in the visitor's WordPress origin. ### Impact Assessment Successful exploitation could execute attacker-controlled JavaScript in the browser of a visitor viewing the affected page. Depending on the victim's WordPress privileges, this may allow administrative actions through the victim's authenticated session, content manipulation, sensitive page-data access, or account compromise. The exploit requires the attacker to control the relevant custom-field value. The resulting scope is the WordPress site and ori ...[truncated 61 chars]
Remediation
View remediation
``` Additional hardening measures: - Restrict the field to letters, digits, underscores, and hyphens. - Validate and sanitize the value when it is saved, not only when rendered. - Limit custom-field modification privileges to trusted roles. - Apply context-specific escaping to every dynamic attribute. - Add tests using values containing quotes, angle brackets, and event-handler syntax. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
SKILL.md:181
Finding

Customizer Values Are Emitted into CSS Without Server-Side Validation

Content
View full analysis
add_setting('theme_primary_color', array( 'default' => '#00E676', 'transport' => 'refresh', )); ``` The value is subsequently placed into a CSS declaration: ```php function theme_customizer_css() { $vars = array( 'primary' => get_theme_mod('theme_primary_color', '#00E676'), 'primary_dark' => get_theme_mod('theme_primary_dark_color', '#00C853'), ); $css = ':root {'; foreach ($vars as $prop => $value) { $css .= '--' . $prop . ':' . esc_attr($value) . ';'; } $css .= '}'; echo '' . $css . ''; } add_action('wp_head', 'theme_customizer_css'); ``` ### Technical Analysis The Customizer setting does not define a server-side `sanitize_callback`. The later output uses `esc_attr()`, which is intended for HTML attribute values and is not a CSS-value validator. A malicious value containing CSS delimiters may terminate the custom-property declaration and inject additional CSS rules. Client-side behavior from `WP_Customize_Color_Control` must not be treated as a security boundary because direct or modified requests can bypass browser-side validation. The output remains inside a `style` element, and the shown escaping limits straightforward HTML or script breakout. The confirmed risk is therefore persistent CSS injection rather than direct JavaScript execution. ### Attack Path 1. An attacker gains access to an account or request context permitted to modify Customizer settings. 2. The attacker bypasses the color control's client-side validation and submits a crafted value containing CSS delimiters. 3. WordPress stores the value because the setting has no `sanitize_callback`. 4. The `theme_customizer_css()` function retrieves the stored value. 5. `esc_attr()` performs HTML-oriented escaping but does not enforce val ...[truncated 799 chars]
Remediation
View remediation
add_setting('theme_primary_color', array( 'default' => '#00E676', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_setting('theme_primary_dark_color', array( 'default' => '#00C853', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color', )); ``` Validate retrieved values before constructing CSS and fall back to known-safe defaults: ```php $primary = sanitize_hex_color( get_theme_mod('theme_primary_color', '#00E676') ); if (!$primary) { $primary = '#00E676'; } ``` Additional hardening measures: - Use a strict allowlist appropriate to the expected CSS data type. - Do not rely on `esc_attr()` as a substitute for CSS validation. - Keep property names fixed rather than deriving them from user input. - Preserve WordPress capability and nonce checks for Customizer requests. - Test direct requests containing semicolons, braces, URLs, and malformed color values. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (1)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The invocation guidance is broad enough to trigger on generic requests to create or migrate a website, but it does not define safety boundaries such as excluding plugin development, admin-side code, direct database access, or handling untrusted user content. In a code-generation skill, this can cause the agent to apply the skill in contexts where the provided examples and workflow omit important security controls, increasing the chance of insecure WordPress code being produced.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.