Steps to reproduce:
- Install Media: YouTube and required modules. Configure display. Import a video, view the page with the video.
- Go to Configure >> File types >> Manage file display for videos.
- Set the width of the YouTube Video display to
560">><script>alert('hi');</script>. (Same thing works for the height.) - Reload the video page. An alertbox with 'hi' shows up.
This is mitigated by the fact, that the attacker must have permission to configure the file display. That + there is no stable release, yet => A security advisory is not nescessary. (Thank you, @Dave Reid.)
Proposed resolution:
Use #element_validate => array('element_validate_integer_positive') on the textfields.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | media_youtube-validate-formatter-xss-1547420-7.patch | 2.45 KB | RobW |
| #6 | media_youtube-validate-width-height-xss-1547420-6.patch | 1.61 KB | RobW |
| #4 | media_youube-checkplain-1547420-4.patch | 620 bytes | RobW |
Comments
Comment #1
dave reidWe should also add a check_plain() to mitigate any existing malicious settings.
Comment #2
gregglesThis seems critical.
Comment #3
aaron commentedD7 stable release blocker
Comment #4
RobW commentedWhoops, missed that. Thanks for finding the security hole, and here's a patch.
Comment #5
RobW commentedComment #6
RobW commentedForget the patch in #4. Niklas's suggestion is way better.
This patch checks if user input is a number or percentage, with or without a decimal, or "auto". It uses the regex
/^(auto|([0-9]*(\.[0-9]+)?%?))$/If the check fails, the form throws the error:
Html 4.x allows percentages and auto in the width and height attributes, and most browsers will use any valid css size (percent, px, em) even though the current spec says unitless numbers only. Percent is still pretty common. I was thinking of allowing px and ems through validation too, but that would make the error message really long and might encourage bad behavior. Suggestions are welcome on where to draw the line.
Comment #7
RobW commentedAs long as I was in there I added validation to the .js API origin, the only other user-entered text in the formatter.
The regex to match is
^https?\:\/\/[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}){1,2}$. Aiming for just restrictive enough.Comment #8
RobW commentedI've tested this pretty thoroughly. Since it's a security issue, committing.
http://drupalcode.org/project/media_youtube.git/commit/4bd2f34
Comment #9.0
(not verified) commentedClose the
.