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

🐛 Prevent SVG icons from leaking into DOM #9574

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

timroes
Copy link
Contributor

@timroes timroes commented Jan 18, 2022

What

Currently the SVG icons returned as a string as part of the connector spec where attached to the DOM using dangerouslySetInnerHTML. This lead to a couple of problems:

  • styles defined in one SVG are attached to the regular DOM, thus will affect all other elements on the page. You can actually see that in action e.g. chosing the Cart.com icon. If you now open the source type selection (and thus render all other icons too), styles from another icon will suddenly overwrite the styles from the Cart.com icon.
    icon-svg-leaking-bug
  • Unless we don't carefully inspect every svg icon we're adding, users would be able to inject "arbitraty" DOM into the page, thus offering an attack vector. I've checked all existing SVG icons and none of it injects anything dangerous so far.

How

Using a simple img tab where we set the SVG as a data URL on, will prevent both of those things from happening, since we don't allow DOM injection from SVG elements.

The only drawback would be, that icons can't make use of some form of SVG animations anymore, which as far as I could tell none of the icons tried to do (and I guess we anyway don't want them to do).

Side-Note

I'd personally have preferred to enable the react/no-danger linting rule to bring double care to all future dangerouslySetInnerHTML calls, but unfortunately the rule doesn't work together with styled components, which we are using.

@CLAassistant
Copy link

CLAassistant commented Jan 18, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@jamakase jamakase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, Awesome!

I haven't even thought about such case.

@timroes timroes merged commit 38a5d84 into airbytehq:master Jan 19, 2022
@timroes timroes deleted the webapp/fix-leaking-svg-icons branch January 19, 2022 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants