Closed Bug 559172 (WH-3768445) Opened 16 years ago Closed 16 years ago

Reflected XSS on tiki-list_file_gallery.php due to lack of Output Encoding

Categories

(support.mozilla.org :: Mobile, task)

task
Not set
critical

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: mcoates, Assigned: paulc)

References

()

Details

(Keywords: wsec-xss, Whiteboard: [WH-3768445][infrasec:xss])

Attachments

(1 file, 3 obsolete files)

Issue A reflected cross site scripting vulnerability is present within https://mobile.support.mozilla.com/tiki-list_file_gallery.php. Data accepted from the user via URL parameters are returned within the HTML response without appropriate HTML encoding. Note: Tiki-wiki using blacklist filtering to make XSS attacks difficult; however, this filtering should not be relied upon to prevent all XSS variations. The root cause identified in this bug needs to be fixed. Recommended Remediation The primary recommendation is to perform HTML entity encoding on any user supplied data that is returned within the HTML response. In this case, the data obtained from the "file_find" URL parameter. In addition, perform input validation against the file_find field to limit the types of characters which are accepted by the application. Utilize a positive approach where acceptable character types are defined. If data does not match this "positive" filter then the entire data string is rejected. Proof of Concept 1. Login with a valid account 2. Follow the url below https://mobile.support.mozilla.com/tiki-list_file_gallery.php?galleryId=1&file_find=%00%22whscheck=%22whscheck&search=Find&file_sort_mode=created_desc 3. View the source of the page and observe that the user supplied data has broken out of the href attribute. e.g. <a class="tableheading" href="/tiki-list_file_gallery.php?galleryId=1&amp;file_find="whscheck="whscheck&amp;file_sort_mode=fileId_desc">ID</a> An attacker can refine the input to inject a XSS attack.
I believe a patch for this exists in the desktop version. Will find it and apply it to the mobile branch.
Assignee: nobody → james
Target Milestone: --- → 1.5.4
Alias: WH-3768445
I've reproduced this bug locally on trunk, and looking at svn history, I don't see any changes made to list-file_gallery and included templates or the main php file. This patch just escapes the $find variable in the template.
Assignee: james → paulc
Attachment #438863 - Flags: review?(james)
Same as previous patch except uses escape:'url' inside links, which... is everywhere it wasn't escaped.
Attachment #438863 - Attachment is obsolete: true
Attachment #438870 - Flags: review?(james)
Attachment #438863 - Flags: review?(james)
Comment on attachment 438870 [details] [diff] [review] v2, explicitly escape:'url' when inside href="" >Index: webroot/templates/list_file_gallery.tpl >=================================================================== >--- webroot/templates/list_file_gallery.tpl (revision 65770) >+++ webroot/templates/list_file_gallery.tpl (working copy) >@@ -37,60 +37,60 @@ > <td class="heading">&nbsp;</td> > {/if} > {if $gal_info.show_id eq 'y'} >- <td class="heading"><a class="tableheading" href="{$smarty.server.PHP_SELF}?galleryId={$gal_info.galleryId}{if isset($file_info)}&amp;fileId={$file_info.fileId}{/if}{if $offset ne 0}&amp;{$ext}offset={$offset}{/if}{if $find}&amp;{$ext}find={$find}{/if}{if isset($page)}&amp;page={$page}{/if}&amp;{$ext}sort_mode={if $sort_mode eq 'fileId_desc'}fileId_asc{else}fileId_desc{/if}{if $filegals_manager eq 'y'}&filegals_manager{/if}">{tr}ID{/tr}</a></td> >+ <td class="heading"><a class="tableheading" href="{$smarty.server.PHP_SELF}?galleryId={$gal_info.galleryId}{if isset($file_info)}&amp;fileId={$file_info.fileId}{/if}{if $offset ne 0}&amp;{$ext}offset={$offset}{/if}{if $find}&amp;{$ext}find={$find|escape:'url'}{/if}{if isset($page)}&amp;page={$page|escape}{/if}&amp;{$ext}sort_mode={if $sort_mode eq 'fileId_desc'}fileId_asc{else}fileId_desc{/if}{if $filegals_manager eq 'y'}&filegals_manager{/if}">{tr}ID{/tr}</a></td> Please also escape the other parameters here: $gal_info.galleryId, $file_info.fileId, $offset, $ext, and fix $page|escape. ($smarty.server.PHP_SELF should be fine, as it's set by PHP.) There may well be other un- or improperly- escaped variables in URLs. You should grab them all while you're in here.
Attachment #438870 - Flags: review?(james) → review-
Attached patch more and more escapes (obsolete) — Splinter Review
As per your wise request, I escaped almost everything and also fixed some |escape typos, mostly for $page.
Attachment #438870 - Attachment is obsolete: true
Attachment #438907 - Flags: review?(james)
Comment on attachment 438907 [details] [diff] [review] more and more escapes Your enthusiasm for escaping is good. Unfortunately, in your fervor you've encoded paths that will now break.
Attachment #438907 - Flags: review?(james) → review-
No more path escaping. Also checked that we don't use these features, just ftr.
Attachment #438907 - Attachment is obsolete: true
Attachment #438910 - Flags: review?(james)
Comment on attachment 438910 [details] [diff] [review] same as previous, but doesn't escape $download_path and $url_path It's still a little aggressive but since we're not using this feature, safe > functional.
Attachment #438910 - Flags: review?(james) → review+
r65795 on fennec branch.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Thanks! Marked for retest in Sentinel
(In reply to comment #10) > Thanks! Marked for retest in Sentinel This change has only been pushed to our staging server. See my comments in bug 556544.
Reopening bug. Will close when fix is confirmed in production.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
We don't push to production until it's VERIFIED.
Status: REOPENED → RESOLVED
Closed: 16 years ago16 years ago
Resolution: --- → FIXED
Loading https://mobile-support-stage.mozilla.com/tiki-list_file_gallery.php?galleryId=1&file_find=%22whscheck%3D%22whscheck&search=Find&file_sort_mode=created_desc, I now see: <td class="heading"><a class="tableheading" href="/tiki-list_file_gallery.php?galleryId=1&amp;file_find=%22whscheck%3D%22whscheck&amp;file_sort_mode=fileId_desc">ID</a> Verified FIXED (as I understand it); Michael, mind double-checking on staging? Thanks!
That looks correct to me. I don't have access to stage (just requested it), but what I see in comment 14 looks like the correct behavior.
Thx; verified.
Status: RESOLVED → VERIFIED
(In reply to comment #15) > That looks correct to me. I don't have access to stage (just requested it), > but what I see in comment 14 looks like the correct behavior. You don't need access to our staging servers. The password prompt is just to keep search crawlers out: the username/password is "support"/"stage".
Whiteboard: [WH-3768445] → [WH-3768445][infrasec:xss]
Adding keywords to bugs for metrics, no action required. Sorry about bugmail spam.
Keywords: wsec-xss
These bugs are all resolved, so I'm removing the security flag from them.
Group: websites-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: