Closed Bug 979884 Opened 12 years ago Closed 12 years ago

xss on tbpl in rev param

Categories

(Tree Management Graveyard :: TBPL, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: curtisk, Assigned: emorley)

References

Details

(Keywords: reporter-external, Whiteboard: [site:tbpl.mozilla.org][reporter-external])

Attachments

(4 files)

Date: Tue, 4 Mar 2014 06:57:33 +0530 Message-ID: <CA+LKR=v+Nz6R_=knAEHqz0VOQmfVcFjp6Ec+URK7Rk5V65bmng@mail.gmail.com> Subject: XSS vulnerability on tbpl.mozilla.org From: Deepankar Arora <codeinjector007@gmail.com> To: security@mozilla.org -----//----- Hi, tbpl.mozilla.org suffers from a cross-site scripting vulnerability due to failure to sanitize the user input. Proof of concept: https://tbpl.mozilla.org/?tree=Try&rev="><img%20src%3Dx%20onerror%3Dalert%282%29%3B> As it shows, the value of rev parameter is not filtered and the script is executed. Thanks, Deepankar Arora
confirmed
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: sec-bounty?
Whiteboard: [site:tbpl.mozilla.org][reporter-external]
Assignee: nobody → ctalbert
Any update on this one?
Flags: needinfo?(ctalbert)
tbpl is not on the list of eligible systems. we do not use *.mozilla.org cookies, that helps re mediate any issues with cookie stealing from this domain.
Flags: sec-bounty? → sec-bounty-
Ed Morley or David Burns will look into this and get us a fix.
Flags: needinfo?(ctalbert) → needinfo?(emorley)
Looking now. (Didn't get the bugmail for this bug being filed, even though I'm watching this component, since I don't have s-s-webtools permissions)
Assignee: ctalbert → emorley
Status: NEW → ASSIGNED
Flags: needinfo?(emorley)
To add to comment 3, the worst that I can come up with for this so far (other than people using a JS 0-day, but I doubt anyone would click on a link that long) is stealing the sheriff password using for controlling the visibility of jobs, presuming someone has it autofill by their password manager (eg https://tbpl.mozilla.org/?tree=Try&rev=%22%3E%3Cimg%20src%3Dx%20onerror%3Dalert%28%24%28%22%23password%22%29.val%28%29%29%3B%3E ; and any changes using said password are reversible & the password is a shared one that 100+ people have access to already). Other than caching a nickname for commenting, the "match server timezone" pref & the tree MRU list, TBPL doesn't store any other data in localstorage or cookies.
(TBPL doesn't have a persistent login for which session state can be stolen)
(Breaking these up a bit to make the diffs clearer)
Attachment #8404874 - Flags: review?(arpad.borsos)
Currently we do unnecessary work if document.location.search == "?". By stripping the leading '?' early we avoid this and more importantly IMO make this block easier to read.
Attachment #8404878 - Flags: review?(arpad.borsos)
Attachment #8404874 - Flags: review?(arpad.borsos) → review+
Attachment #8404878 - Flags: review?(arpad.borsos) → review+
Attachment #8404879 - Flags: review?(arpad.borsos) → review+
All over the UI we treat the revision as trusted & don't escape it, even though the params weren't validated. We got away with this until now, since the only place those params ended up were as part of the hgwebjson fetch, which would fail if passed invalid params, which would mean we don't proceed with the rest of the app load & didn't have a pushlog response to handle. However with bug 721152 a failed pushlog load resulted in us falling back to the provided revision & proceeding with app load. I think the best solution for now is just to sanitise all params to avoid unintended side-effects by seemingly innocuous changes (I'd thought the change in bug 721152 was safe, since we didn't perform any validation in the $.ajax() success case either). The only param for which we may later need to tweak the regexp is 'pusher' - though I processed the last 5000 Try pushes to check that all email addresses used passed the current regexp, which they did.
Attachment #8404885 - Flags: review?(arpad.borsos)
For clarity, [\w\-.+@] expands to: A-Za-z0-9_-.+@
Joel, in this bug I'm adding some fairly strict validation of query string parameters. For the &fromchange=/&tochange= queries that you perform, what syntax do you use? The regexp I've chosen (comment 12) will handle dates that use a hyphen delimiter, but not forward slash. In addition, colon isn't in the list, so times won't work. Is this an issue?
Flags: needinfo?(jmaher)
thanks Ed for checking with me. My common use cases of tbpl are these type of examples: * https://tbpl.mozilla.org/?tree=Fx-Team&fromchange=1af4ac38f025&tochange=67e72ea05f66&jobname=Ubuntu%20HW%2012.04%20fx-team%20talos%20svgr * https://tbpl.mozilla.org/?tree=Fx-Team&rev=67e72ea05f66 * https://tbpl.mozilla.org/?tree=Fx-Team&startdate=2014-04-04&enddate=2014-04-06&jobname=fx-team%20talos%20svgr fromchange/tochange is used in the first item and it is only revisions. I have never used a / unless it was part of a jobname or branchname (i don't think it is)
Flags: needinfo?(jmaher)
Attachment #8404885 - Flags: review?(arpad.borsos) → review+
Removing bug 835471 from blocks, since tinderbox != tinderboxpushlog. Tinderboxpushlog (aka TBPL) was formerly a consumer of tinderbox (hence the name), but now consumes buildbot data (amongst others) instead. (In reply to Joel Maher (:jmaher) from comment #14) > I have never used a / unless it was part of a jobname or branchname (i don't > think it is) Yeah the params supported (either the tree name or the buildbot equivalent) don't have forward slashes: https://hg.mozilla.org/webtools/tbpl/file/tip/js/Config.js#l38 (The keys under treeInfo and the value of buildbotBranch for each of them; primaryRepo is only used for pushlog paths etc)
Blocks: 721152
Depends on: 994909
In production :-)
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Group: webtools-security
Product: Webtools → Tree Management
Product: Tree Management → Tree Management Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: