# Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.
# Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.
Update twig/twig to 3.26.0 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanTwig: Possible sandbox bypass when using a source policy affects twig/twig (composer), twig/twig (composer). Severity is high. # Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.
AI coding agents often install or upgrade packages automatically in composer. A high vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| twig/twigcomposer | >=2.16.0,<=2.16.1 | Not reported |
| twig/twigcomposer | >=3.9.0,<3.26.0 | 3.26.0 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL GuardUpdate twig/twig to 3.26.0 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanTwig: Possible sandbox bypass when using a source policy affects twig/twig (composer), twig/twig (composer). Severity is high. # Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.
AI coding agents often install or upgrade packages automatically in composer. A high vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| twig/twigcomposer | >=2.16.0,<=2.16.1 | Not reported |
| twig/twigcomposer | >=3.9.0,<3.26.0 | 3.26.0 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL Guard