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

Sandbox array bug & fix #106

Closed
soso-zz opened this issue Aug 18, 2010 · 2 comments
Closed

Sandbox array bug & fix #106

soso-zz opened this issue Aug 18, 2010 · 2 comments

Comments

@soso-zz
Copy link

soso-zz commented Aug 18, 2010

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.

@fabpot
Copy link
Contributor

fabpot commented Dec 2, 2010

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.

@CarsonF
Copy link
Contributor

CarsonF commented Oct 6, 2015

I just ran into this myself with Pimple, which is also a global, app. Neither ArrayAccess objects nor globals are checked for with the sandbox.

Consequently, even with the sandbox enabled, this is still allowed through:

{{ app.secret_key }}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants