The analysis of the provided commits clearly indicates that the session fixation vulnerability is located in the invoke method of the org.apache.catalina.valves.rewrite.RewriteValve class. The patches for CVE-2025-55668 across multiple Tomcat versions all point to the same change: replacing a direct call to response.sendRedirect() with response.sendRedirect(response.encodeRedirectURL(redirectPath)). This change is critical for preventing session fixation attacks when URL rewriting is used for session tracking.
The encodeRedirectURL method ensures that the session ID is properly appended to the redirect URL, maintaining session integrity. The vulnerable version of the invoke method failed to do this, allowing an attacker to inject a known session ID into a victim's browser. When the victim authenticates, the attacker can then use that same session ID to hijack the authenticated session.
The other change in the patch, making Request.recycleSessionInfo() public and calling it from the RewriteValve, is a secondary part of the fix to ensure that session information is properly cleared when handling cross-context requests within the rewrite valve, further hardening the session management logic. However, the primary vulnerable function is RewriteValve.invoke because it is the function that directly handles the vulnerable redirect logic.