The vulnerability exists in Spring Security's mechanism for detecting security annotations on methods, specifically when dealing with generic type hierarchies. The root cause is a bug in the org.springframework.security.core.annotation.UniqueSecurityAnnotationScanner.hasSameGenericTypeParameters method. This method incorrectly compared method signatures when a method in a subclass inherited from a superclass with unbounded generic parameters. The use of ResolvableType.resolve() returned null for these generics, causing the method matching to fail.
This bug is exposed through the public scan method of the UniqueSecurityAnnotationScanner. When an application using @EnableMethodSecurity tries to secure a method that falls into this specific generic inheritance scenario, the scan method is called to find the security annotations (like @PreAuthorize). Due to the bug in hasSameGenericTypeParameters, the scan method fails to find the annotation and returns no security metadata. This leads to Spring Security treating the method as if it has no security constraints, resulting in a complete authorization bypass.
The patch addresses the issue by changing .resolve() to .toClass(). This ensures that even if a generic type is unbounded, it is resolved to java.lang.Object, allowing the method comparison to succeed and the security annotation to be correctly identified. Therefore, both the scan method (the entry point) and the hasSameGenericTypeParameters method (the location of the bug) are critical to understanding this vulnerability.