Cross-site request forgery | How csrf Token Works

Поділитися
Вставка
  • Опубліковано 10 лис 2024

КОМЕНТАРІ • 71

  • @ruslannovikov8374
    @ruslannovikov8374 Рік тому +1

    I am very thankful for this explanation. Your channel allows me to get really helpful coding knowledges and also to improve my English!!!

  • @user-cx5ry5tt6s
    @user-cx5ry5tt6s 4 роки тому +2

    MY BROTHER!! Thank you so much ! I’m bad in English, but I excellent understand you. Respect! DjazakAllah hayran

  • @geekthegeek730
    @geekthegeek730 3 роки тому +2

    It was very helpful to me. Thanks man for explaining this concept in detailed

  • @StyleTrick
    @StyleTrick 3 роки тому +5

    How does this prevent the hacker from performing CSRF? The hacker can just read the XSRF-TOKEN Cookie from the client side code and add it as a header? Would love to get some clarity.

    • @shyamsundargoyal9251
      @shyamsundargoyal9251 2 роки тому

      I think if you are saving this token in cookie then it should be like session ids. A unique token for every logged in user

    • @chessking3248
      @chessking3248 2 роки тому

      I have the same question

  •  9 місяців тому

    extremely well explained and enlightening, thank you very much!!!

  • @sthakor10
    @sthakor10 3 роки тому +3

    Very well explained. Thanks

  • @dzen1234
    @dzen1234 2 роки тому +3

    I not completely understood. If CSRF token is saved in cookies the user browser will send cookies at intruder's link opening. Looks like sending CSRF token in some hidden form field is much better.

    • @shyamsundargoyal9251
      @shyamsundargoyal9251 2 роки тому

      You can make that cookie's samesite flag as strict. So it won't be sent on cross site requests

    • @chessking3248
      @chessking3248 2 роки тому

      @@shyamsundargoyal9251 The final request in a CSRF attack is not cross-site .

    • @mach1ne722
      @mach1ne722 26 днів тому

      You are correct. You need to have the CSRF token returned by the server, ideally somewhere in response body. If it's returned within the cookie, cross-site requests will include the Cookie (legitimate token) and the forged request might be accepted, depending on the backend logic.
      However, the CSRF token could be returned within the cookie, client-side JavaScript could there-after extract it via document.cookie directive and manually add it as a X-CSRF-TOKEN header. When the server expects the the token from the header and not the cookie, situation changes, because cross-site requests won't have this header automatically attached (unlike cookie) and the attacker doesn't know the victim user's token value, so the abuse won't be possible.

  • @redaelouahabi731
    @redaelouahabi731 2 роки тому

    Thank you very much, I was sicking for that really

  • @aldovargas8514
    @aldovargas8514 2 роки тому

    Is it expected that the XSRF token changes on every call? I have implemented but any call will retrieve a different token

  • @dev.jacek.grzegorczyk
    @dev.jacek.grzegorczyk 4 роки тому +2

    Hi, is it possible to run off the csrf "Are you sure you want to logout" screen in spring boot security for a non logged in users? By default it shows even if a user did not log in.

  • @marcosernestoalarconhermoz2470
    @marcosernestoalarconhermoz2470 3 роки тому

    If it wasn't too much trouble, is the example repository available?

  • @shashikumar9068
    @shashikumar9068 4 роки тому +1

    Hello...Is it possible to enable CSRF and HttpOnly/Secure(for JseesionId) in the same time?

  • @AjayRathor3926
    @AjayRathor3926 10 місяців тому

    Well explained.

  • @gofarputra9284
    @gofarputra9284 2 роки тому

    Is the csrf token is changing every requests or remain the same?

  • @АлександрСидоров-ъ1ж7ь
    @АлександрСидоров-ъ1ж7ь 7 місяців тому

    Great video ! Thanks a lot

  • @rahulsinha3267
    @rahulsinha3267 3 роки тому

    Superb! Well explained!

  • @robgreen9112
    @robgreen9112 4 роки тому

    which course is this a part of? youtube is not linking the previous episode

    • @EgorlandiaxTsar
      @EgorlandiaxTsar 2 роки тому

      Hello! Here is the link (SpringBootSecurity) ua-cam.com/video/her_7pa0vrg/v-deo.html

  • @avatargirase
    @avatargirase 4 роки тому +2

    How this prevent someone from impersonating by using the same csrf token?

    • @StyleTrick
      @StyleTrick 3 роки тому

      Yes, the hacker could write code to simple get the XSRF-TOKEN from the cookies on the client side?

    • @shyamsundargoyal9251
      @shyamsundargoyal9251 2 роки тому +1

      @@StyleTrick the cookie that you are sending should have samesite flag as strict. So it cannot be sent with cross site requests. Also to avoid xss, cookie should be httpsecure so that client side js cannot access it.

    • @ilyaslyusarchuk3664
      @ilyaslyusarchuk3664 2 роки тому

      @@shyamsundargoyal9251 so how does it work from postman (copying the CSRF token) and not from a malicious website?

    • @mach1ne722
      @mach1ne722 26 днів тому

      The attacker would need to extract the token from victim browser. This could be achieved with for example a XSS attack (Cross-Site-Scripting). XSS almost always defeats CSRF protection as it is more severe client-side vulnerability. In that case, you need to take care of the XSS problem first, or any other form of sensitive data leakage from your site. Once the token is safe, CSRF protections will then hold. Otherwise, hackers cannot get the victim user's valid XSRF-TOKEN and request forgery protection works.

  • @Aman-Thakor
    @Aman-Thakor 4 роки тому +1

    Sir, If I'm using angular as frontend and rest API in spring boot with security at the backend and I'm not using cookies anywhere in the entire application, I'm using localStorage. Does it make sense to use CSRF and if yes then how when I'm not using cookies? Eagerly waiting for your reply!

    • @kishoreramana1
      @kishoreramana1 2 роки тому

      best way is sending the token in the hidden field.
      [...]

    • @shyamsundargoyal9251
      @shyamsundargoyal9251 2 роки тому

      @@kishoreramana1 I think for this to work you need to send a changing token every time because if a hacker is targeting a particular site he can use the value of this csrf token if it is same always.

    • @kishoreramana1
      @kishoreramana1 2 роки тому

      @@shyamsundargoyal9251 we would need to generate a new csrf token whenever user logs in or refreshes the session, then it would be unique for that session.

    • @mach1ne722
      @mach1ne722 26 днів тому

      If you are using localstorage and utilizing this session ID within the header, such as Authorization: Bearer and not Cookie, then your app is secure.
      Reasoning: Cross-site malicious requests will have only victim user's session Cookies attached within the request, other headers won't be attached automatically, meaning that requests won't pass as authenticated, preventing the attack.

  • @basavaraj2065
    @basavaraj2065 3 роки тому

    Where is the full code/github link for this ?

  • @rezokobaidze8501
    @rezokobaidze8501 2 роки тому

    when i get csrf token from backend it is not set in cookie automaticaly

  • @uvillanueva95
    @uvillanueva95 4 роки тому

    I understand how CSRF attack works,but, why the cookie protects the server? The attacker cannot copy that CSRF token inside the cookie? If you have the client token and the user token, you have all, no?

    • @cse8617
      @cse8617 5 місяців тому

      Browser is smart enough to only allow a website to access its own cookie, now website can access the cookie of other website

  • @howiewhite4773
    @howiewhite4773 3 роки тому +1

    Wheres the git?

  • @ceki9900
    @ceki9900 2 роки тому

    I'm not getting any cookie when sending get request?

  • @borisdimitrijevic-v6d
    @borisdimitrijevic-v6d Рік тому

    Amigo can u please help em solve dissapering csrf in react application using spring boot

  • @geeksforstudy7661
    @geeksforstudy7661 Рік тому

    csrf token every time change per post request how to handle in angular

  • @kaarropll95756
    @kaarropll95756 3 роки тому

    my spring do not creat the scrf token, i have no cookies :(( help

  • @arghyamitra3281
    @arghyamitra3281 Рік тому

    If we are using jwt do we need csrf enabling?

  • @ginadi9733
    @ginadi9733 4 роки тому

    Thank you.

  • @chocciemliki7910
    @chocciemliki7910 4 роки тому +1

    I HATE FUCKING GAMESTOP KEEP SAYING IM TRYING TO DO THIS

  • @brian_mckenzie8317
    @brian_mckenzie8317 4 роки тому

    I have a question ... I already have the knowledge on IDOR, CSRF vulnerabilities but I need to practice .. like chess ... I am happy there are softwares I can practice on relating to chess ... because I can test out ..reaarange..apply...try out anything I have learnt ... so saying that ..
    are there any websites or softwares I can buy that has like 100's of IDOR vulnerabilities that I can use Burp on and practice all night?? Thanks.

    • @amigoscode
      @amigoscode  4 роки тому +1

      not sure I am afraid

    • @gindudheer5539
      @gindudheer5539 4 роки тому

      Yes, OWASP has a few vulnerable by design websites for you to practice on. Check it out

  • @hadifox
    @hadifox 4 роки тому +1

    hallo amigoscode , if i want to start learn java programming can you share tutorial link for beginner ^_^ , Thank you ...

    • @amigoscode
      @amigoscode  4 роки тому

      planning to record a course

  • @justindavis7654
    @justindavis7654 5 років тому

    what version of postman are you using my ui looks different from yours

    • @amigoscode
      @amigoscode  5 років тому

      Justin Davis I was using a deprecated version. But the new one is quite similar

    • @justindavis7654
      @justindavis7654 5 років тому

      @@amigoscode do you do any front end ui stuff with angular?

    • @amigoscode
      @amigoscode  5 років тому

      Justin Davis no angular so just react 🙂

  • @lifestealerarmlet6795
    @lifestealerarmlet6795 11 місяців тому

    Can you provide source code for this video

  • @justindavis7654
    @justindavis7654 5 років тому

    hey im not getting all those cookies that your getting all im getting is a jsessionid how do i get what your getting

    • @amigoscode
      @amigoscode  4 роки тому

      Full course is now out. Check my channel for the latest video

    • @truth-seeker-2300
      @truth-seeker-2300 4 роки тому

      Hi Justin, if you have figured out how to get that csrf token while sending a GET request, sharing the workout is highly appreciated :)

  • @ugurersoy4304
    @ugurersoy4304 5 місяців тому

    great

  • @عابثالأخير-ز9ي
    @عابثالأخير-ز9ي 5 років тому +1

    amazing your channel

    • @amigoscode
      @amigoscode  4 роки тому +1

      Thanks. Subscribe for more

  • @عابثالأخير-ز9ي
    @عابثالأخير-ز9ي 5 років тому

    sir can you give one cousre about BDA postgresql

  • @chocciemliki7910
    @chocciemliki7910 4 роки тому

    I JUST WANT A FUCKING CONTROLLER AND I DONT HAVE MY CREDIT CARD ON ME SO IM DOING IT ONLINE