Skip to content

Server-side template injection in Twig template rendering enables information disclosure and RCE

Critical
admdly published GHSA-57mv-jm88-66jc Jun 20, 2026

Package

FOSSBilling

Affected versions

<= 0.7.2

Patched versions

0.8.0

Description

Summary

A Server-Side Template Injection (SSTI) vulnerability exists in FOSSBilling's template rendering system. Administrators with access to features that render Twig templates (email templates, mass mail campaigns, custom payment adapters, and the string_render API endpoint) can inject arbitrary Twig expressions, leading to information disclosure and remote code execution. The vulnerability exists because Twig templates are rendered without a sandbox, allowing access to the full Twig environment, API context, and the application's dependency injection container.

Impact

Information Disclosure to Remote Code Execution: Templates can access sensitive data via the guest, admin, and client API globals that are injected into the Twig environment. This includes company settings, client data, and in specific scenarios, staff password hashes.

Additionally, these API handler objects expose a getDi() method returning the full dependency injection container, which grants direct access to:

  • PDO - arbitrary SQL read/write against the entire database (not limited to what API endpoints return)
  • Symfony FilesystemAdapter - cache read/write (enables extension manifest poisoning)
  • Password service - password hashing for creating rogue accounts
  • Session service - session manipulation
  • All other registered application services

An admin-authenticated attacker can chain SSTI with DI container access to achieve remote code execution on the host server.

  • When chained with GHSA-78x5-c8gw-8279 (authorization bypass), the authentication requirement is eliminated, allowing unauthenticated remote attackers to achieve full remote code execution.
  • When this flaw is reached through the Custom payment gateway, the rendered template is returned directly to invoice-paying clients, so exploitation may present as stored client-side script execution in addition to the broader SSTI and DI-container abuse described above.

Privilege Required:

  • Standalone: Administrator (trusted role).
  • Chained with GHSA-78x5-c8gw-8279: None (unauthenticated).

Affected Versions

FOSSBilling version 0.1.0 through 0.7.2 (all releases to date).

Patched Versions

0.8.0

Details

The vulnerability exists in the template rendering chain:

  1. src/modules/System/Service.php - The renderString() method uses $twig->createTemplate($tpl) to render arbitrary strings without sandbox restrictions.
  2. src/modules/System/Api/Admin.php - The string_render() admin API endpoint passes user-supplied _tpl directly to renderString().
  3. src/modules/Email/Service.php - Email templates are rendered via _parse() which calls renderString() with the template content and subject.
  4. src/di.php - The Twig environment is configured without a sandbox, and with StringLoaderExtension enabled.
  5. src/library/Api/Handler.php / src/library/Api/Abstract.php - The getDi() method on API handler objects returns the raw DI container.

The following variables are available in email templates:

Variable Availability Contains
guest Always Guest API - access to public system data. getDi() exposes full DI container.
admin When admin is logged in Admin API - full administrative access. getDi() exposes full DI container.
client When client_id is set Client API - client-specific data. getDi() exposes full DI container.
staff When to_staff=true Raw staff database row (includes pass).
c When to_client Sanitized client array (no password).
c When to_admin Raw Admin model (includes pass).

Affected Components

  • src/modules/Email/Service.php - Email template rendering
  • src/modules/System/Api/Admin.php - string_render admin API endpoint
  • src/modules/System/Service.php - Template string rendering
  • src/modules/Massmailer/Service.php - Mass email campaigns
  • src/library/Payment/Adapter/Custom.php - Custom payment adapter templates
  • src/library/Box/TwigExtensions.php - Twig configuration
  • src/library/Api/Handler.php - getDi() exposes full DI container
  • src/library/Api/Abstract.php - getDi() base implementation

Workarounds

  • Audit existing email templates for suspicious Twig expressions.
  • Rotate all admin and client API tokens.
  • Block external access to /api/system/* at reverse proxy/WAF to mitigate chaining with GHSA-78x5-c8gw-8279.

Acknowledgements

Thanks to @0xcan1337 for responsible disclosure, vulnerability analysis, and PoC. Additional thanks to @Chocapikk for identifying the getDi() DI container exposure and RCE escalation chain, and to @VadlaReddySai for independently reporting the Custom payment gateway manifestation of this issue.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required High
User interaction None
Vulnerable System Impact Metrics
Confidentiality High
Integrity High
Availability High
Subsequent System Impact Metrics
Confidentiality High
Integrity High
Availability High

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H

CVE ID

CVE-2026-28496

Weaknesses

Improper Neutralization of Special Elements Used in a Template Engine

The product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine. Learn more on MITRE.

Credits