CVE-2022-31186: Next auth Next-auth Before V4.10.2 And V3.29.9 Vulnerability

LOW
Advisory Identifier: GHSA-p6mm-27gq-9v3p
CVSS 3.3
CWE-532
Published
Advisory Summary

CVE-2022-31186 is a LOW (CVSS 3.3) next-auth before v4.10.2 and v3.29.9 vulnerability (CWE-532: Insertion of Sensitive Information into Log File) affecting Next auth libraries in the npm ecosystem. The issue involves next-auth before v4.10.2 and v3.29.9 leaks excessive information into log. Remediation is available by upgrading affected packages to version 3.29.9, 4.10.2.

CVE-2022-31186 at a Glance

CVE Identifier CVE-2022-31186
GHSA Identifier GHSA-p6mm-27gq-9v3p
Severity LOW
CVSS v3.1 Base Score 3.3
CWE Classification CWE-532: Insertion of Sensitive Information into Log File
Affected Product Next auth
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 3.3

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

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
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-2022-31186

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

next-auth fixed: 3.29.9
npm install next-auth@3.29.9
next-auth fixed: 4.10.2
npm install next-auth@4.10.2
Verify Direct and Transitive Dependencies

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

npm ls next-auth

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-31186, inspect your project dependencies using npm:

npm ls next-auth

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

Note: The npm ls next-auth command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-532: Insertion of Sensitive Information into Log File, where the product writes sensitive information to a log file. In Next auth, 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

### Impact An information disclosure vulnerability in `next-auth` before `v4.10.2` and `v3.29.9` allows an attacker with log access privilege to obtain excessive information such as an identity provider's secret in the log (which is thrown during OAuth error handling) and use it to leverage further attacks on the system, like impersonating the client to ask for extensive permissions. ### Patches We patched this vulnerability in `v4.10.2` and `v3.29.9` by moving the log for `provider` information to the debug level. In addition, we added a warning for having the `debug: true` option turned on in production and documented it [here](https://next-auth.js.org/warnings#debug_enabled). > You have enabled the debug option. It is meant for development only, to help you catch issues in your authentication flow and you should consider removing this option when deploying to production. One way of only allowing debugging while not in production is to set debug: process.env.NODE_ENV !== "production", so you can commit this without needing to change the value. > > If you want to log debug messages during production anyway, we recommend setting the [logger option](https://next-auth.js.org/configuration/options#logger) with proper sanitization of potentially sensitive user information. To upgrade: ```sh npm i next-auth@latest # or yarn add next-auth@latest # or pnpm add next-auth@latest ``` (This will update to the latest v4 version, but you can change `latest` to 3 if you want to stay on v3. This is not recommended. v3 is unmaintained.) ### Workarounds If for some reason you cannot upgrade, you can user the `logger` configuration option by sanitizing the logs: ```ts // Example import log from "your-logging-service" export const authOptions: NextAuthOptions = { debug: process.env.NODE_ENV !== "production", logger: { error: (code, metadata) => { if (!(metadata instanceof Error) && metadata.provider) { // redact the provider secret here delete metadata.provider log.error(code, metadata) } else { log.error(code, metadata) } } }, } ``` ### References Related documentation: - https://next-auth.js.org/warnings#debug_enabled - https://next-auth.js.org/configuration/options#logger - https://next-auth.js.org/getting-started/upgrade-v4 ### For more information If you have any concerns, we request responsible disclosure, outlined here: https://next-auth.js.org/security#reporting-a-vulnerability ### Timeline The issue was reported 18th of July, a response was sent out in less than 20 minutes and after identifying the issue a patch was published within a week.

CVE-2022-31186 Affected Next auth Versions

2 component(s)
Fixed Versions:
3.29.94.10.2
Product / Package Ecosystem Affected Versions Fixed Version
next-auth
npm
< 3.29.9
3.29.9
next-auth
npm
≥ 4.0.0
< 4.10.2
4.10.2

References

Frequently Asked Questions

