Query fails with "DeserializationError: Object contains forbidden prototype property" when the response object has a "constructor" key
See original GitHub issue🐛 Bug Report
Query fails with DeserializationError: Object contains forbidden prototype property
.
This started happening when we upgraded from v7.3 to v7.11. This PR seems to be the cause: https://github.com/elastic/elasticsearch-js/pull/1110
To Reproduce
Issue a query that results in constructor
being an object key in the JSON response. In our case it was detected in a request to the Term Vectors API, but I guess it can happen in many other places, like in an aggregation named constructor
, etc. Example from the Term Vectors API response that affected us:
{
"constructor": {
"doc_freq": 1,
"ttf": 1,
"term_freq": 1
}
}
See https://github.com/elastic/elasticsearch-js/pull/1110#issuecomment-790479130 for a full example.
Expected behavior
No errors thrown from a perfectly valid response.
Your Environment
- node version: 14
@elastic/elasticsearch
version: 7.11- os: Linux
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (8 by maintainers)
Top Results From Across the Web
Parse JSON String into a Particular Object Prototype in ...
I want to know how to convert a JSON string into a "Foo" Object. That is, my Object should now have a function...
Read more >Object.prototype.__proto__ - JavaScript - MDN Web Docs
prototype is an accessor property (a getter function and a setter function) that exposes the internal [[Prototype]] (either an object or null ) ......
Read more >NodeJS - __proto__ & prototype Pollution - HackTricks
First of all, we need to understand Object in JavaScript. An object is simply a collection of key and value pairs, often called...
Read more >Mongoose v6.8.1: API docs
Getter/setter around function for pluralizing collection names. Mongoose.prototype.sanitizeFilter(). Parameters. filter «Object». Sanitizes query filters ...
Read more >Changelog - SAP Capire
[cds.java@1.30.0] The sap-language query parameter now has lower priority than ... The max-failed-attempts property for a messaging queue configuration has ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I really think this is the wrong approach here, and that the potential vulnerability that tries to avoid is completely out of the scope of a client lib like this. I wonder if popular requests libraries like node-fetch or axios would throw similar errors when calling an API with
constructor
as key in the response (or maybe the browsers standardfetch
API?). Or a database client library failing to query a table with a column namedconstructor
. I’d be puzzled, just like I was (am) when I came across this. Quite disappointing.Hello! The dev tools UI in Kibana is not using the client, but a plain HTTP proxy. The json parser does a full object traversal to detect dangerous keys, and has been updated to be more strict and only throw an error if the
constructor
key is an object which contains aprototype
key. The option to disable more easily the prototype poisoning protection introduced in #1414 will land in the next minor of the client, but you can already disable it by injecting a custom serializer as shown above.