gallery.cnf leads to XSS · Issue #295 · owncloud/gallery · GitHub
Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

gallery.cnf leads to XSS #295

Closed
Closed

Description

@LukasReschke
---
# Gallery configuration file
information:
  description: This <script>alert(1)</script>is an **album description** which is only shown if there is no `description_link`
  copyright: Copyright 2003-2015 [interfaSys sàrl](javascript:alert(1\)), Switzerland
  inherit: yes
sorting:
  type: date
  order: des
  inherit: yes
features:
  external_shares: yes
  native_svg: yes

Personally I'd advise to remove this info stuff as it can easily lead to further security issues while offering few advantages.

cc @jancborchardt

Activity

  1. added this to the milestone on Sep 2, 2015
  2. oparoz commented on Sep 3, 2015

    @oparoz
    Contributor

    I'm not sure I understand. You're worried about drive-by exploits? Worse damage can be done via an installed app. A user has to have some trust into the links he follows.

  3. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    I'm not sure I understand. You're worried about drive-by exploits? Worse damage can be done via an installed app. A user has to have some trust into the links he follows.

    1. User "test" creates a gallery
    2. User "test" uploads above "gallery.cnf"
    3. User "test" shares the gallery with "admin"
    4. User "admin" access the gallery => JS is executed

    This is bad since if I can execute JS here I can do anything I want such as changing your password, accessing files, etc…

  4. oparoz commented on Sep 3, 2015

    @oparoz
    Contributor

    Yeah, internal shares are a problem... I'll add an HTML sanitizer.

  5. self-assigned this
    on Sep 3, 2015
  6. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    Yeah, internal shares are a problem... I'll add an HTML sanitizer.

    Sanitizers are evil. Please go with a sane markdown interpreter that has a whitelist of things it converts instead of some magic that might get bypassed ;)

  7. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    Especially since the only thing you need here are URLs which can be easily done yourself and you just need to check if it starts with http or https :)

  8. oparoz commented on Sep 3, 2015

    @oparoz
    Contributor

    I've selected a robust one, developed by security experts:
    https://github.com/cure53/DOMPurify

    I need more than links. Descriptions are written in markdown.

    There is one thing which worries me though

    DOMPurify will NOT protect you against HTTP leaks, meaning HTML that somehow requests external resources. There is too many ways of doing that and our tests showed that it cannot be done reliably. There is however plans to create a plugin that might get close to be able to do that. It is hard though.

    Btw, you're going to face the same issue when introducing markdown based descriptions in apps.

  9. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    I've selected a robust one, developed by security experts:
    https://github.com/cure53/DOMPurify

    Come on. That's not a proper solution. There have been 2 bypasses this year and we can solve it so easily reliable.

    I need more than links. Descriptions are written in markdown.

    No. What do you need exactly? It's maybe "strong", "cursive", "links" you can have this pretty secure by choosing a sane markdown implementation or writing one yourself.

    Btw, you're going to face the same issue when introducing markdown based descriptions in apps.

    No. We're not. It's quite easy. Just use a markdown parser with a sane whitelist. Everything else is not really something which we should do.

  10. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    I think what would make sense is reducing the attack surface by thinking what we need in the description. It barely is the whole HTML feature-set but some stuff that we can easily implement securely to make everybody happy ;)

  11. oparoz commented on Sep 3, 2015

    @oparoz
    Contributor

    Come on. That's not a proper solution. There have been 2 bypasses this year and we can solve it so easily reliable.

    DOMPurify does offer a whitelist

    var clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b']});

    but yes, if you send me the link to a sane markdown parser, I'll use it instead of parsing the same content twice :). I don't want to write my own parser and have to maintain it.

    I need at least: * lists, 1,2,3 lists, # headers , *italic*, **strong**, [link](http) and it needs to be on bower.

  12. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    DOMPurify does offer a whitelist

    Yes. But DOMPurify is more meant to act as second line of defense instead of making a known insecure thing more secure :-) - Having it in makes sense, yes, but not as first line of defense.

    but yes, if you send me the link to a sane markdown parser, I'll use it instead of parsing the same content twice :)

    Sane markdown parsers in JS… Hard topic… A lot of them lack some security features in one regard or another.

    What is a sane one is https://github.com/jgm/commonmark.js, I'd recommend using that one with the safe option and also run DOMPurify later over the output. That way we have a defense in depth which never hurts 😄

    I don't want to write my own parser and have to maintain it.

    Markdown Plus! 😄 - Just kidding ;-)

  13. oparoz commented on Sep 3, 2015

    @oparoz
    Contributor

    What is a sane one is https://github.com/jgm/commonmark.js, I'd recommend using that one with the safe option

    OK. The lib I'm using also has a sanitize option, but it's disabled by default:
    https://github.com/chjj/marked#sanitize

    I think it's too restrictive as it gets rid of lists and only keeps paragraphs, but if not, I'll ask you to take a look :)

    Markdown Plus! 😄

    Yeah, there are already a few of those on Github :D

  14. LukasReschke commented on Sep 3, 2015

    @LukasReschke
    ContributorAuthor

    I think it's too restrictive as it gets rid of lists and only keeps paragraphs, but if not, I'll ask you to take a look :)

    Yup. I'd go with the commonmark.js one as it can handle such stuff even in sanitize mode.

  15. oparoz commented on Sep 13, 2015

    @oparoz
    Contributor

    Fix is in #308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions