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

can.Model.findAll promotes usage of XSS attack vector #186

Closed
jeffrose opened this issue Nov 30, 2012 · 3 comments
Closed

can.Model.findAll promotes usage of XSS attack vector #186

jeffrose opened this issue Nov 30, 2012 · 3 comments
Labels
Milestone

Comments

@jeffrose
Copy link

Model.find() assumes that the related service will return an object.

{ "name": "do the dishes" }

Model.findAll() assumes that the related service will return an array of objects, where each object is a model.

[ { "name": "do the dishes" }, { "name": "pick up milk" } ]

Returning an array as the root entity of a JSON service opens that service up to a XSS attack.

http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx

The fix is to wrap the array in an object.

{ "data": [ { "name": "do the dishes" }, { "name": "pick up milk" } ] }
@daffl
Copy link
Contributor

daffl commented Nov 30, 2012

The can.Model.models converter already does this: https://github.com/bitovi/canjs/blob/master/model/model.js#L734

If you would like it mentioned in the documentation you can submit a pull request with the updated documentation.

@daffl daffl closed this as completed Nov 30, 2012
@justinbmeyer justinbmeyer reopened this Nov 30, 2012
@justinbmeyer
Copy link
Contributor

Reopened b/c we should update our docs to show this as the standard way of sending data. We shouldn't show a vulnerability.

@justinbmeyer
Copy link
Contributor

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

No branches or pull requests

3 participants