Skip to content

Commit ed0f455

Browse files
jeremyevansioquatix
authored andcommitted
XSS injection via malicious filename in Rack::Directory.
Without this, if the file started with a URL scheme, it would not be treated as a relative link.
1 parent b29df31 commit ed0f455

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
44

5+
## Unreleased
6+
7+
### Security
8+
9+
- [CVE-2026-25500](https://github.com/advisories/GHSA-whrj-4476-wvmp) XSS injection via malicious filename in `Rack::Directory`.
10+
511
## [3.1.19] - 2025-11-03
612

713
### Fixed

lib/rack/directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Rack
1717
# If +app+ is not specified, a Rack::Files of the same +root+ will be used.
1818

1919
class Directory
20-
DIR_FILE = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>\n"
20+
DIR_FILE = "<tr><td class='name'><a href='./%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>\n"
2121
DIR_PAGE_HEADER = <<-PAGE
2222
<html><head>
2323
<title>%s</title>

test/spec_directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def setup
4646

4747
res.must_be :ok?
4848
assert_includes(res.body, '<html><head>')
49-
assert_includes(res.body, "href='cgi")
49+
assert_includes(res.body, "href='./cgi")
5050
end
5151

5252
it "serve directory indices" do

0 commit comments

Comments
 (0)