MEDIUM 6.1

CVE-2026-48157: Slim Framework XSS Vulnerability in HttpException (v4.4.0-4.15)

Slim, a popular PHP web framework, contains a vulnerability in versions 4.4.0 through 4.15 where developers can inadvertently create reflected cross-site scripting (XSS) vulnerabilities. If an application passes user-supplied data (like a search query or request parameter) into the HttpException::setTitle() or setDescription() methods, that data will be rendered without HTML escaping when an error page is displayed to the user. An attacker could craft a malicious request containing JavaScript that executes in the victim's browser. The vulnerability exists even when error detail display is disabled. The issue is fixed in Slim 4.15.2.

Source data · NVD / CISA · public domain

CVSS
3.1 · 6.1 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Weaknesses (CWE)
CWE-79
Affected products
0 configuration(s)
Published / Modified
2026-06-15 / 2026-06-17

NVD description (verbatim)

Slim is a PHP micro framework that enables users to write simple web applications and APIs. In versions 4.4.0 through 4.15, if an application uses HttpException::setTitle() and/or setDescription() to include untrusted/request-derived data in the error title or description (e.g. "No products found matching '{$query}'."), an attacker could inject arbitrary HTML/JavaScript that executes in the victim's browser when they encounter an HTML error page generated by Slim. The vulnerability is present even with displayErrorDetails = false as the unescaped title and description are rendered on this error path. Built-in exceptions (HttpNotFoundException, HttpBadRequestException, etc.) ship plain-text defaults, so a vanilla Slim app with no user code is not exploitable. Only applications that feed untrusted data into setTitle() and/or setDescription() are affected. The issue has been fixed in 4.15.2. If developers are unable to immediately update their applications, they can work around this issue by avoiding passing untrusted/request-derived data into HttpException::setTitle() and setDescription() and using static, plain-text error copy instead. They should also register a custom error renderer (an ErrorRendererInterface implementation, or a subclass of HtmlErrorRenderer that escapes the title and description) for the HTML media type.

2 reference(s) · View on NVD →

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

Technical summary

CVE-2026-48157 is a stored XSS vulnerability in Slim framework's HttpException class. When applications call setTitle() or setDescription() with untrusted input, the framework renders these values directly into HTML error pages without proper escaping. The vulnerability manifests in the error rendering path used by Slim's error handler middleware, affecting both normal and minimal error display modes. The root cause is the absence of output encoding in the HtmlErrorRenderer component when constructing error page markup from exception metadata. Built-in exception subclasses (HttpNotFoundException, HttpBadRequestException) are not vulnerable because they use static, predefined messages. Custom applications that interpolate request parameters or external data into exception titles or descriptions create an exploitable code path. Patch version 4.15.2 introduces proper HTML entity encoding for these fields.

Business impact

For organizations running Slim-based applications, the risk depends entirely on whether development teams have passed user-controlled data into exception messages. Vulnerable applications could suffer credential theft, session hijacking, malware distribution, or account takeover if error pages are accessible to end users. Since the vulnerability requires developer-level misuse rather than a framework-level defect that affects all deployments, the business impact is moderate but potentially severe for affected instances. Attackers could harvest sensitive information displayed in error context or perform client-side attacks against users encountering error pages. Organizations must audit their codebase to identify where HttpException messages are constructed from request data.

Affected systems

Slim framework versions 4.4.0 through 4.15 are vulnerable. Version 4.15.2 and later contain the fix. Applications using earlier major versions (3.x, 2.x) or versions 4.0 through 4.3 are unaffected. The vulnerability only manifests in applications where developers have explicitly passed untrusted data into setTitle() or setDescription() methods on HttpException or its subclasses. Vanilla Slim installations with default error handling are not exploitable because built-in exceptions use static text.

Exploitability

The vulnerability requires user interaction (a victim must view an error page) and network access to the application. An attacker crafts a request designed to trigger an error condition while injecting HTML/JavaScript into a parameter that the application passes to an exception title or description. The payload executes in the victim's browser context, allowing session stealing, credential harvesting, or malware delivery. The barrier to exploitation is low—standard XSS attack techniques apply. However, exploitability is contingent on the application author having made the specific mistake of feeding request data into exception messages, which is not a default Slim behavior. This is classified as MEDIUM severity (CVSS 6.1) due to the user interaction requirement and limited attack surface, but individual vulnerable applications face significant risk.

Remediation

