{"id":"CVE-2021-4236","aliases":["CVE-2021-4236","GHSA-5gjg-jgh4-gppm","GHSA-jpgg-cp2x-qrw3","GO-2021-0107"],"related":[],"kind":"vulnerability","state":"published","title":"Panic or authentication bypass in github.com/ecnepsnai/web","summary":"Web Sockets do not execute any AuthenticateMethod methods which may be set, leading to a nil pointer dereference if the returned UserData pointer is assumed to be non-nil, or authentication bypass. This issue only affects WebSockets with an AuthenticateMethod hook. Request handlers that do not explicitly use WebSockets are not vulnerable.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Web Sockets do not execute any AuthenticateMethod methods which may be set, leading to a nil pointer dereference if the returned UserData pointer is assumed to be non-nil, or authentication bypass. This issue only affects WebSockets with an AuthenticateMethod hook. Request handlers that do not explicitly use WebSockets are not vulnerable.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nDepending on implementation, a denial-of-service or privilege escalation vulnerability may occur in software that uses the `github.com/ecnepsnai/web` package with Web Sockets that have an AuthenticateMethod.\n\nThe `AuthenticateMethod` is not called, and `UserData` will be nil in request methods. Attempts to read the `UserData` may result in a panic.\n\nThis issue only affects web sockets where an `AuthenticateMethod` is supplied to the handle options. Users who do not use web sockets, or users who do not require authentication are not at risk.\n\n#### Example\n\nIn the example below, one would expect that the `AuthenticateMethod` function would be called for each request to `/example`\n\n```go\nhandleOptions := web.HandleOptions{\n\tAuthenticateMethod: func(request *http.Request) interface{} {\n\t\t// Assume there is logic here to check for an active sessions, look at cookies or headers, etc...\n\t\tvar session Session{} // Example\n\n\t\treturn session\n\t},\n}\n\nserver.Socket(\"/example\", handle, handleOptions)\n```\n\nHowever, the method is not called, and therefor the `UserData` parameter of the request object in the handle will be nil, when it would have been expected to be the `session` object we returned.\n\n### Patches\n\nRelease v1.5.2 fixes this vulnerability. The authenticate method is now called for websocket requests.\n\nAll users of the web package should update to v1.5.2 or later.\n\n### Workarounds\n\nYou may work around this issue by making the authenticate method a named function, then calling that function at the start of the handle method for the websocket. Reject connections when the return value of the method is nil.","format":"markdown","source":"ghsa"},{"lang":"en","text":"## Duplicate Advisory\nThis advisory has been withdrawn because it is a duplicate of GHSA-5gjg-jgh4-gppm. This link is maintained to preserve external references.\n\n## Original Description\nWeb Sockets do not execute any AuthenticateMethod methods which may be set, leading to a nil pointer dereference if the returned UserData pointer is assumed to be non-nil, or authentication bypass. This issue only affects WebSockets with an AuthenticateMethod hook. Request handlers that do not explicitly use WebSockets are not vulnerable.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Web Sockets no ejecuta ningún método AuthenticateMethod que pueda configurarse, lo que lleva a una desreferencia del puntero null si se supone que el puntero UserData devuelto no es null, o a una omisión de autenticación. Este problema solo afecta a WebSockets con un enlace AuthenticateMethod. Los controladores de solicitudes que no utilizan WebSockets explícitamente no son vulnerables.","source":"nvd"}],"published":"2021-06-23T17:26:30.000Z","modified":"2026-06-17T04:19:19.493Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-304","CWE-400","CWE-476"],"affected":[{"ranges":[{"type":"semver","introduced":"1.4.0","fixed":"1.5.2","status":"affected"}],"vendor":"github.com/ecnepsnai/web","product":"github.com/ecnepsnai/web","package":"github.com/ecnepsnai/web","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.4.0","status":"affected","fixed":"1.5.2"}],"ecosystem":"Go","package":"github.com/ecnepsnai/web","purl":"pkg:golang/github.com/ecnepsnai/web","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.4.0","status":"affected","fixed":"1.5.2"}],"ecosystem":"Go","package":"github.com/ecnepsnai/web","purl":"pkg:golang/github.com/ecnepsnai/web","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.4.0","status":"affected","fixed":"1.5.2"}],"ecosystem":"Go","package":"github.com/ecnepsnai/web","purl":"pkg:golang/github.com/ecnepsnai/web","source":"go"},{"ranges":[{"status":"affected","introduced":"1.4.0","fixed":"1.5.2"}],"vendor":"web_project","product":"web","cpe":"cpe:2.3:a:web_project:web:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ecnepsnai/web/commit/5a78f8d5c41ce60dcf9f61aaf47a7a8dc3e0002f","tags":["fix","patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://pkg.go.dev/vuln/GO-2021-0107","tags":["exploit","patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ecnepsnai/web/security/advisories/GHSA-5gjg-jgh4-gppm","tags":["web"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4236","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ecnepsnai/web","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"Go","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"total","date":"2025-04-11T16:20:37.403Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-4236","url":"https://www.cve.org/CVERecord?id=CVE-2021-4236","licence":"CVE Terms of Use","modified":"2025-04-11T16:20:55.821Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5gjg-jgh4-gppm","url":"https://github.com/advisories/GHSA-5gjg-jgh4-gppm","licence":"CC-BY-4.0","modified":"2026-02-03T03:08:03.985Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jpgg-cp2x-qrw3","url":"https://github.com/advisories/GHSA-jpgg-cp2x-qrw3","licence":"CC-BY-4.0","modified":"2026-02-03T03:08:10.772Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2021-0107","url":"https://pkg.go.dev/vuln/GO-2021-0107","licence":"CC-BY-4.0","modified":"2024-05-20T16:03:47.000Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-4236","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4236","licence":"Public domain","modified":"2026-06-17T04:19:19.493Z"}],"updatedAt":"2026-11-25T22:58:08.019Z","epss":{"score":0.01215,"percentile":0.69444,"date":"2026-12-02T12:00:21.000Z"}}