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

Does not work with proper CSP settings #153

Open
heinerlamprecht opened this issue Aug 23, 2022 · 4 comments
Open

Does not work with proper CSP settings #153

heinerlamprecht opened this issue Aug 23, 2022 · 4 comments
Labels
question Issues that look for answers.

Comments

@heinerlamprecht
Copy link

heinerlamprecht commented Aug 23, 2022

After applying proper CSP-settings, the validator does not work anymore. Console shows:

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script

Unfortunately, "unsafe-eval" is prohibited in lots of governmental organisations or Top-500 companies.

Note: The application connects to a REST-Service and the schemas are not known at build-time. Instead they are downloaded from the REST-API.

@ChALkeR
Copy link
Contributor

ChALkeR commented Oct 4, 2022

@heinerlamprecht Hi! Sorry for the late response.

This can be used with CSP via pre-compiling, as mentioned in the documentation: https://github.com/ExodusMovement/schemasafe#generate-modules

To do this, the schemas should be known prior to runtime, and pre-built.
This way, runtime won't need to execute dynamically built validators.

@ChALkeR
Copy link
Contributor

ChALkeR commented Oct 4, 2022

Note: The application connects to a REST-Service and the schemas are not known at build-time. Instead they are downloaded from the REST-API.

Ah, I see.

Are the schemas trusted or not?
If yes, they could perhaps be shipped in pre-compiled form via a proxy (perhaps even a separate host)?

Using untrusted schemas could cause DoS even with all the checks, regardless of the validator used.

@ChALkeR ChALkeR added the question Issues that look for answers. label Oct 6, 2022
@heinerlamprecht
Copy link
Author

To do this, the schemas should be known prior to runtime, and pre-built. This way, runtime won't need to execute dynamically built validators.

How can I use this compiled module in an application?

@ChALkeR
Copy link
Contributor

ChALkeR commented Mar 10, 2023

How can I use this compiled module in an application?

I'm not sure about the nature of the question, that depends on the exact setup.

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

No branches or pull requests

2 participants