Insecure Deserialization Attack Explained

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • #Deserialization #WebSecurity
    We'll explore the basic concepts of an Insecure Deserialization by attacking a web app written in Python.
    🐤 Twitter: / pwnfunction
    🎵 Track: Warriyo - Mortals (feat. Laura Brehm)
    NCS link: • Warriyo - Mortals (fea...

КОМЕНТАРІ • 243

  • @PwnFunction
    @PwnFunction  3 роки тому +213

    eyJtZXNzYWdlIjoiaGVsbG8gdGltZSB3YXN0ZXIsIHdlbGNvbWUgdG8gdGhlIGNsdWIuIiwgInNlY3JldCI6Imh0dHBzOi8vYml0Lmx5LzNqc1BxUXoifQ==

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

      Cool

    • @mrhappysmiley2968
      @mrhappysmiley2968 3 роки тому +35

      I hate you

    • @RnVjayBZb3V0dWJl
      @RnVjayBZb3V0dWJl 3 роки тому +23

      Well that was mean! xD But i like it ;)

    • @anushmanglani5979
      @anushmanglani5979 3 роки тому +4

      Smart Ass!!
      BTW: how can you italicize the python keywords in VSCode?

    • @sodiboo
      @sodiboo 3 роки тому +28

      Can’t copy youtube comments on mobile :(
      But i recognize the ey, that’s JSON!

  • @fr0mage
    @fr0mage 3 роки тому +167

    Amazing video! It would be great if you could also include a small section at the end on how to defend against these vulnerabilities for the blue team people out there :D

    • @PwnFunction
      @PwnFunction  3 роки тому +67

      Noted

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

      Yes it is....

    • @mabakalox2353
      @mabakalox2353 3 роки тому +11

      The simple way to defend against such attack is to check cookie string at first place, that this cookie was created by your server, before calling serializer. I mean Digital signature at cookie.

    • @dacid44
      @dacid44 3 роки тому +16

      Certain serialization methods are also more secure than others. For example, don't use pickle. It literally has a huge warning at the top of it's documentation saying not to use it to (de)serialize untrusted data. Other forms like JSON are more secure (though check documentation for whichever library you might want to use to be sure.) This can still depend on your implementation though. JSON isn't secure just because it's JSON, if you write a deserializer that generates and runs code from the JSON, that could still be a vulnerability.

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

      @@dacid44 just write the serialization and deserialization yourself with two methods. Boom easy

  • @wnathanielw
    @wnathanielw 3 роки тому +223

    This channel is so underrated

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

      completely, i just discovered it, the end music is perfect

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

      @@loanqypol6797 agreed

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

      It's a programming channel
      No matter how good it is, most people are sadly extremely bored by programming content

    • @darknessandbelow.4640
      @darknessandbelow.4640 3 роки тому +2

      @@thatguy5277 In fact, Programming is actually so enjoyable if u wish to learn it.

  • @rishabhtiwari6641
    @rishabhtiwari6641 3 роки тому +48

    Just imagine if this guy creates his own course. That would be crazy.

    • @mr.rabbit5642
      @mr.rabbit5642 Рік тому

      Is that sarcastic or there truly aren't any? :((

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

    I don't see how python is particularly vulnerable to this. You using an insecure package is not the languages fault.

    • @alagaika8515
      @alagaika8515 3 роки тому +6

      Especially if the documentation of the package screams THIS IS INSECURE! DO NOT USE WITH UNTRUSTED INPUTS

    • @lismanrazvan5783
      @lismanrazvan5783 2 роки тому +2

      it's about the concept...

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

    So normally the client would send a pickled + base64 encoded session object to the server? That means there should be Python running on the Client Browser? This is the easiest security hole to stuff, just don't use pickles. Use JSON or XML instead.

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

      youre right, I didn't even know someone would actually restore objects in this way.

  • @batatakhizou4509
    @batatakhizou4509 3 роки тому +15

    One of the best tutorials channel out there, MADE RESPECT TO YOU

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

      made respect. yeah-...

  • @marlon582
    @marlon582 3 роки тому +22

    Your timing with these videos is pretty good! When I finished a challenge about Server-Side Template Injections you uploaded the video about SSTIs. And today I finished a challenge about Deserialization Attacks and now you uploaded this! Haha, keep it going man :)

    • @PwnFunction
      @PwnFunction  3 роки тому +30

      I can see the future because your computer is my computer.

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

      @@PwnFunction 😂😂

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

      😂

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

    I don't get the web exploit:
    1.Does the server must have python installed or is this some kind of a asm shellcode?
    2.You didn't show the deserialization code on the server
    3.How can one distinct between local effects and remote successful rce?

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

    came for the penguin profile pic, stayed for the awesome content

  • @RnVjayBZb3V0dWJl
    @RnVjayBZb3V0dWJl 3 роки тому +8

    I found your channel earlier today when trying to search for anyone explaining the difference between XSS in HTML and XSS in json requests. Haven't had the luck but saw your XSS video. Loved it a lot and shared it with my co-workers! Trying to advance myself in web application pentesting and understand everything. It's rare to see people explain in a good way and even get things drawn graphically in front of you. It helps a lot so thank you!
    I've been working with this for about a year from being freshly new from university. All you learn is mostly the theoretical part and not the practical. What i've recently noticed is that i lack the knowledge in HTML to be able to perform and really understand XSSes. So i have also been on the look out to create a web application and use some HTML to really understand JavaScript.
    p.s Just got myself two 1TB M2 SSD for my Raspian :P Already have pi-hole installed and will now fiddle with creating an OpenMediaVault to create my own NAS. Hoping by fiddling with stuff like this, will give me more knowledge in actual hacking and understanding it all. Will be fun! Love your videos! have only seen two of them. Saving the rest for the weekend. Good job with them all and greetings from Sweden! :P

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

      I very much appreciate comments like these, thanks.
      Also I do think it's necessary for one to learn HTML and Javascript to understand XSS on a fundamental level.

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

    If you Deserialization object with verificarion is your fault not pythons , This can be done with any Language, nice video btw.

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

    Quick question: how did python code run in the server? Is it converted to ASM or some global language?

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

    You're doing an amazing job. I have no idea why you don't have like 2 mil subs. I'm sure that in like a year or two we'll be there as well.
    Greetings from a fellow Gen Z-er from Croatia

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

    I have a request dear brother/mentor. You are posting really good stuff here 😊 big congratulations for that 😊👍. We need a complete course from you covering all the basics to advanced of hacking... So that it is helpful for lots of new comers like me. 😊👍 Hope you consider this !!!!

  • @mukulgaut
    @mukulgaut 3 роки тому +6

    Just one word PERFECT

    • @PwnFunction
      @PwnFunction  3 роки тому +4

      🙏

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

      @@PwnFunction 🙏

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

      @@ifelseprog
      SO PERFECT
      function subscribe2PWN()
      Redirection.load = subscribe
      Site.function.load = www.youtube.com
      (Not real html js)

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

    and that's why you should always sign this kind of stuff

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

    Most disturbing part of this is that the server runs windows(or at least powershell).

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

    who in their right mind just unpickles random data?

  • @Omar-wm9kz
    @Omar-wm9kz 3 роки тому +3

    the only teachers which i like Pwn for these awesome videos and net-ninja for explainning java script and web technologies.

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

    great video! Got a ton out of this! Thank you so much for all your amazing content!

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

    what font do you use for terminal?

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

    Not only that your explanations are great, but you got a huge talent to draw/sketch, so you should change the hobby... (just kidding). :)

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

    amazingly i understood every bit of it...Thanks..it means alot!!!

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

    Thank you
    Please , api attack

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

    Well done with ilustrations and quite a good explanation. Definetely would be useful to also hear how to defend against such attacks )

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

    Who uses pickle for serialization/deserialization on production?

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

    so Insecure deserialize have 2 category?
    - binary
    - Web Application?
    thats right?

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

    Veautiful video man
    You deserve the like and subscribe

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

    i know this is old, but my question is, why the f!ck does python serialize methods? can't it have just a class that you then initialize like a struct in C(++) somehow (not familiar with python) with only the member variables and the methods will be stored only in your code?

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

    1:04 I love how you took a moment there and then actually estimate "5 hours or so" as though it was meant to be precise :D

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

    how about to Link the Stackoverflow post?

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

      stackoverflow.com/questions/19855156/whats-the-exact-usage-of-reduce-in-pickler

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

    What software do you use for your screen explanation

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

    Your vids are amazing, thanks so much!

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

    Is this vulnerability still exists in Django?

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

    thanks a lot for this very educational content

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

    pretty sure he's using Operator Mono as a font.
    $150 flex lmao

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

      If you like seeing cursive in a monospace font, definitely give Victor Mono a try. It's a great free alternative. It also has a fair amount of ligatures supported and is quite stylish. Personally I use it in my code editor to stunt on tasteless peasants.

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

    Basically, creator of the website trusts that you have given valid inputs instead of they checking your inputs.

  • @eduardoandrescastilloperer4810
    @eduardoandrescastilloperer4810 8 місяців тому

    As Patrick star once said:
    I’ve come for your pickle!!!

  • @Vazzible_gaming
    @Vazzible_gaming 6 місяців тому

    I have a good idea for you, might I suggest you try giving us some QNA notes or questions at the beginning of each video, giving us the necessary question, and then you go onto answer the questions in depth in the rest of the video.

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

    binary from title says "FU" lol

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

    _lets write insecure code and show it's flawed_
    C'mon, who writes that?

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

    imagine a noob friendly, new and popular language having an exploit such as this

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

      It's not a problem with the language, its the serialization library that has the exploit. It even outright tells you not to use it for anything untrusted.
      Not even the most security careless developers would use this kind of serialization in such a way so I'm not sure why this video was made.

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

      @@someonerandom9939 ah that's some good context the video maker should've included, thanks

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

    Hi , amazing video. Its possible let the app available to download in a docker environment ?

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

    Great explanation of what de/serialization is !

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

    Your video quality is insane!

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

    Absolutely Beautiful!

  • @天馬-u6f
    @天馬-u6f 2 роки тому

    even json deserialization is enough to break your machine. i see no reason to use pickle unless it is encrypted after serialization

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

    I swear Dude you're fuckin' genius Allah bless you

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

    Quality content like this is what is needed more. Kudos to you mate - waiting for more.

  • @mr.rabbit5642
    @mr.rabbit5642 Рік тому

    Is 490 some joke of "XD" or was it actually 2020? :D

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

    I have nothing to add, but to support this channel I will leave a comment.

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

    one question, wouldnt this be an issue for all the existing restapi code we have,?

  • @tbc...
    @tbc... 2 роки тому

    What is the typography you're using on your vscode instance?

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

    really cool and easy to understand. Agree @NathanielWard

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

    WTF with this language? It serializes method bodies of objects? That's BS.
    Why would you ever do that? It is the same as someone upload to your server a sting of code to execute.
    Serialisation and deserialisation must be used only for data in objects (and this still have vulnerabilities)

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

      It does not serialize actual methods, but it does serialize the tuple returned by the __reduce__ method, the first item of which is taken as the name an object that the deserializer calls, expecting it to return an initial version of the serialized object to be reconstructed. This call can be to any bound function in memory at the time of deserialization, which is what allows the exploit.
      The pickle serializer was never intended to be used with untrusted data, certainly not from a user cookie in a web application. The pickle module documentation conspicuously warns about this.

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

    Yeah cyberpunk do look like that xD.

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

    How do i know that the website has the vulnerability

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

    this is same thing happen last year about Drupal8 CMS , serialization RCE

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

    Wait, what is the source code of the webpage ?

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

    You awesome thank you

  • @VigneshWaran-jr1if
    @VigneshWaran-jr1if 3 роки тому

    I got error on def __reduce__(self) in this line

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

    Great video!!

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

    Did somebody know which musik playes in the backround
    PS: thanks for your great videos

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

    That Keeanu Reeves joke was funny man

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

    Yo i have a question ! Is Laravel safe against these type of attacks ? Compared to Django witch is using python ( a prototyped style of OOP) it's possible to inject some functions in session cookie and execute them using something like constructor, but for Laravel i think it's impossible to do the same thing, so please correct me if i m wrong , and thanks in advance.

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

    I think K. Reeves is 491 in 2021. But the rest of the video is fine. Jokes apart, excellent as always

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

    I like science fiction. It's like in one of those movies!
    Although this might / might not serve as proof of concept, I cannot imagine who would install those tools on the web server, nor how you could run them. I cannot tell how that PS crap works but why not just listen? I like the sparkle of interest it arouses but keep it real.. the day I see you open a console on port 80 you will lose a subscriber

  • @Rene-tu3fc
    @Rene-tu3fc 3 роки тому

    it's pretty sad that people build systems that are actually this dumb. If I were to review a PR of an api that consumes a pickled object I'd make sure to close the PR instantly to make sure it doesn't get merged by others approving lol

  • @ukaszkiepas57
    @ukaszkiepas57 3 місяці тому

    thank you !!!! Awesome !!!

  • @adityyyaaa
    @adityyyaaa 2 місяці тому

    you hyped me up for cybersec

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

    what is your font in visual studio?

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

    Lession learned, just use json instead

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

    Channels underrated but only one request would like mic volume to increase!!! 😍

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

    This means the server should store cookies in python pickles, so that when reading pickled cookies to unpickle it, the bad code runs, this is a very specific situation, but its still a cool way to explain serialization and to say to not copy&paste random code into web compiler

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

    Never, ever trust user-supplied data.

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

    I mean you have clear warnings in pickle docs, for a moment I thought you pulled it off as json

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

    Thank you so much for your explaination, cant find anywhere else better than yours, hope you can make a lot more videos related to web vulnerabilities :D

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

    I didnt see comin, it was so fast !!!

  • @sajidali-hs4vv
    @sajidali-hs4vv Рік тому

    каждый раз 10% это здорово спасибо за связки

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

    Hey buddy 😕 what happens to your voice? Are you ok?

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

    As I said the best UA-camr of Indian web security community.
    If you don't know he is Indian!.

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

      Any references? I can't believe it 😅

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

      Ok i see now, from his intigriti profile

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

      @@sudhanshurajbhar9635 We are proud of him😎

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

      wow nice. his pronunciation is really good

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

    Maan ! Love your videos !

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

    The gif of the person banging his head against the desk accurately sums up my pentesting career… love all your content btw

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

    Are Django websites vaulnarable to this attack? If so, how can it be prevented?

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

      Nothing that doesn't use pickle is vulnerable to this
      Pickle is not a normal (de)serialiser, it's an unsafe one, by design. It's made for a completely different use-case.
      The python documentation on pickle is full of warnings about using it on untrusted data.
      Most webapps use safe (de)serialisers and formats, like python's builtin 'json' module for the json format

  • @lisannasil2346
    @lisannasil2346 6 місяців тому

    you're a legend!

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

    Wowww the intro is killer

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

    How come the base-64-encoded cookie has a run of AAAAAAAA in it? Is the cookie screaming? Does it need help? *Should I be concerned!?*
    (but no really why is that there?)

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

      In Base64, the letter “A” corresponds to the bits “000000”.

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

      @@cmyk8964 So, long runs of zeroes get converted into A's. Or, emptiness gets converted into screaming. Sounds like midlife crisis.

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

    awesome presentation.

  • @Pekatcho-y1d
    @Pekatcho-y1d 3 місяці тому

    amazing 🔥

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

    Simple but great. Good work.

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

    I hit like button at your example of Serialization! Great video and explanation! Thanks

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

    That was lit

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

    Love your content, man! I'm curious about what you use to draw on screen? What software & hardware do you use for drawing?

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

    man it's so damn cool! please keep creating videos. you'll be successful

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

    XD: very satisfying shell

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

    Keep going man, pretty underrated channel. I bet it'll gain some more popuation over time. The video has good quality.

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

    I hope to see more videos on your channel. This content is special

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

    + 1 sub 👍

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

    are there any vulnerable test apps you recommend to practice this? can you share what you used?