CVE-2025-49136: listmonk's Sprig template Injection vulnerability leads to reading of Environment Variable for low privilege user
9.1
Basic Information
Technical Details
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
github.com/knadh/listmonk | go | >= 4.0.0, < 5.0.2 | 5.0.2 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability (GHSA-jc7g-x28f-3v3h) in Listmonk arises from the use of the Sprig template library, which by default includes potentially dangerous functions like env
and expandenv
. These functions allow access to system environment variables from within templates. The exploit occurs when a low-privilege user with permissions to create or modify campaign content (which uses templates) injects template code like {{ env "SENSITIVE_VAR" }}
.
The analysis of the provided patch (commit d27d2c32cf3af2d0b24e29ea5a686ba149b49b3e
) shows modifications in two key Go files:
cmd/init.go
: The functioninitTplFuncs
was changed to explicitly deleteenv
andexpandenv
from thesprig.GenericFuncMap()
before making these functions available to the template engine.internal/manager/manager.go
: The method(*Manager).makeGnericFuncMap
(note: 'Gneric' is likely a typo in the original codebase for 'Generic') underwent the same modification, removingenv
andexpandenv
.
These two functions, initTplFuncs
and (*Manager).makeGnericFuncMap
, were the points in the Listmonk codebase where the vulnerable Sprig functions were being registered for use in templates. By including sprig.GenericFuncMap()
in its entirety without filtering, these Listmonk functions inadvertently exposed the env
and expandenv
functionalities, making the application vulnerable to environment variable disclosure by users who could control template content. The patch mitigates this by ensuring these specific dangerous functions are no longer available to the template engine. Therefore, these two functions are identified as the ones whose previous implementation led to the vulnerability.