Skip to content

Commit a8705e6

Browse files
committed
this fixes a DOM-Based XSS in the recent-uploads page: it was possible to execute arbitrary javascript by tricking someone into visiting `/?ru&filter=</script>` huge thanks to @Ju0x for finding and reporting this!
1 parent b7ca6f4 commit a8705e6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

copyparty/httpcli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
html_escape,
8282
humansize,
8383
ipnorm,
84+
json_hesc,
8485
justcopy,
8586
load_resource,
8687
loadpy,
@@ -5595,7 +5596,7 @@ def tx_rups(self) -> bool:
55955596
self.reply(jtxt.encode("utf-8", "replace"), mime="application/json")
55965597
return True
55975598

5598-
html = self.j2s("rups", this=self, v=jtxt)
5599+
html = self.j2s("rups", this=self, v=json_hesc(jtxt))
55995600
self.reply(html.encode("utf-8"), status=200)
56005601
return True
56015602

copyparty/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,10 @@ def find_prefix(ips: list[str], cidrs: list[str]) -> list[str]:
22532253
return ret
22542254

22552255

2256+
def json_hesc(s: str) -> str:
2257+
return s.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026")
2258+
2259+
22562260
def html_escape(s: str, quot: bool = False, crlf: bool = False) -> str:
22572261
"""html.escape but also newlines"""
22582262
s = s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")

0 commit comments

Comments
 (0)