Organizations should upgrade Slim to version 4.15.2 or later immediately. Before upgrading, developers must audit their codebase for calls to HttpException::setTitle() and setDescription() that incorporate request parameters, environment variables, or other untrusted data. As a temporary mitigation, remove or sanitize any untrusted data passed to these methods, using static error messages instead. Developers can also implement a custom error renderer that properly escapes HTML entities in exception titles and descriptions, or extend HtmlErrorRenderer with proper output encoding. After patching, verify that custom error handling logic does not reintroduce the vulnerability.

Patch guidance

Upgrade Slim to version 4.15.2 or later. Review your composer.json or package manager configuration and apply the update in a staging environment first. Slim follows semantic versioning; 4.15.2 is a patch release and should be backward compatible with 4.15 and earlier 4.x versions. After updating, run your application's test suite to confirm no regressions. If you maintain a custom error renderer or have overridden default error handling, verify that your implementation properly escapes exception metadata before rendering. Consider adding a security test case that confirms injection attempts in exception messages do not execute.

Detection guidance

Monitor application logs for HTTP error page requests that contain suspicious characters (angle brackets, script tags, event handlers) in request parameters. Web application firewalls can detect classic XSS payloads in query strings and POST bodies. Perform static code analysis to identify calls to setTitle() and setDescription() on HttpException objects; flag any invocations where the argument is derived from request input, superglobals, or external sources rather than hardcoded strings. Review error page HTML source (using browser developer tools) to confirm that exception titles and descriptions are properly HTML-entity encoded. Penetr testing should include submitting XSS payloads to parameters known to trigger application errors.

Why prioritize this

Although this vulnerability is rated MEDIUM severity, organizations running affected Slim versions should prioritize patching because: (1) the fix is straightforward and low-risk, (2) many development teams inadvertently pass user data into error messages without realizing the security implication, (3) error pages are often visible to unauthenticated attackers, and (4) XSS vulnerabilities enable a broad range of follow-on attacks. Prioritize any internal or customer-facing applications using Slim 4.4.0–4.15 that have user-generated content or dynamic error messages.

Risk score, explained

The CVSS 3.1 score of 6.1 (MEDIUM) reflects: (1) network attack vector (AV:N) — no special access required, (2) low attack complexity (AC:L) — standard XSS techniques suffice, (3) no privilege required (PR:N), (4) user interaction required (UI:R) — victim must view an error page, (5) scope change (S:C) — JavaScript can affect user's browser beyond the vulnerable application, and (6) low confidentiality and integrity impact (C:L/I:L) — session theft or defacement, no system-level compromise, no availability impact (A:N). The score appropriately penalizes the user interaction requirement while acknowledging the real client-side risk.

Frequently asked questions

Does this affect my Slim application if I'm not using custom exception messages?

No. Slim's built-in exception classes (HttpNotFoundException, HttpBadRequestException, etc.) use static, safe error text and are not vulnerable. Only applications that explicitly call setTitle() or setDescription() with request-derived data are at risk. Verify your codebase for these specific method calls.

I'm on Slim 4.15. Do I need to upgrade to 4.15.2?

Yes. The vulnerability exists in 4.15 and earlier versions. You must upgrade to 4.15.2 or later. This is a patch release and should not introduce breaking changes.

Can I exploit this if the application has displayErrorDetails = false?

Yes. The vulnerability is present regardless of the displayErrorDetails setting. The unescaped title and description are rendered on the error page even in minimal error display mode, so an attacker's injected JavaScript can still execute.

What's the difference between this vulnerability and a typical reflected XSS?

This is a stored or persistent XSS risk within the application's error handling pathway. The attacker injects code via a request parameter, but the code is 'stored' in the exception object and rendered on the error page in the same request. It behaves like reflected XSS from the attacker's perspective but is triggered through the framework's error rendering rather than direct output of request data in normal response paths.

This analysis is provided for informational purposes and does not constitute professional security advice. Organizations should conduct their own risk assessments and testing in accordance with their security policies. SEC.co makes no warranty regarding the completeness or accuracy of third-party vulnerability data. Verify all patch versions and vendor guidance directly against official Slim project releases and security advisories before deployment. No exploit code or active attack examples are provided in this article; security research and testing should be conducted only in authorized, isolated environments. Source: NVD (public-domain), retrieved 2026-07-24. Analysis generated by SEC.co (claude-haiku-4-5).