How To Prevent The Most Common Cross Site Scripting Attack

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024

Комментарии • 181

  • @FairyRat
    @FairyRat 3 года назад +149

    Great stuff. Hello from The Odin Project!

    • @pendelschabe
      @pendelschabe Год назад +2

      Hey

    • @NadidLinchestein
      @NadidLinchestein 6 месяцев назад

      How's it going? Have you finished

    • @bashehu
      @bashehu 2 месяца назад +4

      Hii from DOM Manipulations and Events

    • @albertt755
      @albertt755 Месяц назад +3

      @@bashehu me too bro :D

  • @leo8964
    @leo8964 2 года назад +32

    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..

  • @fredymarb
    @fredymarb Год назад +20

    The Odin Project brought me here!

  • @dimarak8866
    @dimarak8866 5 месяцев назад +2

    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.

  • @leblanc666666
    @leblanc666666 2 года назад +23

    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
    @morgengabe1 2 года назад +9

    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
    @AmmarRai 4 года назад +146

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

    • @areshera4039
      @areshera4039 2 года назад +7

      @@SkillUpMobileGaming never gonna let you down

    • @hdsz7738
      @hdsz7738 2 года назад +3

      hair, definitely

    • @AssFaceNFT
      @AssFaceNFT 2 года назад

      Hello from the other side 🌹🙏🕊

    • @htx80nerd
      @htx80nerd 7 месяцев назад

      Both

  • @codinginflow
    @codinginflow 2 года назад +12

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

  • @JosephKhalilov
    @JosephKhalilov 5 лет назад +108

    Simple and clear explanation! Thank you!

  • @poudlardo
    @poudlardo 2 года назад +6

    hi there, coming from the odin project

  • @thecodersbay2775
    @thecodersbay2775 5 лет назад +31

  • @kaysi768
    @kaysi768 5 лет назад +7

    really well explained my friend, subbed

  • @diogosousa9704
    @diogosousa9704 3 года назад +3

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

  • @jumboliah13
    @jumboliah13 9 месяцев назад

    FANTASTIC. Your teaching skills are crazy good.

  • @htx80nerd
    @htx80nerd 7 месяцев назад

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

  • @LeHuffy
    @LeHuffy 6 лет назад +3

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

    • @WebDevSimplified
      @WebDevSimplified  6 лет назад +2

      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.

    • @LeHuffy
      @LeHuffy 6 лет назад

      @@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  6 лет назад +1

      @@LeHuffy 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 6 лет назад +1

      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 RUclips 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 )

  • @marcotonybu3231
    @marcotonybu3231 2 года назад +1

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

  • @hariprasath3871
    @hariprasath3871 4 года назад +19

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

  • @demonicsyndrome
    @demonicsyndrome 5 лет назад +4

    Legend, subscribed!

  • @srjons_official
    @srjons_official Год назад

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

  • @dereksneddon6386
    @dereksneddon6386 2 года назад

    Great explanation man! You earned a sub!

  • @emonymph6911
    @emonymph6911 2 года назад +3

    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 года назад +2

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

  • @christiancramer3379
    @christiancramer3379 3 года назад

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

  • @pvd4170
    @pvd4170 Год назад

    Thank you for a such helpful video!

  • @stathisi.5883
    @stathisi.5883 Год назад

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

  • @justingolden21
    @justingolden21 3 года назад +1

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

  • @ridl27
    @ridl27 4 года назад

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

  • @zelytics
    @zelytics Год назад

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

  • @littleweirdo96
    @littleweirdo96 3 года назад +2

    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.

  • @BrownFreelance
    @BrownFreelance 2 года назад

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

  • @travisblogstravis4367
    @travisblogstravis4367 3 года назад +2

    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

  • @pankajjoshi8292
    @pankajjoshi8292 3 года назад +1

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

  • @br6719
    @br6719 4 года назад

    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

  • @ioannisme7495
    @ioannisme7495 4 года назад

    thank you, very helpful

  • @randy4443
    @randy4443 2 года назад

    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

  • @rubeushagrid4131
    @rubeushagrid4131 3 года назад

    You are life saver.

  • @zarazada
    @zarazada 3 года назад

    Thank you 🙏🏻

  • @niggisnonaz
    @niggisnonaz 2 года назад +1

    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

  • @Julia_Berrrlin
    @Julia_Berrrlin 3 года назад

    I'd like to learn more about escaping

  • @flashteq1030
    @flashteq1030 5 лет назад

    very nice explanation bro

  • @cmd9183
    @cmd9183 4 года назад

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

  • @wizardtechlabbs5902
    @wizardtechlabbs5902 3 года назад

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

  • @cyber_india
    @cyber_india 2 года назад

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

  • @farismazlan5157
    @farismazlan5157 2 года назад

    Awesome !

  • @lubu2960
    @lubu2960 Год назад

    very interesting!

  • @vishalverma5280
    @vishalverma5280 2 года назад

    2:00 magic!

  • @erzengaming
    @erzengaming 4 года назад

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

  • @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

  • @akhilpadmanaban3242
    @akhilpadmanaban3242 4 года назад

    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

  • @rpanda_old
    @rpanda_old Год назад

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

  • @kurdmajid4874
    @kurdmajid4874 3 года назад

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

  • @hus8860
    @hus8860 4 года назад

    Thanks bro

  • @rajashekhar433
    @rajashekhar433 4 года назад

    Looking for Js decoraters

  • @cengiz-ilhan
    @cengiz-ilhan Год назад

    hi again dudee

  • @hawaiigirl121
    @hawaiigirl121 2 года назад

    subscribed

  • @MisterOptimous
    @MisterOptimous 6 лет назад

    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  6 лет назад +2

      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 6 лет назад

      @@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 6 лет назад

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

    • @MisterOptimous
      @MisterOptimous 6 лет назад

      @@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  6 лет назад +1

      @@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.

  • @BarbaraMarshall-v6e
    @BarbaraMarshall-v6e 19 дней назад

    Robinson Amy Thompson Sharon Thomas James

  • @zachfenton608
    @zachfenton608 3 года назад

    that is amazing

  • @ShivamSan
    @ShivamSan 2 года назад

    bart simpson

  • @myworldbox
    @myworldbox 3 года назад

  • @ajitsaharan9445
    @ajitsaharan9445 3 года назад

    Ek like to banta h

  • @MonteLogic
    @MonteLogic 4 года назад

    wow

  • @xBadxGirlxLucyx
    @xBadxGirlxLucyx 3 года назад

    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.

  • @luizgustavoveneziani3646
    @luizgustavoveneziani3646 4 года назад +204

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

  • @r11sr
    @r11sr 3 года назад +2

    Simple and clear explanation! Thank you!

  • @natarajanmuthuraman5019
    @natarajanmuthuraman5019 4 года назад +49

    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 ''.

  • @anvayjain4100
    @anvayjain4100 2 месяца назад +2

    Odin project keeps sending me to this golden channel.

  • @iagomota4649
    @iagomota4649 5 месяцев назад +4

    Bro even your older content is fire!

  • @viallymboma9874
    @viallymboma9874 4 года назад +6

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

  • @maciejleszek7401
    @maciejleszek7401 3 года назад +3

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

  • @danser_theplayer01
    @danser_theplayer01 Год назад +2

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

  • @ravendfj
    @ravendfj 5 лет назад +8

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

    • @WebDevSimplified
      @WebDevSimplified  5 лет назад +7

      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.

  • @santra528
    @santra528 4 года назад +6

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

  • @arcanelore168
    @arcanelore168 6 месяцев назад +1

    Do you have a course on Javascript?

  • @davidjiang7929
    @davidjiang7929 4 года назад +3

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

  • @gaganyadav9569
    @gaganyadav9569 6 месяцев назад +1

    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!

  • @FBDev64
    @FBDev64 Год назад

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

  • @alfredosolorzanoaguilar3058
    @alfredosolorzanoaguilar3058 6 месяцев назад

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

  • @devikapluspoint8306
    @devikapluspoint8306 4 года назад

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

  • @marcusotter
    @marcusotter 6 лет назад +4

    Great tutorial as always :D

  • @aaa4363
    @aaa4363 2 года назад +1

    Thanks!

  • @LazyBearHQ
    @LazyBearHQ 11 месяцев назад

    Love u xD

  • @user-kn8nt5zm5n
    @user-kn8nt5zm5n Год назад

    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

  • @otesunki
    @otesunki 3 года назад

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

  • @dudeimadolphin4318
    @dudeimadolphin4318 6 лет назад +1

    hey man your face is covered by the wds symbol

    • @WebDevSimplified
      @WebDevSimplified  6 лет назад +2

      Thanks for the heads up. I removed it and it should take effect within the next few hours or so.

  • @yanrocha447
    @yanrocha447 2 года назад

    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?

  • @silenceplease5904
    @silenceplease5904 Год назад

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

  • @mrnobody1286
    @mrnobody1286 3 года назад

    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 ?

  • @biswajitsamantaray3117
    @biswajitsamantaray3117 3 года назад

    @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?

  • @sumantsagar9162
    @sumantsagar9162 4 дня назад

    coming from odin project "Trust the process-look how far you've already come! You've made incredible progress, and there's so much more ahead waiting for you. Keep pushing forward; you're on the right path to be an amazing web developer!"

  • @yashojha5033
    @yashojha5033 3 года назад

    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.

  • @thedmitryguy
    @thedmitryguy 2 года назад

    Nice like animation.

  • @theresioleefland1737
    @theresioleefland1737 4 года назад

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

  • @busyrand
    @busyrand 2 года назад

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

  • @codedynamics1
    @codedynamics1 3 года назад

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

  • @widibaka7058
    @widibaka7058 3 года назад

    very great video

  • @karansahu7710
    @karansahu7710 3 года назад

  • @ukgames304d
    @ukgames304d 4 года назад

    Xss = css

  • @number1neek
    @number1neek 3 года назад

    Pikaboo, baby Kyle! 😄

  • @almahdi2877
    @almahdi2877 4 года назад

    bro you are awesome..