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

XSS issue with message translation #1

Closed
roblillack opened this issue Sep 20, 2016 · 0 comments
Closed

XSS issue with message translation #1

roblillack opened this issue Sep 20, 2016 · 0 comments
Assignees

Comments

@roblillack
Copy link
Owner

Mars contains a cross-site scripting vulnerability, that allows attackers to inject JavaScript code into the HTML output of your templates, if all of these conditions are met:

  1. You are using the string interpolation features as part of your translations strings and
  2. User input was is added to these translations strings without escaping and
  3. You are using the msg template function to translate messages.

Example translation strings, messages.en:

unable-to-send-msg-error=Unable send message "%s"!

Translation approach that is not vulnerable:

  • Controller:

    c.RenderArgs["errMsg"] = c.Message("unable-to-send-msg-error", c.Params.Get("message"))
    
  • View:

    <p class="error">{{.errMsg}}</p>
    

Translation approach that is vulnerable:

  • Controller:

    c.RenderArgs["usersMessage"] = c.Params.Get("message")
    
  • View:

    <p class="error">{{msg $ `unable-to-send-msg-error` .usersMessage}}</p>
    

The fix for this issue will disable HTML message translation strings, a better approach to allow those kind of strings will be implemented using a separate ticket.

Thanks to @ptman for reporting this.

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

No branches or pull requests

1 participant