-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Sandbox array bug & fix #106
Comments
I think the current behavior is the right one. If an object implements ArrayAccess, it means that it must behave like any other array in PHP and as far as the sandbox is concerned. So, I don't want to make a difference between real arrays and objects that implement ArrayAccess. The only possibility is to add protection for array items, which seems overkill. |
I just ran into this myself with Consequently, even with the sandbox enabled, this is still allowed through: {{ app.secret_key }} |
Situation:
An unexpected behavior regarding arrays, in Twig_Template::getAttribute() if a referenced object is an array then security checking is skipped. It is allright, but in addition to checking with is_array() Twig also checks for objects that implement ArrayAccess and if so then is considered an array and security checking is again skipped.
Issue:
It doesn't seem a good behavior, because there are a lot of objects that implement ArrayAccess and a security policy must be enforced on them. For example I found about this behavior while feeding the template with some active record objects and the base AR class implements ArrayAccess to allow access for model attributes using array like syntax. But still the security policy needs to be enforced especially since AR objects are tightly linked to the database and I don't want users to have any ideas...
Resolution:
I think the best way is to differentiate between native arrays (check with is_array()) and objects that implement ArrayAccess. If it is later, then security policy must be enforced.
The text was updated successfully, but these errors were encountered: