CVE-2019-9942: Twig/twig Twig Sandbox Information Disclosure Vulnerability

LOW
Advisory Identifier: GHSA-vxrc-68xx-x48g
CVSS 3.7
CWE-200
Published
Advisory Summary

CVE-2019-9942 is a LOW (CVSS 3.7) twig sandbox information disclosure vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Twig/twig libraries in the Packagist ecosystem. The issue involves twig sandbox information disclosure. Remediation is available by upgrading affected packages to version 1.38.0, 2.7.0.

CVE-2019-9942 at a Glance

CVE Identifier CVE-2019-9942
GHSA Identifier GHSA-vxrc-68xx-x48g
Severity LOW
CVSS v3.1 Base Score 3.7
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Twig/twig
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 3.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2019-9942

To remediate this vulnerability, upgrade all affected Twig/twig dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

twig/twig fixed: 1.38.0
Upgrade twig/twig to 1.38.0
twig/twig fixed: 2.7.0
Upgrade twig/twig to 2.7.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for twig/twig

How to Check if You Are Affected

To determine whether your application is affected by CVE-2019-9942, inspect your project dependencies for Twig/twig:

inspect dependencies for twig/twig

Analyze the terminal output to locate any version of Twig/twig in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.38.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Twig/twig, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it is possible to call the `__toString()` method on an object even if not allowed by the security policy in place.

CVE-2019-9942 Affected Twig/twig Versions

2 component(s)
Fixed Versions:
1.38.02.7.0
Product / Package Ecosystem Affected Versions Fixed Version
twig/twig
Packagist
< 1.38.0
1.38.0
twig/twig
Packagist
≥ 2.0.0
< 2.7.0
2.7.0

References

Frequently Asked Questions

What is CVE-2019-9942?
CVE-2019-9942 is a security vulnerability in Twig/twig involving Twig Sandbox Information Disclosure under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Twig/twig versions are affected?
Affected versions include releases prior to 1.38.0, 2.7.0 across affected packages: twig/twig.
What version fixes CVE-2019-9942?
Upgrading to 1.38.0, 2.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is twig/twig affected?
Yes, twig/twig is affected in releases prior to 1.38.0, 2.7.0. Upgrade your dependency to 1.38.0, 2.7.0 or later.
What is the CVSS score of CVE-2019-9942?
CVE-2019-9942 has a CVSS v3.1 base score of 3.7 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2019-9942?
CVE-2019-9942 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check Packagist dependencies for CVE-2019-9942?
Run the dependency tree command: 'inspect dependencies for twig/twig'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vxrc-68xx-x48g",
  "modified" : "2023-09-21T19:49:03Z",
  "published" : "2022-03-26T00:25:25Z",
  "aliases" : [ "CVE-2019-9942" ],
  "summary" : "Twig Sandbox Information Disclosure",
  "details" : "A sandbox information disclosure exists in Twig before 1.38.0 and 2.x before 2.7.0 because, under some circumstances, it is possible to call the `__toString()` method on an object even if not allowed by the security policy in place.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "twig/twig"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.38.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "twig/twig"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-9942"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/twigphp/Twig/commit/eac5422956e1dcca89a3669a03a3ff32f0502077"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2019-9942.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/twigphp/Twig"
  }, {
    "type" : "WEB",
    "url" : "https://seclists.org/bugtraq/2019/Mar/60"
  }, {
    "type" : "WEB",
    "url" : "https://symfony.com/blog/twig-sandbox-information-disclosure"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2019/dsa-4419"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-03-26T00:25:25Z",
    "nvd_published_at" : "2019-03-23T15:29:00Z"
  }
}