No video

How To Prevent The Most Common Cross Site Scripting Attack

Cross site scripting is one of the most common ways that a hacker will attempt to infiltrate a website. There are many different forms of cross site scripting, but the most common cause of cross site scripting is using the JavaScript method innerHTML with user input. Any form of user input must be escaped before being used with innerHTML, and any use of innerHTML should be thoroughly thought out to ensure no user input can make it through without being sanitized. It is such an easy mistake to make, but luckily the fix is also just as easy.
Cross Site Scripting Article:
blog.webdevsim...
CodePen For This Video:
codepen.io/Web...
Twitter:
/ devsimplified
GitHub:
github.com/Web...
CodePen:
codepen.io/Web...
#XSS #WebDevelopment #Programming

Пікірлер: 179

  • @FairyRat
    @FairyRat3 жыл бұрын

    Great stuff. Hello from The Odin Project!

  • @pendelschabe

    @pendelschabe

    Жыл бұрын

    Hey

  • @NadidLinchestein

    @NadidLinchestein

    5 ай бұрын

    How's it going? Have you finished

  • @bashehu

    @bashehu

    Ай бұрын

    Hii from DOM Manipulations and Events

  • @albertt755

    @albertt755

    14 күн бұрын

    @@bashehu me too bro :D

  • @luizgustavoveneziani3646
    @luizgustavoveneziani36464 жыл бұрын

    Explanation for people in a hurry. Clear, objective, and exemplified. You've got another subscriber.

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    Thank you!

  • @fredymarb
    @fredymarb Жыл бұрын

    The Odin Project brought me here!

  • @husseinomran1021

    @husseinomran1021

    Жыл бұрын

    me too!

  • @mikayla3386

    @mikayla3386

    Ай бұрын

    Same!

  • @fredymarb

    @fredymarb

    Ай бұрын

    @@mikayla3386 good luck in your journey

  • @leo8964
    @leo89642 жыл бұрын

    This is genuinely terrifying...thank you for covering this topic and informing those of us who don't have that in depth knowledge about such security topics..

  • @natarajanmuthuraman5019
    @natarajanmuthuraman50194 жыл бұрын

    If you want to use innerHTML,then just encode it before putting inside innerHTML. To encode, just replace '' by '>'. So when it goes in the innerHTML, the browser changes them back to ''.

  • @gaganyadav9569
    @gaganyadav95694 ай бұрын

    I really like how this guy makes tutorial videos for teaching (short and simple) and not for view by putting un-necessarily long 10 minute videos. You are doing great work. Thank you!

  • @leblanc666666
    @leblanc6666662 жыл бұрын

    Clear and concise explanation of how this can be dangerous. Ive been looking around for a while now because I couldn't understand the risk associated, but you did a great job doing it, thanks!

  • @morgengabe1
    @morgengabe12 жыл бұрын

    I've seen a bunch of people talk about xss before but you've got a real knack for explaining it simply. Would be great to see more security videos from you!

  • @AmmarRai
    @AmmarRai4 жыл бұрын

    I don't know what's more amazing... that website.. or that hair...

  • @areshera4039

    @areshera4039

    2 жыл бұрын

    @@SkillUpMobileGaming never gonna let you down

  • @hdsz7738

    @hdsz7738

    2 жыл бұрын

    hair, definitely

  • @AssFaceNFT

    @AssFaceNFT

    2 жыл бұрын

    Hello from the other side 🌹🙏🕊

  • @htx80nerd

    @htx80nerd

    5 ай бұрын

    Both

  • @iagomota4649
    @iagomota46493 ай бұрын

    Bro even your older content is fire!

  • @codinginflow
    @codinginflow2 жыл бұрын

    Thank you, the first 3 minutes perfectly summarized all my questions

  • @JosephKhalilov
    @JosephKhalilov5 жыл бұрын

    Simple and clear explanation! Thank you!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    You're welcome!

  • @viallymboma9874
    @viallymboma98743 жыл бұрын

    All those who dislike and hate this video are definitely hackers...thanks for the explanation Kyle

  • @poudlardo
    @poudlardo2 жыл бұрын

    hi there, coming from the odin project

  • @dimarak8866
    @dimarak88663 ай бұрын

    Good explanation. But if one does not put queries in the url then stuff like this doesnt matter, so one could still safely use innerHTML. Generally the client is never safe, because all client code is accessible through dev tools in the browser. So a strong backend protection and safe routing is all it takes to prevent stuff like this.

  • @anvayjain4100
    @anvayjain4100Ай бұрын

    Odin project keeps sending me to this golden channel.

  • @santra528
    @santra5283 жыл бұрын

    Thanks @Kyle for simplifying this. You always come up with new interesting topics 💖

  • @thecodersbay2775
    @thecodersbay27755 жыл бұрын

  • @paristar3079

    @paristar3079

    4 жыл бұрын

    Your dirty tricks won't work here.

  • @want-diversecontent3887

    @want-diversecontent3887

    4 жыл бұрын

    Pari Star javascript:Function(“a”+”lert(1)”)()

  • @slickwilly691

    @slickwilly691

    3 жыл бұрын

    fuck you my computer is hacked now

  • @deansprivatearchive

    @deansprivatearchive

    3 жыл бұрын

    Better yet, the alert doesn't even fire as the quotes inside aren't escaped.

  • @harefeedzieharefidziee4315

    @harefeedzieharefidziee4315

    3 жыл бұрын

    @RajeshKumar Chokkalingam chill, obviously he is in mean of joking.

  • @htx80nerd
    @htx80nerd5 ай бұрын

    I prefer to get my coding advice from models. Thank you.

  • @diogosousa9704
    @diogosousa97043 жыл бұрын

    Really simple explanation but it was so clear :) Well done

  • @B3ASTM0DE1
    @B3ASTM0DE15 жыл бұрын

    Awesome tutorial! I'd love to see a intro into Javascript series as well!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks. That is something I want to tackle for sure, but I need to plan out exactly how beginner friendly I want to make the videos. I could go as beginner friendly as never programmed before or just explain JavaScript itself and not programming.

  • @B3ASTM0DE1

    @B3ASTM0DE1

    5 жыл бұрын

    @@WebDevSimplified Yeah that is a tough one to figure out. You never know where people are at in the journey of web development. Personally, I think it would be nice to cover the basic aspects of programming like you mentioned and then dive into Javascript. If they don't want to watch that part they can always skip ahead!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    @@B3ASTM0DE1 that is kind of my thought as well. I have so many different series ideas and so little time it is tough to choose one to start on.

  • @Speaks4itself

    @Speaks4itself

    5 жыл бұрын

    Web Dev Simplified Will be waiting

  • @yadneshkhode3091

    @yadneshkhode3091

    4 жыл бұрын

    @@WebDevSimplified Can you make video based on Kylie Simpson book you don't know js Or other JavaScript books A person can find basics anywhere on KZread but you won't find industry level JavaScript anywhere So can you please cover that ? You can even make paid course if you like many people will purchase if it's on the level of Kyle Simpson book ( lot of people hate reading books like me and it's more time consuming )

  • @kaysi768
    @kaysi7685 жыл бұрын

    really well explained my friend, subbed

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks! I really appreciate it.

  • @jumboliah13
    @jumboliah138 ай бұрын

    FANTASTIC. Your teaching skills are crazy good.

  • @davidjiang7929
    @davidjiang79294 жыл бұрын

    This is a great explanation, thank you! Do you have any other videos that talk about securing a website and web server?

  • @hariprasath3871
    @hariprasath38714 жыл бұрын

    “>alert(“Channel Hacked!!!”)

  • @sreeharisanjeev8271

    @sreeharisanjeev8271

    4 жыл бұрын

    Your dirty tricks don't work here

  • @anarkix6956

    @anarkix6956

    4 жыл бұрын

    eval(StringtoCharCode());

  • @marcotonybu3231
    @marcotonybu32312 жыл бұрын

    Thanks so much for doing contents that help people like this one. God bless you

  • @srjons_official
    @srjons_official Жыл бұрын

    Your video are really awesome, you make web really simplified 🎉

  • @codedynamics1
    @codedynamics12 жыл бұрын

    thanks Kyle. This is vital information. I've subbed !

  • @danser_theplayer01
    @danser_theplayer01 Жыл бұрын

    Discord had to patch this thing just a week ago, I mean cmon how has nobody considered it?

  • @maciejleszek7401
    @maciejleszek74013 жыл бұрын

    Problem is that also innerText is not a a safe method, textContent is a better idea

  • @marcusotter
    @marcusotter5 жыл бұрын

    Great tutorial as always :D

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks! I really appreciate it.

  • @demonicsyndrome
    @demonicsyndrome5 жыл бұрын

    Legend, subscribed!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks!

  • @dereksneddon6386
    @dereksneddon63862 жыл бұрын

    Great explanation man! You earned a sub!

  • @christiancramer3379
    @christiancramer33793 жыл бұрын

    learned is much here, I think I have to my 7th javascript beginner tutorial

  • @stathisi.5883
    @stathisi.5883 Жыл бұрын

    This was very eye-opening... like wow...

  • @aaa4363
    @aaa4363 Жыл бұрын

    Thanks!

  • @WebDevSimplified

    @WebDevSimplified

    Жыл бұрын

    You're welcome!

  • @emonymph6911
    @emonymph69112 жыл бұрын

    Umm why didn't you show us how to fix the problem right at the end?? Kinda weird that you stopped on the most important part lol

  • @DogmaFight

    @DogmaFight

    2 жыл бұрын

    Yes, was expecting a quick example of how to sanitize the input

  • @busyrand
    @busyrand2 жыл бұрын

    Nice tutorial... The short of it sent me here.

  • @ridl27
    @ridl274 жыл бұрын

    wow. thx for this useful and concise video. now I understand Cross Site Scripting

  • @ravendfj
    @ravendfj5 жыл бұрын

    Hi, So you escape on client side or server side?

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    The escaping needs to be done on the server side since it is always possible a user can change something on the client side before it gets sent to the server so when you send it back you need to escape it.

  • @ravendfj

    @ravendfj

    5 жыл бұрын

    @@WebDevSimplified Thanks for the answer!!

  • @yashojha5033

    @yashojha5033

    3 жыл бұрын

    Or you can use do escaping when you are actually rendering it in DOM. if server side change is a lot. dompurify npm package does exactly that.

  • @zelytics
    @zelytics11 ай бұрын

    "you may think, what can they do with this?" Have you ever had the infinite error box???

  • @yashojha5033
    @yashojha50333 жыл бұрын

    Woah, never knew about IMG tags can be dangerous too. so on error event or any event in the dynamic html and script tags should be removed. got it.

  • @pvd4170
    @pvd4170 Жыл бұрын

    Thank you for a such helpful video!

  • @justingolden21
    @justingolden213 жыл бұрын

    So how would one sanitize the input? Would you just replace all less than and greater than signs with < > ?

  • @chumpee01
    @chumpee015 жыл бұрын

    Superb..couldn't be explained better.

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks!

  • @littleweirdo96
    @littleweirdo963 жыл бұрын

    Hi, I don't fully understand how a person can have access to the cookie data if I open the link on my end, wouldn't the script just be run on my end and only be seen by me? Thanks

  • @Victor_Marius

    @Victor_Marius

    3 жыл бұрын

    It can send your data from your end to an api/server of theirs (to the malicious end). Afterwards they can use those cookies to log into your account.

  • @travisblogstravis4367
    @travisblogstravis43673 жыл бұрын

    My pc just got hacked were I axadently put a script in my URL and some guy almost got my pc but I emailed my local police and they got him

  • @BrownFreelance
    @BrownFreelance2 жыл бұрын

    Thank you! On a side note, what is that font that you are using?

  • @planetmall2
    @planetmall24 жыл бұрын

    Great video! Thank you!

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    You're welcome!

  • @lifeforce3451
    @lifeforce34515 жыл бұрын

    Thank you I am about to finish my web site and I am thinking now I will have to do the same amout of work only for the security its a dangerous world ...

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Security is really hard, but luckily once you know what to look for it is pretty easy to avoid those traps.

  • @biswajitsamantaray3117
    @biswajitsamantaray31173 жыл бұрын

    @web dev simplified I see other videos and they start with script tags, why do you say it's not supported ? I think CORS isn't the way to stop XSS issue of sharing cookie information to another server, right ? If so how can we allow/block thirdparty servercalls from client side and who decides it?

  • @ben_jammin242
    @ben_jammin2425 жыл бұрын

    Great video. Thanks!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    You're welcome!

  • @ioannisme7495
    @ioannisme74953 жыл бұрын

    thank you, very helpful

  • @sparky-makes8373
    @sparky-makes83732 жыл бұрын

    Hello from TOP!

  • @silenceplease5904
    @silenceplease5904 Жыл бұрын

    we can stop this by just giving a regex expression though not allowing tag related items

  • @br6719
    @br67194 жыл бұрын

    Love this video. I am curious if these filters can be seen from a website if one was to open the developer tools to search these .innerHTML or .innerText elements.

  • @amyp.575

    @amyp.575

    4 жыл бұрын

    Look in the inspect tab then the console tab and look

  • @otesunki
    @otesunki3 жыл бұрын

    function safeify(string) { let el = document.createElement('p'); el.innerText = string; return el.innerHTML; }

  • @flashteq1030
    @flashteq10304 жыл бұрын

    very nice explanation bro

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    Thank you

  • @user-kn8nt5zm5n
    @user-kn8nt5zm5n10 ай бұрын

    I added javascript text to my own website. However, IT does not give any alert. My web app treat it like a plain text instead of JavaScript. What should i do to make my code vulnerable to XSS? cause i need to perform XSS for my cybersecurity class

  • @pankajjoshi8292
    @pankajjoshi82923 жыл бұрын

    Sir I request you to built a simple website discussing all security issues

  • @jonfreshhh
    @jonfreshhh Жыл бұрын

    Thank you!

  • @Chaaos2
    @Chaaos25 жыл бұрын

    Very cool great video dude

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks!

  • @rubeushagrid4131
    @rubeushagrid41313 жыл бұрын

    You are life saver.

  • @zarazada
    @zarazada3 жыл бұрын

    Thank you 🙏🏻

  • @niggisnonaz
    @niggisnonaz2 жыл бұрын

    i dont get it? you can insert into html easy and get the same information too? just click inspect in chrome and put that in

  • @bryceblazegamingyt9741

    @bryceblazegamingyt9741

    Жыл бұрын

    You can't send other people your inspected website.

  • @arcanelore168
    @arcanelore1685 ай бұрын

    Do you have a course on Javascript?

  • @WebDevSimplified

    @WebDevSimplified

    5 ай бұрын

    Yep. javascriptsimplified.com

  • @FBDev64
    @FBDev64 Жыл бұрын

    I tried to test with your HTML CSS JS code in Codepen, nothing works.

  • @mrnobody1286
    @mrnobody12863 жыл бұрын

    So what about link sharing ? If I want my website to be able to support web url/link sharing what can I do ? If I use innerHTML then it won't understand a website url as links. Any idea ?

  • @alfredosolorzanoaguilar3058
    @alfredosolorzanoaguilar30584 ай бұрын

    why don't you use a pattern for avoid xss attack

  • @widibaka7058
    @widibaka70583 жыл бұрын

    very great video

  • @randy4443
    @randy44432 жыл бұрын

    I tried this with my site and the alert is not working. I have not sanitize it all and not sure why it is not displaying

  • @yanrocha447
    @yanrocha4472 жыл бұрын

    Hello friend! How are you? I'm Brazilian, a script is running on my sales site. Do you know if there's a way I can block it?

  • @lubu2960
    @lubu2960 Жыл бұрын

    very interesting!

  • @cengiz-ilhan
    @cengiz-ilhan Жыл бұрын

    hi again dudee

  • @rede_neural
    @rede_neural Жыл бұрын

    Why would other websites data be available for this website? This seems like a browser defect, it shouldn't hand cookies and data of other websites

  • @cmd9183
    @cmd91834 жыл бұрын

    what if im not using innerHTML in a form rather am using it to output data from a php script?

  • @Julia_Berrrlin
    @Julia_Berrrlin3 жыл бұрын

    I'd like to learn more about escaping

  • @almahdi2877
    @almahdi28774 жыл бұрын

    bro you are awesome..

  • @akhilpadmanaban3242
    @akhilpadmanaban32423 жыл бұрын

    bro recently iw as just using a normal stranger chat page in google and a person did this like showing big running charectors and all....and he told he is doing html injection.....what should i do???? should he have harmed me????say bro....suddenly my replies went also changed in that site..i then disconnected and stopped.....help me bro..how to check that im secure

  • @farismazlan5157
    @farismazlan51572 жыл бұрын

    Awesome !

  • @wizardtechlabbs5902
    @wizardtechlabbs59022 жыл бұрын

    what if i use post method using jquery for this work?

  • @rpanda_old
    @rpanda_old Жыл бұрын

    That spot on your camera man. I kept swiping my screen for 5 mins😭

  • @vishalverma5280
    @vishalverma52802 жыл бұрын

    2:00 magic!

  • @hus8860
    @hus88604 жыл бұрын

    Thanks bro

  • @cyber_india
    @cyber_india2 жыл бұрын

    Hi, can you tell me how to prevent xss in perl ?

  • @erzengaming
    @erzengaming4 жыл бұрын

    You can see cookies in console if you type alert(document.cookie);

  • @kurdmajid4874
    @kurdmajid48743 жыл бұрын

    That Website is Very Very Vulnerable to SQL injection And Cross Site Script

  • @ai_enthusiast
    @ai_enthusiast5 жыл бұрын

    Amazing!

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Thanks!

  • @rajashekhar433
    @rajashekhar4334 жыл бұрын

    Looking for Js decoraters

  • @thedmitryguy
    @thedmitryguy2 жыл бұрын

    Nice like animation.

  • @theresioleefland1737
    @theresioleefland17374 жыл бұрын

    hey guys can anyeone help with a a java script site just like this one so i can practice?

  • @shauryaaher1579
    @shauryaaher15792 жыл бұрын

    Not correct information. You'll need to sanitize the text on the server. You can't trust the client. Anyone can open the developer tools and change `innerText` to `innerHTML`.

  • @shaheerDev

    @shaheerDev

    Жыл бұрын

    but then thats the users fault, not the site

  • @bryceblazegamingyt9741

    @bryceblazegamingyt9741

    Жыл бұрын

    While you can change inner text to innerHTML, you can't change it for other people you send the links to.

  • @hawaiigirl121
    @hawaiigirl1212 жыл бұрын

    subscribed

  • @devikapluspoint8306
    @devikapluspoint83064 жыл бұрын

    Cross site scripting:normal poo HTML searching:ugly poo javascript injection:rich poo

  • @number1neek
    @number1neek3 жыл бұрын

    Pikaboo, baby Kyle! 😄

  • @jackr6727
    @jackr67274 жыл бұрын

    Can you please explain difference between using only alert tag against img tag? why did alert tag not inject it while img tag inject it? I dont understand the difference between the too scripts that u have used.

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    When you inject a script tag it will not run since the browser already ran all the script tags for the page. The img tag will run the onerror script though since it will immediately through an error when it is loaded.

  • @jackr6727

    @jackr6727

    4 жыл бұрын

    @@WebDevSimplified Sorry still didn't get...since the browser already ran all the script tags?

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    @@jackr6727 That is correct. It already parsed and ran all the script tags and will not run the newly imported script tag.

  • @jackr6727

    @jackr6727

    4 жыл бұрын

    @@WebDevSimplified It already parsed and ran all the script tags ? How is it already parsed? I am talking abt general difference between the 2 scrips. Not related to your video or website that you have used for demo

  • @WebDevSimplified

    @WebDevSimplified

    4 жыл бұрын

    @@jackr6727 What do you mean?

  • @zachfenton608
    @zachfenton6083 жыл бұрын

    that is amazing

  • @MisterOptimous
    @MisterOptimous5 жыл бұрын

    Any examples of a good sanatize/escape functiom I can run for showing (e.g.) an user his details in his profile page as they are all user input.

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    Just make sure you don't use innerHTML with any of the data and you will be fine. You can easily test this to make sure it works, by entering valid HTML and submitting that to see if it is injected or not.

  • @MisterOptimous

    @MisterOptimous

    5 жыл бұрын

    @@WebDevSimplified I've actually always thought XSS is a thing I should be careful with when programming backend, and also I use jQuery so I guess the equivalent would be $().text and $().html

  • @MisterOptimous

    @MisterOptimous

    5 жыл бұрын

    Thanks for clearing it up though, I shall be more careful writing my frontend js code now.

  • @MisterOptimous

    @MisterOptimous

    5 жыл бұрын

    @@WebDevSimplified also what about when I use something like eJs, and then write his or her username like or when you use php short tags, that would be vulnerable, would it not? It's something I just thought of.. I am confusion 🤔😀

  • @WebDevSimplified

    @WebDevSimplified

    5 жыл бұрын

    @@MisterOptimous it would be vulnerable if your backend language isn't sanitizing the data before rendering. It depends on your language. An easy way to test would be to just try it and see what your language does. Most should sanatize it.

  • @karansahu7710
    @karansahu77103 жыл бұрын

  • @xBadxGirlxLucyx
    @xBadxGirlxLucyx3 жыл бұрын

    But didnt you just fetch your own cookie from your own browser, how could you do it for other users?

  • @NickyDekker89

    @NickyDekker89

    3 жыл бұрын

    In this example, you could create a malicious link to this website and have other users click it, fetch their cookie and send it off to you so you can use it to access their account.