Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fixes #6354

Merged
merged 4 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/rocketchat-file-upload/server/lib/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ WebApp.connectHandlers.use('/file-upload/', function(req, res, next) {
}
}

res.header('Content-Security-Policy', 'default-src \'none\'');

return FileUpload.get(file, req, res, next);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,21 @@ Template.messageAttachment.helpers
injectIndex: (data, previousIndex, index) ->
data.index = previousIndex + '.attachments.' + index
return

safeLoadImageAttachment: (url) ->
host = ''
url = fixCordova(url)
if (url.indexOf("://") > -1) {
host = url.split('/')[2]
} else {
host = url.split('/')[0]
}

host = host.split(':')[0]

if (host != window.location.hostname) {
return ''
} else {
return url
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<div class="attachment-image">
{{#if loadImage}}
<figure>
<div class="inline-image" style="background-image: url('{{fixCordova image_url}}');">
<img src="{{fixCordova image_url}}" height="{{getImageHeight image_dimensions.height}}" class="gallery-item" data-title="{{title}}" data-description="{{description}}">
<div class="inline-image" style="background-image: url('{{safeLoadImageAttachment image_url}}');">
<img src="{{safeLoadImageAttachment image_url}}" height="{{getImageHeight image_dimensions.height}}" class="gallery-item" data-title="{{title}}" data-description="{{description}}">
</div>
{{#if description}}
<figcaption class="attachment-description">{{description}}</figcaption>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Template.createCombinedFlex.events

'click .save-channel': (e, instance) ->
err = SideNav.validate()
name = instance.find('#channel-name').value.toLowerCase().trim()
name = instance.find('#channel-name').value.toLowerCase().trim().replace(/</g, "&lt;").replace(/>/g, "&gt;")
privateGroup = instance.find('#channel-type').checked
readOnly = instance.find('#channel-ro').checked
createRoute = if privateGroup then 'createPrivateGroup' else 'createChannel'
Expand Down