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

Parser library variables escape & template includes #3640

Closed
wants to merge 1 commit into from
Closed

Parser library variables escape & template includes #3640

wants to merge 1 commit into from

Conversation

vstelmakh
Copy link

Added functionality for escaping data and including template in to template.

{var} - prints escaped data
{{var}} - prints unescaped data

@include(template_name) - includes one view to another

@vstelmakh vstelmakh changed the title Parser library variables escape & template includes. Parser library variables escape & template includes Mar 3, 2015
@narfbg
Copy link
Contributor

narfbg commented Mar 4, 2015

I see what you're doing with escape by default, but that's a huge BC break and the escaping itself is not really sensible. Even otherwise, you should use a templating engine like Twig if you want such functionality.

CI's Parser class is meant to be dead simple and if we start accepting changes like these, we're also dedicating ourselves to adding and supporting more and more templating features and that's just beyond our targets. In fact, I've thought a few times already about dropping the Parser class in favor of external templating engines for those same reasons, but that will probably happen in CI4.

@narfbg narfbg closed this Mar 4, 2015
@kakysha
Copy link
Contributor

kakysha commented Mar 4, 2015

@narfbg for what reason does CI need templating engine at all? Why not just use PHP in views, really? One more absolutely useless abstraction layer. For whom it is intended? Designers? Pfff. Replacing $var with {{var}} and require_once() with @include() makes no sense for me.

@vojtatranta
Copy link

@kakysha well, I don't want to create flame here, but php framework that does not use templating engine that cares about escaping can be hacked under 5 seconds.
Funny thing is that even sophisticated templating engine that by default everything escapes cannot ensure that attacker wont be able to run his code on your site via XSS or something.
The true purpose of existence of templating engines is not simplification of the way we write html but lack of security layer when printing stuff via PHP to html.

@LouisMilotte
Copy link
Contributor

@vojtatranta citation for hack claim?

@vojtatranta
Copy link

@LouisMilotte well, you need citation for it?
If you do not use templating engine, you have to manually escape every string in every template, you can't even use .
If someone saves his username as <script>alert('Sucessfull xss')</script> then mostly this code will be executed (or it might com as parameter from URL).
Even Codeigniter's official tutorial does not escape strings.
Thats extremely dangerous, we all should know about that.

@mwhitneysdsu
Copy link
Contributor

@vojtatranta CI's Parser library doesn't escape the output for you, either. It's relatively simple to override it to do so, but, in the end, you're really left to your own devices to secure output in CI.

@LouisMilotte
Copy link
Contributor

@vojtatranta that's not a citation; citation please.

edit: I'm not meaning to be an a$!. This is a new claim to me.

@vojtatranta
Copy link

@mwhitneysdsu thats what I am talking about.
@LouisMilotte Well I hope that explanation would be enough, XSS is usually used to steal session of logged user, I think you can find yourself some articles about it.
If you really want a citation I can write article about how you can simply steal session from some administrators using XSS and Javascript.

@LouisMilotte
Copy link
Contributor

@vojtatranta more so as to why template engines resolve that. At this point it's probably best to just point me at one of these "engines" that achieve what you're talking about rather than flooding this issue log.

@vojtatranta
Copy link

@LouisMilotte Very well, then mostly commonly use in PHP world is propabably Smarty or you can also use Mustache/handlebars Symfony relies on Twig Laravel has nice engine called Blade and last but not least, czech framework Nette has awesome templating library which I use in CI if I have something in legacy code, it's called Latte.
All of them can be installed via composer. There is also fork of smarty that is meant to be used in CI.
Using bold PHP (unescaped, manually escaped) HTML I consider huge hole in security, so huge that I would fear to use such app.

@narfbg
Copy link
Contributor

narfbg commented Jul 15, 2015

well, I don't want to create flame here, but

"I don't want to ... but here it is". You resurrected a 4-months old discussion for the sake of argument.

Please don't use our issue tracker as a forum board.

@bcit-ci bcit-ci locked and limited conversation to collaborators Jul 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants