Let's say that name is not now Gibson Explorer. Let's go back here, right? Not Gibson Explorer anymore. That's gonna be, again, that thing that we saw. Well, let's do, I don't know, well, let's do. I mean, JavaScript alert will not work there. That's not a link, so I can try this vector instead, like alert and see what happens. And changed it, but I mean, no alert. I don't even see an image tag, so that's okay. Let's try something else.
What I would say is, I don't remember what was here, so I'll just do ABC, but let's say this, you know, if I were thinking how to exploit this, I would say, if this package was written by someone, maybe they didn't take a good care enough of sanitizing the data or output-encoding it by going into all of the recursive elements that actually are within the JSON, so all of the elements that's like living inside other fields in other fields. So what if I tried to put it here? Like maybe this level on the JSON is sanitized, but this one is not, or output-encoded would be the best way of doing this. But looks like it is. So that looks okay. So there we go, getting back to normal. Now, it looks like this is working, and if this is a JSON input from an NPM package that you get, as well, that is not controlled by you, that is controlled by someone else, right? So what if that person gives you a bad package JSON, right? Like I'm gonna go and do something like this and say, hey, like you're getting this package JSON. There you go. So package manifest. There you go. Now, it's not a JSON anymore. Now it's a string. It's a string, which I control, because I can define whatever I want in my package JSON and mine is just a TAR file and I'll send it to you, right? So if this is the input now, let's see what happens. Changed the whole meaning of what the package JSON is, but the question is, is the application ready to handle something like that? Doesn't look like it, because it looks like it tries to render it. You should probably have put an alert box somewhere there. And I'll alert, on our alert, probably should have worked. Oh, there we go. So now we see that what's happening, right? So now you're using a component, an open source library that may have vulnerabilities in it, even though you were thinking it might be okay, you know, probably, you know, well, probably it's not, but no, you have to like test all of those things. So it's kind of like brings us into the world of, you know, managing components, learning about all of those things. So here are my takeaways.
Let's go back to slides. Yeah, there we go. So takeaways for us, right? This is, you know, avoid all of this, you know, dangerously inner HTML, obviously you do not wanna do this, but the fact that you're avoiding it doesn't mean that others are avoiding it as well, like we've seen here. So you should really scan your third-party dependencies if you're doing something like npm audit, you know, that's fine. It's a great way to, you know, get awareness for security vulnerabilities. But in my case, I found out when I was using React.JSON in my demo here is that he did not find it when I was doing npm install and npm audit, nothing was showing up for it. You know, luckily I was using a sneak test and I was able to find it. So be aware of what you're putting into this, if I have to summarize, right? Be aware of what you're putting into your, I would say dependencies in general, libraries collection or your applications, components, be aware of what you're putting there, be able to scan it all the time and fix it. And the other thing is, of course, be careful of what you put into those href html attributes because they are not getting output encoded by default. So thank you, React, as I would say, React responsibly and securely.
Comments