?
avatar C-Lodder
C-Lodder
1 Apr 2020

Steps to reproduce the issue

Not sure if Joomla supports this on purpose or not, but will raise it anyway.

If you create the following language string:

COM_MYCOMPONENT_STRING="<script>alert('test')</script>"

And then call it using:

echo Joomla\CMS\Language\Text::_('COM_CONTENTHISTORY_PREVIEW_FIELD');

It will display a browser alert on the page.

Is this allowed on purpose?

avatar C-Lodder C-Lodder - open - 1 Apr 2020
avatar joomla-cms-bot joomla-cms-bot - change - 1 Apr 2020
Title
<script> tag in language string
tag in language string
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Apr 2020
avatar SharkyKZ
SharkyKZ - comment - 1 Apr 2020

Yes, HTML is allowed here.

avatar C-Lodder
C-Lodder - comment - 1 Apr 2020

@SharkyKZ - HTML yes, but a HTML script tag specifically?

avatar acs-ferreira
acs-ferreira - comment - 1 Apr 2020

Can you also reproduce it with a language override trough the admin or only by manually editing the language file?

avatar C-Lodder
C-Lodder - comment - 1 Apr 2020

@acs-ferreira Haven't tried overriding the string in the admin backend. This test is for editing language file

avatar chmst
chmst - comment - 1 Apr 2020

@acs-ferreira : If used in overrides, the script tag is removed

avatar SharkyKZ
SharkyKZ - comment - 1 Apr 2020

HTML yes, but a HTML script tag specifically?

Why would it be excluded?

avatar C-Lodder
C-Lodder - comment - 1 Apr 2020

To prevent any potential XSS attacks

avatar brianteeman
brianteeman - comment - 1 Apr 2020

This really should have been reported privately to the jsst

@SniperSister @zero-24

avatar SharkyKZ
SharkyKZ - comment - 1 Apr 2020

If you're passing user input, you should filter or escape it before doing so. This doesn't belong in Text class.

avatar mbabker
mbabker - comment - 1 Apr 2020

It should not be considered a security vulnerability that language strings can have any valid HTML structures in them. Nor should the language API be trying to sanitize HTML before translating text. That is really a concern of the presentation layer, not the translation layer.

avatar C-Lodder C-Lodder - change - 2 Apr 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-04-02 07:01:28
Closed_By C-Lodder
avatar C-Lodder C-Lodder - close - 2 Apr 2020

Add a Comment

Login with GitHub to post a comment