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

[FIX] Encode avatar url to prevent CSS injection #6651

Merged
merged 1 commit into from
Apr 10, 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-ui-message/client/message.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import moment from 'moment'

Template.message.helpers
encodeURI: (text) ->
return encodeURI(text)
isBot: ->
return 'bot' if this.bot?
roleTags: ->
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-message/client/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{else}}
<button class="thumb user-card-message" data-username="{{u.username}}" tabindex="1">
<div class="avatar">
<div class="avatar-image" style="background-image:url({{avatar}});"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we save the URL encoded on the DB?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this in the future, because we will need a migration to do that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@engelgabriel I don't know now, cuz we save usernames there too, can be a problem

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it in the client. The server should reject malformed messages with a proper error code.

<div class="avatar-image" style="background-image:url({{encodeURI avatar}});"></div>
</div>
</button>
{{/if}}
Expand Down