GIVE YOUR AGENT THE EVIDENCE

Set up in your agent.

One prompt to get started. Paste it into your coding agent to connect cve.new through MCP and bring vulnerability context into your workflow.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GIVE YOUR AGENT THE EVIDENCE

Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

All vulnerabilities
GHSA-2q52-x2ff-qgfrhigh8.8

Twig: Possible sandbox bypass when using a source policy

Check your stack

The advisory, in context

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.

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

twig/twig Packagist
Ecosystem versions

From 2.16.0 through 2.16.1 (inclusive)

No fix recorded for this interval.

2 explicitly affected versions

v2.16.0, v2.16.1

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "2.16.0"
        },
        {
          "last_affected": "2.16.1"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "v2.16.0",
    "v2.16.1"
  ]
}
twig/twig Packagist
Ecosystem versions

From 3.9.0 before 3.26.0

Fixed in 3.26.0

32 explicitly affected versions

v3.10.0, v3.10.1, v3.10.2, v3.10.3, v3.11.0, v3.11.1, v3.11.2, v3.11.3, v3.12.0, v3.13.0, v3.14.0, v3.14.1, v3.14.2, v3.15.0, v3.16.0, v3.17.0, v3.17.1, v3.18.0, v3.19.0, v3.20.0, v3.21.0, v3.21.1, v3.22.0, v3.22.1, v3.22.2, v3.23.0, v3.24.0, v3.25.0, v3.9.0, v3.9.1, v3.9.2, v3.9.3

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "3.9.0"
        },
        {
          "fixed": "3.26.0"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "v3.10.0",
    "v3.10.1",
    "v3.10.2",
    "v3.10.3",
    "v3.11.0",
    "v3.11.1",
    "v3.11.2",
    "v3.11.3",
    "v3.12.0",
    "v3.13.0",
    "v3.14.0",
    "v3.14.1",
    "v3.14.2",
    "v3.15.0",
    "v3.16.0",
    "v3.17.0",
    "v3.17.1",
    "v3.18.0",
    "v3.19.0",
    "v3.20.0",
    "v3.21.0",
    "v3.21.1",
    "v3.22.0",
    "v3.22.1",
    "v3.22.2",
    "v3.23.0",
    "v3.24.0",
    "v3.25.0",
    "v3.9.0",
    "v3.9.1",
    "v3.9.2",
    "v3.9.3"
  ]
}

References