Summary
Groundhogg's [ghr] shortcode can render a post title as unescaped HTML, creating a stored cross-site scripting vulnerability. An authenticated user with Contributor-level access or higher may be able to place script content in a post title that executes when someone views a page containing the affected shortcode.
Affected context
The issue affects the Groundhogg WordPress plugin in versions up to and including 4.10. It occurs when the [ghr] shortcode processes the post_title merge tag: the nested replacement path can return the title without the expected escaping, while the single_post() callback decodes HTML entities. The risk arises when a Contributor-level or higher user can submit a crafted post title and the affected shortcode renders it.
Exploit preconditions
- Attack surface: WordPress pages that render the Groundhogg
[ghr]shortcode with thepost_titlemerge tag - Required access: Authenticated access with Contributor-level privileges or higher
- Trigger point: Rendering a page that includes the affected shortcode and a post title controlled by the attacker
- Why exploitation is possible: Entity-encoded title content can be decoded and emitted as HTML without the required output escaping
Why this happens
This is a stored cross-site scripting flaw mapped to CWE-79: Improper Neutralization of Input During Web Page Generation. The nested merge-tag replacement path bypasses escaping, and the callback decodes HTML entities before emitting the title. As a result, content that remains encoded after WordPress filtering may become active HTML in the rendered page.
Potential impact
- Attacker-controlled scripts may execute in the browsers of users who view an affected page.
- Scripts could act with the privileges of the viewing user within the site.
- Depending on the viewer's role and site controls, this could expose or alter site data or facilitate further account compromise.
General mitigation guidance
Defensive patterns include:
- Escape values for their specific output context at the point where they are rendered.
- Avoid decoding untrusted content into HTML unless it is subsequently sanitized and safely escaped.
- Use safe-by-default replacement and templating paths that apply consistent escaping, including to nested values.
- Validate and constrain content according to its intended use, while treating user-submitted titles as untrusted.
- Apply least privilege to user roles and limit who can create or modify content used by shortcodes.
How teams detect issues like this
- Use static analysis to identify output of post titles or merge-tag values without context-appropriate escaping, particularly after HTML entity decoding.
- Review nested replacement and shortcode rendering paths for branches that bypass sanitization or escaping.
- Test role-based content submission and rendering flows to confirm that untrusted titles remain inert in the browser.
- Apply code review and CI policies that flag unsafe HTML output and require contextual escaping.

