Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Conversation

chirayuk
Copy link
Contributor

Sandboxing Angular Expressions

Angular expressions are generally considered safe because these
expressions only have direct access to $scope and locals. However, one
can obtain the ability to execute arbitrary JS code by obtaining a
reference to native JS functions such as the Function constructor.

As an example, consider the following Angular expression:

{}.toString.constructor(alert("evil JS code"))

We want to prevent this type of access. For the sake of performance, we
disallow any access to any member named "constructor". You can foil
this by sticking in the Function constructor under a different name in
your scope or exposing other JS apis or the DOM by sticking it on the
scope. Don't do that - you increase the chances of accidently allowing
an exploit through.

@ghost ghost assigned IgorMinar Jun 25, 2013
Sandboxing Angular Expressions
------------------------------
Angular expressions are generally considered safe because these
expressions only have direct access to $scope and locals.  However, one
can obtain the ability to execute arbitrary JS code by obtaining a
reference to native JS functions such as the Function constructor.

As an example, consider the following Angular expression:

  {}.toString.constructor(alert("evil JS code"))

We want to prevent this type of access.  For the sake of performance, we
disallow any access to any member named "constructor".  You can foil
this by sticking in the Function constructor under a different name in
your scope or exposing other JS apis or the DOM by sticking it on the
scope.  Don't do that - you increase the chances of accidently allowing
an exploit through.
@IgorMinar
Copy link
Contributor

landed as 5349b20

@IgorMinar IgorMinar closed this Jul 3, 2013
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.

2 participants