CVE-2021-4236
criticalpriority · track · 39EPSS 0.012 · 68 %ileEUUSEPSS · scored 2026-10-27
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.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (3)
Products and version ranges known to be affected.
advisories (3)
Vendor and ecosystem advisories describing this.
- GHSA-5gjg-jgh4-gppmWebsocket requests did not call AuthenticateMethod2021-06-23ghsa · osvUS
### Impact Depending 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. The `AuthenticateMethod` is not called, and `UserData` will be nil in request methods. Attempts to read the `UserData` may result in a panic. This 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. #### Example In the example below, one would expect that the `AuthenticateMethod` function would be called for each request to `/example` ```go handleOptions := web.HandleOptions{ AuthenticateMethod: func(request *http.Request) interface{} { // Assume there is logic here to check for an active sessions, look at cookies or headers, etc... var session Session{} // Example return session }, } server.Socket("/example", handle, handleOptions) ``` However, 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. ### Patches Release v1.5.2 fixes this vulnerability. The authenticate method is now called for websocket requests. All users of the web package should update to v1.5.2 or later. ### Workarounds You 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.
- GHSA-jpgg-cp2x-qrw3Duplicate Advisory: ecnepsnai/web vulnerable to Uncontrolled Resource Consumption2022-12-28ghsa · osvUS
## Duplicate Advisory This advisory has been withdrawn because it is a duplicate of GHSA-5gjg-jgh4-gppm. This link is maintained to preserve external references. ## Original 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.
- GO-2021-0107Panic or authentication bypass in github.com/ecnepsnai/web2021-07-28vendor · osvUS
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.
also known as (7)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (8)
External citations — patches, advisories, analysis.
- https://cxsecurity.com/cveshow/CVE-2021-4236/cnnvd
- https://github.com/ecnepsnai/web/Patchcnnvd
- https://github.com/ecnepsnai/web/commit/5a78f8d5c41ce60dcf9f61aaf47a7a8dc3e0002fcnnvd
- https://pkg.go.dev/vuln/GO-2021-0107cnnvd
- https://github.com/ecnepsnai/web/commit/5a78f8d5c41ce60dcf9f61aaf47a7a8dc3e0002fenisa_euvd
- https://pkg.go.dev/vuln/GO-2021-0107enisa_euvd
- https://github.com/ecnepsnai/web/commit/5a78f8d5c41ce60dcf9f61aaf47a7a8dc3e0002fPatchThird Party Advisorynvd
- https://pkg.go.dev/vuln/GO-2021-0107ExploitPatchThird Party Advisorynvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan