Vulnerability Database

361,925

Total vulnerabilities in the database

Kimai leaks API Token Hash via Invoice Twig Template — kimai / kimai

Incomplete List of Disallowed Inputs

Summary

The Twig sandbox used for invoice templates blocks certain sensitive User methods (password, TOTP secret, etc.) via a blocklist in StrictPolicy::checkMethodAllowed(). However, getApiToken() and getPlainApiToken() are not on the blocklist. An admin who creates an invoice template can embed calls to these methods, causing the bcrypt or sodium hashed API password of any user who generates an invoice using that template to be included in the rendered output.

Only relevant for OnPremise installations with template upload activated.

Background

Kimai allows admins (ROLE_ADMIN and above) with the manage_invoice_template permission to create Twig-based invoice templates. These templates are rendered in a sandboxed Twig environment with StrictPolicy controlling which methods and properties are accessible.

StrictPolicy explicitly blocks:

// src/Twig/SecurityPolicy/StrictPolicy.php:156 if (\in_array($lcm, [ 'getpassword', 'gettotpsecret', 'getplainpassword', 'getconfirmationtoken', 'gettotpauthenticationconfiguration' ], true)) { throw new SecurityNotAllowedMethodError(...); }

getApiToken() and getPlainApiToken() are not in this list and are freely callable.

Vulnerable Code

StrictPolicy.php — missing entries in the User method blocklist:

// Current ['getpassword', 'gettotpsecret', 'getplainpassword', 'getconfirmationtoken', 'gettotpauthenticationconfiguration'] // Should also include: 'getapitoken', 'getplainapitoken'

The invoice model passes a User object through model.user, accessible in any twig invoice template.

Steps to Reproduce

  1. Log in as an admin with the manage_invoice_template permission.
  2. Create a new Twig invoice template (HTML or PDF) containing:
API Token: {{ model.user.getApiToken() }} Plain Token: {{ model.user.getPlainApiToken() }}
  1. Save the template and set it as the default for a customer.
  2. Log in as a regular user assigned to that customer and generate an invoice.
  3. Observe that the rendered invoice contains the user's API token in plaintext.

Impact

An admin can silently embed token-exfiltration code in a shared invoice template. Every user who subsequently generates an invoice using that template will have their hashed API token leaked into the invoice output.

  • API passwords are deprecated since April 2024 and not in wide use anymore (especially by new users)
  • The function getPlainApiToken() does NEVER return any data
  • The function getApiToken() might return a bcrypt or sodium hashed API password, if the user (who created the invoice) has configured one - this cannot be used, but needs to be cracked using rainbow tables
  • The cloud does not allow Twig template upload, this is only relevant for OnPremise installations with template upload activated

Fix

The SecurityPolicy was changed to exclude methods that contains certain trigger words instead of using the hard-coded list, see https://github.com/kimai/kimai/pull/5878

This disables access to both the getApiToken() and getPlainApiToken() function.

  • Published: Apr 14, 2026
  • Updated: Apr 14, 2026
  • GHSA: GHSA-rh42-6rj2-xwmc
  • Severity: Low
  • Exploit:
  • CISA KEV:

CVSS v3:

  • Severity: Low
  • Score: 2
  • AV:N/AC:H/PR:H/UI:R/S:U/C:L/I:N/A:N

CWEs:

Frequently Asked Questions

A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.

CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.

A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.

Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.

Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.

SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.