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

Secure by default #182

Closed
rluvaton opened this issue Nov 15, 2022 · 2 comments
Closed

Secure by default #182

rluvaton opened this issue Nov 15, 2022 · 2 comments

Comments

@rluvaton
Copy link

rluvaton commented Nov 15, 2022

Currently the JavaScript evaluation is enabled by default which is a bad practice, I know this project is not maintained anymore but given the case I would like to know if you would merge a PR that disable the evaluation by default

JavaScript evaluation is very dangerous if coming from user input (even if it's running in a sandbox) for example, the following path will cause Heap out of Memory error:

const { JSONPath } = require('jsonpath-plus');

JSONPath({
  json: { nonEmpty: 'object' },
  path: '$..[?(' +
'(function a(arr){' +
'a([...arr, ...arr])' +
'})([1]);)]'
});
@brettz9
Copy link
Collaborator

brettz9 commented Nov 16, 2022

Yes, normally, I'd agree that a project should go with safe-by-default, but as this project has been long around, derived from jsonpath which also had the same issue, I think we would be taking away too much functionality from users accustomed to the project if we are not providing at least a subset of filtering expressions without eval. Until such time as we can have a safe sandbox on by default, one can opt into preventEval.

@brettz9 brettz9 closed this as completed Nov 16, 2022
simontaurus added a commit to OpenSemanticLab/mediawiki-extensions-MwJson that referenced this issue Feb 24, 2023
@80avin
Copy link
Contributor

80avin commented May 6, 2024

Hey @rluvaton , not sure if relevant now but JSONPath-Plus is now safe by default.
And the expression you entered fails with error

index-browser-umd.cjs:1694 Uncaught Error: Unexpected "{" at character 16

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

3 participants