-
Notifications
You must be signed in to change notification settings - Fork 308
XSS Vulnerability #610
Comments
are you saying the library should not trust the user? Radium is the tool, your source code is the user. I am pretty sure it is your responsibility to protect yourself. const { exec } from 'child_process'
exec('rm test.out', function callback(error, stdout, stderr){
// result
}); |
@mattyork |
@goldensunliu I'm saying Radium should follow React's safety philosophy:
So when writing non-Radium React components, programmers do not have to worry about sanitizing input from the end-users except when a programmer explicitly chooses to perform an unsafe operation. Radium's use of dangerouslySetInnerHTML goes against that philosophy because there is no indication that the operation is unsafe: no indication in the usage of the library, nor in the documentation. The only way to know it's unsafe is by looking through the source code. @kumarharsh in this case Radium is in control of So again, two options:
|
While you can't inject I vote for "safety first." Radium should be as safe to use as any other React component. |
Great discussion, thanks everyone. Looking forward to the PR @tptee! |
Turns out there's a pretty exhaustive list of vulnerabilities involved with injecting CSS: http://heideri.ch/jso/#css Thankfully, user input in Radium is limited to plain objects we control. A whitelist of CSS properties would be the safest option, but could balloon up the bundle size. I'll see what I can do. |
I could be reading this wrong, but it looks like React itself doesn't protect against dangerous CSS: @sebmarkbage explains it here (they tried a whitelist/validator and it ended up too expensive): facebook/react#3473 (comment) Considering that, a warning about unsafe user input in style objects is probably our best bet, and would be consistent with how React handles inline styles at this moment. |
The
StyleSheet
andStyle
components usedangerouslySetInnerHTML
on input that comes from outside the library. This is a vulnerability. Ideally the input is sanitized or the css is inserted in an xss-proof way (maybe usinginsertRule()
?), but it should at least be documented that input needs to be trusted.dangeouslySetInnerHTML should not be used for any input that comes from outside Radium.
The text was updated successfully, but these errors were encountered: