{"id":"CVE-2021-4236","aliases":["EUVD-2022-7668","GHSA-5gjg-jgh4-gppm","GHSA-jpgg-cp2x-qrw3","GO-2021-0107"],"status":"published","title":"Panic or authentication bypass in github.com/ecnepsnai/web","description":"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.","severity":{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-10","score":0.01191,"percentile":0.68233,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-304","CWE-400","CWE-476"],"published":"2021-06-23T17:26:30Z","modified":"2026-10-20T10:55:00Z","fixes":[{"ecosystem":"Go","package":"github.com/ecnepsnai/web","fixed_in":["1.5.2"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"Go","package":"github.com/ecnepsnai/web","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"1.4.0"},{"fixed":"1.5.2"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/ecnepsnai/web","ranges":[{"type":"SEMVER","events":[{"introduced":"1.4.0"},{"fixed":"1.5.2"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/ecnepsnai/web","ranges":[{"type":"SEMVER","events":[{"introduced":"1.4.0"},{"fixed":"1.5.2"}]}]}],"products":[{"vendor":"github.com/ecnepsnai/web","product":"github.com/ecnepsnai/web"},{"vendor":"web_project","product":"web"}],"references":[{"url":"https://github.com/ecnepsnai/web/commit/5a78f8d5c41ce60dcf9f61aaf47a7a8dc3e0002f","tags":["x_transferred","Patch","Third Party Advisory","fix","web"]},{"url":"https://pkg.go.dev/vuln/GO-2021-0107","tags":["x_transferred","Exploit","Patch","Third Party Advisory","fix","web"]},{"url":"https://github.com/ecnepsnai/web/security/advisories/GHSA-5gjg-jgh4-gppm","tags":["web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-4236","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-5gjg-jgh4-gppm"},{"url":"https://github.com/advisories/GHSA-jpgg-cp2x-qrw3"},{"url":"https://github.com/ecnepsnai/web","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-4236","title":"Panic or authentication bypass in github.com/ecnepsnai/web","description":"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.","status":"published","published":"2022-12-27T21:13:45.711Z","modified":"2025-04-11T16:20:55.821Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"adp"}],"updated_at":"2026-11-02T14:33:08.045407Z"}],"euvd":[{"id":"EUVD-2022-7668","description":"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.","status":"published","published":"2022-12-27T21:13:45Z","modified":"2025-04-11T16:20:55Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T20:52:34.493984Z"}],"ghsa":[{"id":"GHSA-5gjg-jgh4-gppm","title":"Websocket requests did not call AuthenticateMethod","description":"### 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.","status":"published","published":"2021-06-23T17:26:30Z","modified":"2026-01-23T22:35:57Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-304","CWE-400","CWE-476"],"updated_at":"2026-11-02T14:39:19.525691Z"},{"id":"GHSA-jpgg-cp2x-qrw3","title":"Duplicate Advisory: ecnepsnai/web vulnerable to Uncontrolled Resource Consumption","description":"## 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.","status":"withdrawn","published":"2022-12-28T00:30:23Z","modified":"2026-01-23T22:35:49Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-400","CWE-476"],"updated_at":"2026-11-02T14:39:19.525691Z"}],"nvd":[{"id":"CVE-2021-4236","description":"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.","status":"published","published":"2022-12-27T22:15:12.013Z","modified":"2026-06-17T04:19:19.493Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"primary"},{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"secondary"}],"cwes":["CWE-476"],"updated_at":"2026-11-02T14:07:07.323379Z"}],"osv":[{"id":"CVE-2021-4236","description":"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.","status":"published","published":"2022-12-27T22:15:12.013Z","modified":"2026-10-20T10:55:00.805132635Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T15:44:21.557945Z"},{"id":"GHSA-5gjg-jgh4-gppm","title":"Websocket requests did not call AuthenticateMethod","description":"### 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.","status":"published","published":"2021-06-23T17:26:30Z","modified":"2026-02-03T03:08:03.985538Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-304","CWE-400","CWE-476"],"updated_at":"2026-11-02T15:46:38.213481Z"},{"id":"GHSA-jpgg-cp2x-qrw3","title":"Duplicate Advisory: ecnepsnai/web vulnerable to Uncontrolled Resource Consumption","description":"## 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.","status":"withdrawn","published":"2022-12-28T00:30:23Z","modified":"2026-02-03T03:08:10.772864Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-400","CWE-476"],"updated_at":"2026-11-02T15:46:50.687609Z"},{"id":"GO-2021-0107","title":"Panic or authentication bypass in github.com/ecnepsnai/web","description":"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.\n\nThis issue only affects WebSockets with an AuthenticateMethod hook. Request handlers that do not explicitly use WebSockets are not vulnerable.","status":"published","published":"2021-07-28T18:08:05Z","modified":"2024-05-20T16:03:47Z","updated_at":"2026-11-02T15:47:00.604718Z"}]}}
