4 ms·
"Customize the look of your blog by editing these templates."
by tedunangst 10y ago
"Customize the look of your blog by editing these templates."
- coldtea 10y agoShouldn't that be based not on the built-in string capabilities, but on a template engine, that must also take care for much more narrow cases of abuse (e.g. SQL injection, or access to only of a restricted number of helper functions within the template)?
- tedunangst 10y agoMany templates allow accessing fields. There's no risk of SQL injection, you're only echoing the output back to the user.
- yawaramin 10y agoDidn't you just point out that some of those fields could be sensitive, like password info?
- icebraining 10y agoThe author discovered this exploit in the template engine he wrote (Jinja2).
- nine_k 10y agoI'll consider switching to a different engine.
- jessaustin 10y agoPerhaps one that hasn't had this exploit fixed yet?
- coldtea 10y agoWhy would a template engine allow for free access to the native platforms string capabilities in the first place?
- obstinate 10y agoNative vs. non-native is irrelevant. A non-native formatting system could have the features of the python formatter that are dangerous. Or, if Python's native formatter lacked these dangerous features, there'd be no reason not to use it.
- coldtea 10y ago>Native vs. non-native is irrelevant. A non-native formatting system could have the features of the python formatter that are dangerous. Hardly irrelevant. The idea is that a non-native formatting system is build specifically for the templating engine, and so the developers controls what it can do and gives it non-dangerous features. >Or, if Python's native formatter lacked these dangerous features, there'd be no reason not to use it Even if it did lack them, it's not under the control of the template platform author, so they should not rely on it for such a crucial part of the template engine as string formatting. (Which is exactly the case here: Python lacked those features before, but got them, and bit the template engine in the back).
- obstinate 10y ago> it's not under the control of the template platform author This doesn't really matter. If it does what you want, it's not like they're going to change the formatter's behavior from under your feet if it's part of the language's default runtime.
- dom0 10y agoWhile the vuln is there, it's a rather obscure way of using the engine in the first place, so in "good" templates it shouldn't be exploitable. See the example in the release: https://www.palletsprojects.com/blog/jinja-281-released/ https://www.palletsprojects.com/blog/jinja-281-released/
- icebraining 10y agoSure, but like tedunangst pointed out, there are valid reasons to allow users to edit those templates, in which case you can't assume they'll be "good".
- dom0 10y agoWhat does the template engine have to do with SQL? Not really following you there.
- coldtea 10y agoA template engine has multiple use cases its author can not foresee, not just creating pages. Here they talk of using it for translation, with arbitrary user provided strings for example. Another could use it to create an SQL helper (accounting themselves for injection) etc. In any case, it should not contain dangerous helper methods of capabilities not fit for strictly templating, just because the native string class allows them.