reactpy icon indicating copy to clipboard operation
reactpy copied to clipboard

Add warning for `html.script`

Open Archmonger opened this issue 3 years ago • 12 comments

Current Situation

Currently, there is no documented warnings for the potential of XSS attacks when using html.script

Proposed Actions

We should add a disclaimer to warn users not to use raw user inputs (from any untrusted data source) within the script contents to avoid XSS attacks.

Archmonger avatar Feb 13 '23 03:02 Archmonger

Can you assign me the task? Will be a good starting point.

ZEUS-03 avatar Apr 17 '23 03:04 ZEUS-03

We don't utilize the issue assignment feature on GitHub. The first person to open a draft PR gets priority to resolve it.

Archmonger avatar Apr 17 '23 04:04 Archmonger

ok thanks! will do that.

ZEUS-03 avatar Apr 17 '23 04:04 ZEUS-03

@Archmonger, was your intention for this to be in the docstring.

rmorshea avatar Apr 17 '23 04:04 rmorshea

Yeah, since the docstring gets turned into auto-docs.

Archmonger avatar Apr 17 '23 04:04 Archmonger

hey! can you please tell me where do i have to put or write the documention i mean in which file?

ZEUS-03 avatar Apr 17 '23 15:04 ZEUS-03

https://github.com/reactive-python/reactpy/blob/main/src/reactpy/html.py

rmorshea avatar Apr 17 '23 17:04 rmorshea

@Archmonger, can we create a follow-up ticket for a tool that would sanitize inputs to scripts? I think we can do more to help mitigate this risk for users.

rmorshea avatar Apr 23 '23 05:04 rmorshea

You think this could be added to our flake8 plugin?

Archmonger avatar Apr 23 '23 06:04 Archmonger

It's possible, but if that's all we supplied users might improperly sanitize inputs. Better to provide a standardized solution.

rmorshea avatar Apr 23 '23 06:04 rmorshea

That might be a bit over engineered for a tag that we shouldn't incentivize using.

In my opinion, due to script tags being inherently dangerous we should treat them similar to React dangerouslySetInnerHtml.

It's best to get the idea into user's heads that "you can use this but it's risky so you probably shouldn't."

Archmonger avatar Apr 23 '23 19:04 Archmonger

I like that idea. We could require the script to be passed as a kwarg with a scary name like insecurely_eval or something.

rmorshea avatar Apr 23 '23 22:04 rmorshea