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

Security enhancement: JSON Vulnerability Protection #7

Open
kennardconsulting opened this issue Aug 21, 2013 · 2 comments
Open

Security enhancement: JSON Vulnerability Protection #7

kennardconsulting opened this issue Aug 21, 2013 · 2 comments

Comments

@kennardconsulting
Copy link

May I suggest MongoStreamingOutput could be changed to add escaping characters:

public void write( OutputStream out )
    throws IOException, WebApplicationException {

    if ( object instanceof DBCursor ) {
        out.write( ")]}',\n".getBytes() );
    }
    com.mongodb.jee.util.JSON.serialize(object, out);
}

This prevents a type of JSON attack, described here http://docs.angularjs.org/api/ng.$http (see heading 'JSON Vulnerability Protection')

@angelozerr
Copy link
Owner

Thank's for the hint and the link.

It seems Angular works with ")]}',\n", but is it a standard mean?

For instance at http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx it says :

The ASP.NET AJAX library uses the "d" parameter formatting for JSON data. This forces the data in the example to appear in the following form:
{"d" : "bankaccountnumber", "$1234.56" }

Perhaps we should manage the both?

JAX-RS provider should manage that too
https://github.com/angelozerr/mongo-jee/blob/master/mongo-jee/src/main/java/com/mongodb/jee/jaxrs/providers/DBObjectIterableProvider.java

But how to pass this info to the provider? With an annotation? A global configuration?

@kennardconsulting
Copy link
Author

A global configuration might be nice. Maybe specified along with context-param mongoURI in the web.xml?

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

No branches or pull requests

2 participants