The vulnerability exists in the Rack::Static middleware, specifically within the applicable_rules method. This method is responsible for determining which header_rules should be applied to a given request path. The vulnerability arises because this method was performing its checks on the raw, URL-encoded path from the request. However, the underlying file serving mechanism would decode the path before accessing the file. This discrepancy allowed an attacker to bypass header rules by crafting a URL with encoded characters. For example, a request for /fonts/test%2Ewoff would be served as /fonts/test.woff, but the header rules that should have been applied to .woff files would not be triggered because the check was performed on the encoded string.
The patch, found in commit 4207d22e58a41d57a2c6e1ed2602170504b000c7, addresses this by decoding the path using ::Rack::Utils.unescape_path(path) at the very beginning of the applicable_rules method. This ensures that all subsequent rule matching is performed on the canonical, decoded path, closing the bypass vulnerability. The primary vulnerable function is therefore Rack::Static.applicable_rules.