MEDIUM 4.8

CVE-2026-58657: Stored CSS Injection in Grav CMS Markdown Image Resize

Grav, a flat-file CMS platform, contains a stored CSS injection flaw in its Markdown image resize feature. A content editor with page-editing privileges can embed malicious CSS into image resize parameters that will execute in the browser of any administrator or reviewer who views the crafted page. Unlike traditional injections, this attack doesn't require JavaScript—it abuses CSS properties to manipulate the visual layout or create overlay attacks that could deceive users into performing unintended actions.

Source data · NVD / CISA · public domain

CVSS
3.1 · 4.8 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N
Weaknesses (CWE)
CWE-79
Affected products
0 configuration(s)
Published / Modified
2026-07-08 / 2026-07-08

NVD description (verbatim)

Grav before 2.0.0 (affected through 2.0.0-rc.9 and the 2.0 branch) contains a stored CSS injection vulnerability in the Markdown image resize() media action. Prior media hardening rejects direct ?style= payloads and unsafe attribute() fallbacks, but the resize() action in Excerpts::processMediaActions() writes caller-controlled values directly into the image's styleAttributes. A lower-privileged content editor who can edit page Markdown can store a crafted image URL with semicolon-delimited CSS declarations in the resize parameters, which are rendered into the final <img style=...> attribute when a higher-privileged reviewer/admin views the page or preview. This does not require JavaScript execution but enables UI redress/overlay and content-manipulation attacks (e.g., a full-viewport fixed overlay). Fixed in 2.0.0.

5 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability exists in the Excerpts::processMediaActions() method, specifically in the resize() media action handler. While Grav's prior media hardening blocks direct ?style= query parameters and unsafe CSS attribute() functions, the resize() action fails to sanitize caller-controlled input before writing it directly into the styleAttributes of rendered <img> elements. An attacker with content-editor privileges can craft a Markdown image reference with semicolon-delimited CSS declarations in resize parameters (e.g., width, height fields). When the page is rendered for higher-privileged users, these unsanitized values are injected into the final HTML style attribute, creating a persistent stored XSS-adjacent vulnerability. The attack surface is limited by the PR:H requirement—only users with higher privilege levels (admin/reviewer) need to view the page for the payload to render—but the confluence of editor access and admin viewing makes this a realistic threat in collaborative editorial workflows.

Business impact

For organizations using Grav as a CMS, this vulnerability enables editorial staff to launch visual redress or content-manipulation attacks against administrative users without requiring code execution. Practical impacts include stealing session tokens via invisible form overlays, redirecting admins to malicious sites, or defacing administrative dashboards. In multi-tenant or community-driven Grav instances, a compromised or malicious contributor could poison pages viewed by high-privilege accounts. The medium CVSS score reflects the requirement for both editor access and admin interaction, but the ease of exploitation and persistence (stored in Markdown) elevate practical risk in open editorial environments.

Affected systems

All versions of Grav prior to 2.0.0 are affected, including the entire 2.0.0 release candidate series through 2.0.0-rc.9 and the 2.0 branch. The fix is released in Grav 2.0.0 stable. Organizations running older 1.x versions and RC builds of 2.0 are in scope.

Exploitability

Exploitability is straightforward for anyone with Markdown page-editing permissions. No complex tooling or user interaction beyond normal admin review is required—admins only need to view a crafted page in the editor or frontend. The barrier to entry is low (CSS knowledge, not programming expertise), but the attack is limited to scenarios where a lower-privileged editor can store content viewed by higher-privileged users, and the attacker must anticipate admin interaction. The CVSS vector (PR:H, UI:R, AC:L) accurately reflects these constraints: high privilege required for the attacker to introduce payload, user interaction required for the victim, but low attack complexity.

Remediation

Upgrade to Grav 2.0.0 or later, where the resize() action in Excerpts::processMediaActions() has been hardened to sanitize CSS input before rendering into style attributes. Organizations unable to upgrade immediately should restrict Markdown editing permissions to trusted administrators only and audit existing pages for suspicious image resize parameters containing semicolons or CSS-like syntax.

Patch guidance

Apply the update to Grav 2.0.0 as soon as feasible. For users on 1.x branches or RC builds of 2.0, verify your upgrade path through the official Grav documentation. After patching, no configuration changes are required; the fix is automatic. Test the upgrade in a staging environment first, particularly if you maintain custom plugins that extend media action handling, to ensure compatibility.

Detection guidance

Search your Grav page repository (typically the pages/ directory) for Markdown image syntax with suspicious patterns in resize parameters, such as: `![...](image.jpg?resize=...;...;...)` or occurrences of CSS keywords (display, position, fixed, left, top, overflow) in resize or image metadata fields. Monitor admin user sessions and audit logs for page edits by lower-privileged users followed by admin access. In live deployments, inspect rendered HTML for unexpected style attributes on images that deviate from legitimate responsive design patterns.

Why prioritize this

This vulnerability merits prompt patching despite its medium CVSS score because it combines ease of exploitation with persistence and bypasses traditional XSS mitigations. The stored nature and the typical admin-review workflow make it a realistic threat in active Grav installations. Organizations with open editorial policies or community-contributed content should prioritize this over other medium-severity issues.

Risk score, explained

CVSS 4.8 (MEDIUM) reflects the constrained attack surface: the attacker must have higher privilege (PR:H) to introduce payload and the victim must actively view the page (UI:R). However, in collaborative CMS environments, both conditions are routine, making the practical risk higher than the numerical score suggests. The impact is limited to information disclosure and minor integrity (visual manipulation, not data alteration), which aligns with the low C and I scores.

Frequently asked questions

Can this vulnerability be exploited without admin interaction?

No. The payload is stored in the Markdown, but it only renders and executes when a higher-privileged user (reviewer/admin) views the page. A content editor alone cannot trigger the injection; they can only prepare it.

Is JavaScript execution required?

No. This is a CSS-only injection. The attack abuses CSS properties like `position: fixed` and `top/left` to create invisible overlays or visual redirection, without needing script tags or event handlers. This makes it harder to detect via simple CSP or script-blocking policies.

What should organizations do if they can't upgrade immediately?

Restrict Markdown editing and image upload permissions to fully trusted administrators, and implement a multi-step approval workflow where all page edits are reviewed before publish. Additionally, audit existing content for suspicious resize parameter syntax.

Does this affect Grav 1.x?

Yes, all versions before 2.0.0 are affected, including 1.7.x and earlier. However, the fix is released only in 2.0.0; organizations on 1.x may need to plan a major version upgrade or apply a backport if available from the vendor.

This analysis is based on the official CVE record and Grav vendor advisory as of the publication date. Organizations should verify patch availability and compatibility with their specific Grav version and custom extensions before deploying updates. No guarantee is made regarding the completeness or applicability of this information to any particular environment. Always test patches in a staging environment first. Source: NVD (public-domain), retrieved 2026-08-17. Analysis generated by SEC.co (claude-haiku-4-5).