Skip to content

Commit b908ed4

Browse files
committed
Improper-markup-sanitization: disclose Bitbucket XSS
1 parent 950b2a3 commit b908ed4

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

Improper-markup-sanitization.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Improper markup sanitization in popular software
22

3-
_[Featuring](#affected-software): GitHub, GitLab, {TBA}, Redmine, Gogs, JetBrains, and others._
3+
_[Featuring](#affected-software): GitHub, GitLab, Bitbucket, Redmine, Gogs, JetBrains, and others._
44

55
There are several common markup (mostly Markdown) sanitization issues outlined in this article, but I would be mostly speaking about the single, most common one.
66

@@ -108,16 +108,17 @@ Those already existing event handlers could be used by the attacker to execute s
108108

109109
I have found and reported markup sanitization related issues in: \
110110
[GitHub](#github), [GitLab](#gitlab),
111-
_[TBA](#tba)_,
111+
[Bitbucket](#bitbucket),
112112
[Gogs](#gogs), [Gitea](#gitea), [Redmine](#redmine),
113113
_[TBA 2](#tba-2)_,
114114
[YouTrack](#youtrack),
115115
[Upsource](#upsource),
116116
[JIRA](#jira).
117117

118-
Of those, [TBA](#tba), [TBA 2](#tba-2), [YouTrack](#youtrack), and [Upsource](#upsource) issues are not related to unsanitized `class` atribute.
119-
Note that the █████ ██████ █████ █████ ███████ ███ █████████████ — █████████ ████ ███ ███████ ████ ██████ ██ ████████ ██████, ███ ███████ ███████ █████████ ██████
120-
████████████. ████ ███████ ███████ ████████ ████████████ ████████ ████, though, and ██████ ███ ██████ ███ ████ ██ ██ ████████ ███████ writeup.
118+
Of those, [Butbucket](#bitbucket), [TBA 2](#tba-2), [YouTrack](#youtrack), and [Upsource](#upsource) issues are not related to unsanitized `class` atribute.
119+
Note that the first two of those don't satisfy the [prerequisites](#introduction) — Bitbucket does not support HTML markup in Markdown at all, and
120+
███████ ███████ █████████ ██████ ████████████.
121+
They managed to fail markup sanitization in other ways, though, and that's the reason for them to be included in this writeup.
121122

122123
See below for the detailed vulnerabilities information, PoC examples and screenshots.
123124

@@ -240,26 +241,57 @@ Redmine (in default setup) has a relatively small number of css rules and a smal
240241

241242
The severity could be raised in presence of various Redmine plugins that include their own js/css to the page, and installing thirdparty plugins is pretty popular in Redmine ecosystem.
242243

243-
### TBA
244+
### Bitbucket
245+
246+
_Fixed at: 2017-06-20._
244247

245248
The issue here is different and is not related to `class` not being sanitized.
246249

247-
![XSS](/media/tba.xss.png)
250+
This is a full-featured XSS, with arbitrary JS code, achievable through issue comments (among other places).
248251

249-
This is a full-featured XSS, with arbitrary JS code, achievable through █████████████████████ █████████████.
252+
PoC 1, covers everything on the page with a div with an `onmouseover` event handler executing arbitrary JS code:
253+
```md
254+
The HTML specification is maintained by the W3C.
255+
*[HTML]: [Hyper Text Markup Language](http://example.com/bar/style='background:#fff;font-size:0;left:0;right:0;top:0;bottom:0;z-index:99990;position:fixed'#/onmouseover=alert('xss:'+document.cookie);")
256+
```
257+
258+
![XSS](/media/bitbucket.xss.png)
259+
260+
PoC 2:
261+
~~~md
250262

251-
PoC:
252-
```html
253-
TBA
254263
```
264+
#!lolcoad.0000123
265+
lol
266+
```
267+
~~~
255268

256-
_Details TBA._
269+
![XSS](/media/bitbucket.poc2.png)
270+
271+
I was surprised by the fact that Bitbucket does not use Content Security Policy at all (they said that they are in the process of adding it).
272+
273+
Note: Atlassian security team managed to disclose the XSS vulnerability before fixing it by testing the PoC in a public repo issues
274+
on their production server, soon after I reported the issue and provided the PoC privately, and it was public until I noticed that
275+
after 19 hours. Explanation was the following: «testing your PoC to make sure it was reproducible».
276+
_They acknowledged that it was accidential — the test repository itself was private, but its issue tracker
277+
was public. I was able to find my PoC in that public issue tracker, though.
278+
That repo permissions were fixed in an hour after I noticed that._
279+
280+
This issue has been passed to the development team after 50 days from the inital report.
281+
282+
An incomplete fix was deployed 57 days after the report — that covered only the first one of the originally reported PoCs
283+
(the other one did not execute arbitrary JS code, though).
257284

258-
██████████████████████████████████████████████████████████████████████████████████████.
285+
The complete fix was deployed after 78 days from the initial report.
259286

260-
Note: ███████████████████████ managed to disclose the XSS vulnerability before fixing it by testing the PoC in a pub███████████
261-
█████ production server, soon after I reported the issue and provided the PoC privately, and it was public until I noticed that
262-
after 19 hours.
287+
Timeline:
288+
* Discovered: 2017-04-03
289+
* Reported: 2017-04-03
290+
* Confirmed by Atlassian Security team: 2017-04-03
291+
* PoC leaked to a public repo issues by Atlassian Security team: 2017-04-03
292+
* Issue was assigned to the Bitbucket development team: 2017-05-23
293+
* Incomplete fix deployed (covered only the first PoC): 2017-05-30
294+
* Complete fix deployed: 2017-06-20
263295

264296
### TBA 2
265297

@@ -439,7 +471,7 @@ a good one, send me a link, I will include that link here.
439471
---
440472
441473
Published (partially): 2017-04-13, 9:01 UTC. \
442-
Updated with _TBA_ disclosure: _TBA_. \
474+
Updated with Bitbucket XSS disclosure: 2017-06-26 15:40 UTC. \
443475
Updated with _TBA 2_ disclosure: _TBA_. \
444476
Updated with YouTrack disclosure: 2017-04-25, 9:34 UTC.
445477

media/bitbucket.poc2.png

95.7 KB
Loading

media/bitbucket.xss.png

51.9 KB
Loading

media/tba.xss.png

-30 KB
Binary file not shown.

0 commit comments

Comments
 (0)