What is CVE-2022-31186?
CVE-2022-31186 is a security vulnerability in Next auth involving next-auth before v4.10.2 and v3.29.9 leaks excessive information into log under CWE-532: Insertion of Sensitive Information into Log File.
Which Next auth versions are affected?
Affected versions include releases prior to 3.29.9, 4.10.2 across affected packages: next-auth.
What version fixes CVE-2022-31186?
Upgrading to 3.29.9, 4.10.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is next-auth affected?
Yes, next-auth is affected in releases prior to 3.29.9, 4.10.2. Upgrade your dependency to 3.29.9, 4.10.2 or later.
What is the CVSS score of CVE-2022-31186?
CVE-2022-31186 has a CVSS v3.1 base score of 3.3 (LOW) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2022-31186?
CVE-2022-31186 is classified under CWE-532: Insertion of Sensitive Information into Log File (The product writes sensitive information to a log file.).
How can I check npm dependencies for CVE-2022-31186?
Run the dependency tree command: 'npm ls next-auth'. 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-p6mm-27gq-9v3p",
  "modified" : "2022-08-06T05:29:45Z",
  "published" : "2022-08-06T05:29:45Z",
  "aliases" : [ "CVE-2022-31186" ],
  "summary" : "next-auth before v4.10.2 and v3.29.9 leaks excessive information into log",
  "details" : "### Impact\nAn information disclosure vulnerability in `next-auth` before `v4.10.2` and `v3.29.9` allows an attacker with log access privilege to obtain excessive information such as an identity provider's secret in the log (which is thrown during OAuth error handling) and use it to leverage further attacks on the system, like impersonating the client to ask for extensive permissions.\n\n### Patches\nWe patched this vulnerability in `v4.10.2` and `v3.29.9` by moving the log for `provider` information to the debug level. In addition, we added a warning for having the `debug: true` option turned on in production and documented it [here](https://next-auth.js.org/warnings#debug_enabled).\n> You have enabled the debug option. It is meant for development only, to help you catch issues in your authentication flow and you should consider removing this option when deploying to production. One way of only allowing debugging while not in production is to set debug: process.env.NODE_ENV !== \"production\", so you can commit this without needing to change the value.\n> \n> If you want to log debug messages during production anyway, we recommend setting the [logger option](https://next-auth.js.org/configuration/options#logger) with proper sanitization of potentially sensitive user information.\n\nTo upgrade:\n\n```sh\nnpm i next-auth@latest\n# or\nyarn add next-auth@latest\n# or\npnpm add next-auth@latest\n```\n(This will update to the latest v4 version, but you can change `latest` to 3 if you want to stay on v3. This is not recommended. v3 is unmaintained.)\n\n### Workarounds\n\nIf for some reason you cannot upgrade, you can user the `logger` configuration option by sanitizing the logs:\n```ts\n// Example\nimport log from \"your-logging-service\"\nexport const authOptions: NextAuthOptions = {\n  debug: process.env.NODE_ENV !== \"production\",\n  logger: {\n    error: (code, metadata) => {\n      if (!(metadata instanceof Error) &&  metadata.provider) {\n        // redact the provider secret here\n        delete metadata.provider\n        log.error(code, metadata)\n      } else {\n        log.error(code, metadata)\n      }\n    }\n  },\n}\n```\n\n### References\nRelated documentation:\n- https://next-auth.js.org/warnings#debug_enabled\n- https://next-auth.js.org/configuration/options#logger \n- https://next-auth.js.org/getting-started/upgrade-v4\n\n### For more information\nIf you have any concerns, we request responsible disclosure, outlined here: https://next-auth.js.org/security#reporting-a-vulnerability\n\n### Timeline\nThe issue was reported 18th of July, a response was sent out in less than 20 minutes and after identifying the issue a patch was published within a week.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "next-auth"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.29.9"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "next-auth"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.10.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nextauthjs/next-auth/security/advisories/GHSA-p6mm-27gq-9v3p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31186"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nextauthjs/next-auth"
  }, {
    "type" : "WEB",
    "url" : "https://next-auth.js.org/configuration/options#logger"
  }, {
    "type" : "WEB",
    "url" : "https://next-auth.js.org/getting-started/upgrade-v4"
  }, {
    "type" : "WEB",
    "url" : "https://next-auth.js.org/warnings#debug_enabled"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-532" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-06T05:29:45Z",
    "nvd_published_at" : "2022-08-01T20:15:00Z"
  }
}