CVE-2022-31186: Next auth Next-auth Before V4.10.2 And V3.29.9 Vulnerability
LOWCVE-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
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).
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.
npm install next-auth@3.29.9
npm install next-auth@4.10.2
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
CVE-2022-31186 Affected Next auth Versions
2 component(s)| 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?
Which Next auth versions are affected?
What version fixes CVE-2022-31186?
Is next-auth affected?
What is the CVSS score of CVE-2022-31186?
What CWE is associated with CVE-2022-31186?
How can I check npm dependencies for CVE-2022-31186?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}