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

Bug with block commenting in compiled template via string resource #157

Closed
talisto opened this issue Jan 7, 2016 · 1 comment
Closed

Comments

@talisto
Copy link

talisto commented Jan 7, 2016

As of Smarty v3.1.28, a block in a compiled template has a PHP comment wrapped around it that indicates the resource and name of the template that the block is contained in. The problem is that the "name" of a string resource's template is actually the entire template contents. This can allow for exploitable code in some situations. Consider this example:

$smarty = new Smarty;
$smarty->display('string:{block name="test"} */ echo date("Y"); /* {/block}');

this will output:

2016 */ echo date("Y"); /*

Note the "2016". Because the template content is embedded to the compiled template as-is, the PHP comment can be closed and re-opened, and anything in between will be executed as raw PHP code. Obviously the echo command could be replaced with an exec or otherwise to do "bad things".

If there are other internal compiler plugins that add comments like the block plugin, those should probably be checked for similar exploits.

@uwetews
Copy link
Contributor

uwetews commented Jan 26, 2016

Thanks for bringing this up.
The fix is now in the master branch and will later be included in 3.1.30

@uwetews uwetews closed this as completed Jan 26, 2016
uwetews added a commit that referenced this issue Jan 26, 2016
…mplates through PHP comments #157 (reverted from commit 2850cce)
uwetews added a commit that referenced this issue Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants