Sep 17, 2026·4 min read·11 visits
Low-privileged editors can inject arbitrary CSS via image resize query parameters due to missing type validation in Grav's media processing trait.
CVE-2026-58657 is a critical stored CSS injection vulnerability in Grav CMS's media processing pipeline. By exploiting improper sanitization of image dimensions in the resize helper, low-privileged users with page editing permissions can inject arbitrary CSS styles. This can lead to visual defacement, UI redressing, and indirect data exfiltration.
Grav CMS is a flat-file content management system that processes content written in Markdown. Within its media pipeline, users can append query parameters to image references to perform dynamic manipulations, such as resizing, cropping, or scaling.
The vulnerability, designated as CVE-2026-58657, resides within the media manipulation handler. Specifically, when parsing the resize parameter, the system fails to sanitize or validate the dimensions supplied in the URL query string.
This lack of sanitization allows an attacker with page creation or editing privileges to insert raw CSS syntax. Because the generated dimensions are directly written to inline style attributes, this results in stored CSS injection when the page is rendered for other users.
The root cause of this vulnerability lies in the lack of type verification within the resize() method. This method is implemented inside the StaticResizeTrait trait, located at system/src/Grav/Common/Media/Traits/StaticResizeTrait.php.
During Markdown processing, Grav extracts query parameters from image URLs and forwards them to Excerpts::processMediaActions(). When the resize action is processed, the raw width and height strings are assigned directly to the internal $styleAttributes array.
Because the input values are concatenated directly with the 'px' string without casting to integers, any character sequence containing semicolons is preserved. Semicolons act as delimiters in CSS, enabling an attacker to terminate the width property and append arbitrary CSS properties to the inline style block.
A comparison of the vulnerable and patched code reveals how the input validation check was missing. In the vulnerable version, the parameters are handled as raw variables:
public function resize($width = null, $height = null)
{
if ($width) {
$this->styleAttributes['width'] = $width . 'px';
}
// ...
}The fix introduces strict validation by verifying if the values are numeric and casting them to integers. This neutralizes any non-numeric characters before they are added to the inline style array:
$width = is_numeric($width) ? (int) $width : 0;
$height = is_numeric($height) ? (int) $height : 0;
if ($width > 0) {
$this->styleAttributes['width'] = $width . 'px';
} else {
unset($this->styleAttributes['width']);
}This validation ensures that only positive integer values are rendered inside the final style attribute. Non-numeric inputs evaluate to 0 and are completely discarded, preventing the inject path.
To exploit this vulnerability, an attacker must have permissions to create or modify pages within the Grav CMS instance. This restriction makes the threat vector post-authentication, though achievable by users with low-privilege roles such as content editors or contributors.
The attacker crafts an image tag within the Markdown editor containing a malformed resize parameter. An example payload structures the query parameter to include a semicolon followed by positioning directives:
When processed by the server, the template parser renders an image tag with a corrupted inline style attribute. The browser parses the semicolon as a delimiter, overriding the layout with a full-screen block on top of the original interface. This visual overlay can be customized to display deceptive content.
The impact of this vulnerability is centered around UI redressing and potential credential theft. While CSS injection does not execute arbitrary JavaScript directly, modern CSS features allow sophisticated manipulation of the user interface.
Attackers can utilize absolute positioning and high z-index elements to craft phishing forms over the legitimate administration interface. When an administrator views the page, they may interact with the fake form, unknowingly submitting sensitive inputs to an external server.
Additionally, CSS attribute selectors can be used to exfiltrate sensitive tokens. By utilizing background image URLs that trigger conditionally based on input attributes, an attacker could leak CSRF tokens or user-typed data to an out-of-band logger.
The primary remediation path is to update the Grav CMS installation to version 2.0.0 or higher. This release integrates the type-casting logic in the StaticResizeTrait class to completely block the injection path.
If upgrading is not immediately possible, administrators should manually apply the code-level patch to the StaticResizeTrait.php file. This involves casting the input parameters to integers before they are evaluated or appended to style arrays.
In addition, implementing a strict Content Security Policy can restrict the impact of CSS injection. Configuring the style-src directive without 'unsafe-inline' prevents the execution of arbitrary inline style rules, though it may affect normal operation if inline styles are required by the theme.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
Grav CMS Trilby Media | < 2.0.0 | 2.0.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-79 |
| Attack Vector | Network |
| CVSS Score | 6.5 |
| EPSS Score | 0.00371 |
| Impact | Stored CSS Injection |
| Exploit Status | none |
| KEV Status | Not Listed |
CVE-2026-118777 is a prototype pollution vulnerability (CWE-1321) in the Forge JavaScript cryptography and networking library (distributed on npm as node-forge) prior to version 1.4.1. The flaw resides in the forge.http client subsystem, where incoming HTTP cookie names and paths parsed from Set-Cookie response headers are stored directly into standard JavaScript objects without key validation or property isolation. By returning crafted Set-Cookie headers containing keys such as __proto__ or constructor, a malicious HTTP server can inject arbitrary properties into Object.prototype, attach attributes to the global Object constructor, or delete built-in prototype methods to cause an application-wide denial of service.
CVE-2026-118775 (GHSA-4642-5mcj-2rqw) is an integer overflow and validation flaw in the ASN.1 serialization module of Forge (node-forge) prior to version 1.4.1. The asn1.oidToDer() function fails to validate the range of the first two arcs of an Object Identifier (OID) and truncates the packed initial subidentifier to a single 8-bit integer. Applications that perform policy checks on untrusted OID strings before encoding them into Distinguished Encoding Rules (DER) format can be tricked into emitting DER bytes that correspond to a completely different, restricted OID.
CVE-2026-119194 is an algorithmic complexity vulnerability (CWE-407) in the pyasn1 library for Python, affecting versions 0.3.3 through 0.6.4. The flaw resides in the schemaless decoding routine ConstructedPayloadDecoderBase._decodeComponentsSchemaless used across BER, CER, and DER codecs. By sending an ASN.1 container populated with child components whose tag identifiers are separated by multiples of CPython's integer hash modulus (sys.hash_info.modulus), an unauthenticated attacker can force worst-case hash collisions in an unbounded Python set, degrading decoding performance from O(N) to O(N^2) and causing a Denial of Service (DoS).
CVE-2026-119195 is an algorithmic complexity vulnerability (CWE-407) in the pyasn1 library for Python, affecting all versions prior to 0.6.5. When decoding constructed strings or indefinite-length ANY types across BER, CER, and certain DER code paths, the payload decoders repeatedly concatenate incoming fragments onto an immutable bytes object using the += operator. Because Python bytes objects cannot be resized in-place, each fragment iteration allocates a new buffer and copies all previously accumulated bytes, resulting in quadratic O(N^2) time and memory copy complexity. An unauthenticated remote attacker can supply a highly fragmented ASN.1 stream to exhaust CPU cycles and stall application worker threads.
An algorithmic complexity vulnerability (CWE-407) in pyasn1 versions prior to 0.6.5 allows unauthenticated attackers to cause a Denial of Service (DoS) via crafted ASN.1 payloads. The flaw resides in the binary-encoded ASN.1 REAL mantissa deserialization routine within RealPayloadDecoder.valueDecoder. By performing iterative byte-string slicing and repeated bitwise shifts on a growing arbitrary-precision integer, the decoder exhibits quadratic time and memory allocation complexity relative to the mantissa length. Supplying a BER-, CER-, or DER-encoded payload with a large REAL mantissa causes excessive CPU consumption and blocks application worker processes.
A vulnerability classified under CWE-407 (Inefficient Algorithmic Complexity) exists in the pyasn1 library prior to version 0.6.5. When parsing constructed ASN.1 BIT STRING payloads under BER, CER, or schema-driven DER encoding rules, the BitStringPayloadDecoder repeatedly shifts and copies the entire accumulated bit value for each incoming fragment. Processing inputs with a large number of small constructed fragments induces quadratic CPU consumption, allowing unauthenticated remote attackers to cause a denial of service via resource exhaustion during the initial decoding phase.