CVE-2024-42356: Shopware vulnerable to Server Side Template Injection in Twig using Context functions
The context
variable is injected into almost any Twig Template and allows to access to current language, currency information. The context object allows also to switch for a short time the scope of the Context as a helper with a callable function.
Example call from PHP:
$context->scope(Context::SYSTEM_SCOPE, static function (Context $context) use ($mediaService, $media, &$fileBlob): void {
$fileBlob = $mediaService->loadFile($media->getId(), $context);
});
This function can be called also from Twig and as the second parameter allows any callable, it’s possible to call from Twig any statically callable PHP function/method.
It’s not possible as customer to provide any Twig code, the attacker would require access to Administration to exploit it using Mail templates or using App Scripts.
References
- github.com/advisories/GHSA-35jp-8cgg-p4wj
- github.com/shopware/core/commit/04183e0c02af3b404eb7d52c683734bfe0595038
- github.com/shopware/core/commit/a784aa1cec0624e36e0ee4d41aeebaed40e0442f
- github.com/shopware/shopware
- github.com/shopware/shopware/commit/8504ba7e56e53add6a1d5b9d45015e3d899cd0ac
- github.com/shopware/shopware/commit/e43423bcc93c618c3036f94c12aa29514da8cf2e
- github.com/shopware/shopware/security/advisories/GHSA-35jp-8cgg-p4wj
- nvd.nist.gov/vuln/detail/CVE-2024-42356
Detect and mitigate CVE-2024-42356 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →