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

How to increase the security of Expression and avoid being executed evil javascript code #631

Open
WoeOm opened this issue Oct 27, 2022 · 4 comments

Comments

@WoeOm
Copy link

WoeOm commented Oct 27, 2022

Version

Reproduction link
https://sunmao-ui.com/dev.html
Steps to reproduce
Inside the Text component, enter {{alert()}}
What is expected?

What is actually happening?

@tanbowensg
Copy link
Collaborator

Good point. Sunmao uses new function() to run the code in Expression, so the expression will run globally and Sunmao can not prevent expression from running.

But there is a simple workaround to solve this problem to some extent, which is overriding some dangerous global variables(like alert) when evaluating expressions. Maybe we can add it into next version.

@WoeOm
Copy link
Author

WoeOm commented Oct 27, 2022

javascript sandbox is very tricky problem.

But lowcode allows access to third-party apis, and the return values of apis such as (alert(), GetSessionToken(), eval()) may also be executed through {{api.result}}.

@Yuyz0112
Copy link
Contributor

One thing I'm thinking about is how should we define 'dangerous code'.

Because in sunmao, the expressions were written by the app developer, the people that can responsible for the code.

@Yuyz0112
Copy link
Contributor

Another point is whether the expression system cause XSS happens easier. I think the answer is yes and there is something we can improve.

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