The vulnerability lies in the Rack::Sendfile.map_accel_path function, which handles path rewriting for Nginx's X-Accel-Redirect feature. The function reads path mappings from the X-Accel-Mapping HTTP request header. The root cause of the vulnerability is the failure to sanitize the value read from this header before using it in a regular expression. Specifically, the internal part of the mapping is used directly in path.sub(/\A#{internal}/i, external). An attacker can supply regex metacharacters (e.g., .*) in the X-Accel-Mapping header, which are then interpreted by the Ruby regex engine. This allows them to control the generated X-Accel-Redirect path and access files that are not meant to be public. The patch, identified in commit 7f288de93768b5cc44a5f4ed1ac02470d8fe52f4, resolves this by escaping the internal variable using Regexp.escape, ensuring it is treated as a literal string rather than a pattern.