Skip to content

Fix transformHeader can't work with worker (#623) (#761)#953

Open
imReker wants to merge 1 commit into
mholt:masterfrom
imReker:Fix-transformHead-in-worker
Open

Fix transformHeader can't work with worker (#623) (#761)#953
imReker wants to merge 1 commit into
mholt:masterfrom
imReker:Fix-transformHead-in-worker

Conversation

@imReker

@imReker imReker commented Sep 5, 2022

Copy link
Copy Markdown

When worker set to true, convert transformHeader function to string, so the config could be cloned to worker and convert back in worker thread by eval.
So, when using Content Security Policy, this workaround will still fail, consider to use vkThread instead.

When worker set to true, convert transformHeader function to string, so the config could be cloned to worker and convert back in worker thread by `eval`.
So, when using Content Security Policy, this workaround will still fail, consider to use vkThread instead.
@pokoli

pokoli commented Sep 5, 2022

Copy link
Copy Markdown
Collaborator

I'm a little bit worried about the eval function as string specially as anyone can manipulate the string definition and then inject malicious code on the worker.

This raises a BIG WARNING on my mind.

Can we avoid using eval?

@imReker

imReker commented Sep 5, 2022

Copy link
Copy Markdown
Author

I'm a little bit worried about the eval function as string specially as anyone can manipulate the string definition and then inject malicious code on the worker.

This raises a BIG WARNING on my mind.

Can we avoid using eval?

Yes, there are potential risks. But the transformHeader usually doesn't come from dynamic user input, and the eval is running in the worker, so only global data and codes could be executed. Maybe a big notice in the document is needed .
And, as I mentioned, to totally avoid eval, consider using vkThread(https://github.com/vkiryukhin/vkthread), but I think it's a bit heavy for this problem.

@dbaranoff

dbaranoff commented Apr 23, 2024

Copy link
Copy Markdown

here's the way to do it without eval. Also, there are similar issues with all the rest config functions

@dboskovic

Copy link
Copy Markdown
Collaborator

Adding this to the v6 todo. In practice adding support for at least primitive functions here is reasonable as long as we also provide documentation for "full worker" mode. People should be given guidance for making their own workers for more advanced scenarios.

@dboskovic dboskovic added the v6-todo This issue should be handled in the v6 release label Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v6-todo This issue should be handled in the v6 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants