Attacking Language Server JSON RPC

Поділитися
Вставка
  • Опубліковано 1 чер 2024
  • While auditing a VSCode Extension + Language Server I noticed something interesting. This turned into the research question "can we attack the extension from the browser?". After a bit of preliminary research I decided to do it again on stream, and eventually made this video. This is how security research can look like.
    What is a Server? • What is a Server? (Dee...
    What is a Protocol? • What is a Protocol? (D...
    GitLab 11.4.7 RCE • GitLab 11.4.7 Remote C...
    Live Stream: • Attacking VSCode Exten...
    My Font (advertisement): shop.liveoverflow.com/
    Interested in more videos like this? • Security Research
    Chapters:
    00:00 - Why Security Research?
    01:23 - What is a Language Server?
    02:53 - Setup Example Code
    04:00 - RCE in VSCode Extension?
    05:25 - The Language Server Code
    06:29 - Researching Communication
    11:13 - Can a Browser Attack the VSCode Extension?
    13:54 - Research Results
    15:40 - Ad n' Outro
    =[ ❤️ Support ]=
    → per Video: / liveoverflow
    → per Month: / @liveoverflow
    2nd Channel: / liveunderflow
    =[ 🐕 Social ]=
    → Twitter: / liveoverflow
    → Streaming: twitch.tvLiveOverflow/
    → TikTok: / liveoverflow_
    → Instagram: / liveoverflow
    → Blog: liveoverflow.com/
    → Subreddit: / liveoverflow
    → Facebook: / liveoverflow

КОМЕНТАРІ • 111

  • @Dominik-K
    @Dominik-K Рік тому +185

    There's no failed research, just fruitless attempts. And I learned a bit about the language server protocol too

    • @EstelonAgarwaen
      @EstelonAgarwaen Рік тому +12

      When you find out that something doesnt work, you still get the knowledge about how not to attack stuff

  • @MechMK1
    @MechMK1 Рік тому +32

    This reminds me of a project I was involved in for the past couple of weeks. Review of source code, really did a deep dive into it. Thousands of class files, going from broad architecture all the way to functional implementation. The final verdict? "Looks good, ship it"
    Just because you try really hard to find a vuln doesn't always mean there is one to find.

  • @sadDota
    @sadDota Рік тому +27

    that was awesome, ty
    showed me that research is not always/ doesn't need to always be fruitful, and now thinking about it I feel much better 😁

  • @tajsec498
    @tajsec498 Рік тому +3

    I love this video, it was great way of showing even failed research can teach us a lot.

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

    Great and very realistic showcase about how (security) research goes. Good job!

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

    It isn't even fruitless. You checked it, found no vulnerabilities, gained knowledge about VsCode Extensions.
    Nice work! 👍

  • @alexanderdell2623
    @alexanderdell2623 Рік тому +6

    It would be cool to do such content more often in live and upload recordings to the second channel.
    A good reminder that a research is when you fail significantly more times than you succeed

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

    great video! this was a really raw and honest demonstration of hard work.

  • @logiciananimal
    @logiciananimal Рік тому +2

    Great work - I don't regard the *research* as a failure; merely one avenue for exploitation is not seemingly possible - and that itself is a good result to communicate or at least know about.

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

    Thank you for posting this type of process! Learned a lot, and hopefully will be able to do research myself one day, thanks for all the quality content.

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

    Love the new fonts BTW ❤

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

    Oh this sparked my interest in vscode extensions. Definitely on my list of things to play around with some time.

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

    It's pretty cool to learn how the protocol works

  • @znxster
    @znxster Рік тому +4

    Learning what fails is often as important as learning what succeeds.

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

    This is amazing! Instant sub!

  • @MattKAva
    @MattKAva Рік тому +2

    Amazing video, helped me a little with my imposter syndrome as I realized I knew a little more than I expected I would!

  • @till8413
    @till8413 Рік тому +2

    im currently writing vscode language support for my own language, so this is very interessting

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

    Wow, you just blew my mind with the solution to the problem at 13:20! 😃
    I even paused to try and come up with my own idea, but didn't realize such a simple trick is enough...

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

    In the on screen text at around 7:30 you wrote the word mess twice!
    Amazing video though, incredibly informative and deep information :) I appreciate your work!

    • @anon_y_mousse
      @anon_y_mousse Рік тому +2

      Someone messed messed with his on screen text.

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

    Thank you, it is great, I do enjoy a lot over the journey. 👍

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

    That was informative. Thank you 🙏

  • @user-qw9yf6zs9t
    @user-qw9yf6zs9t Рік тому

    i love your videos man! every time i watch your videos i get a weird but amazing feeling.. as if i want to do cyber sec for the rest of my life haha, keep doing what youre doing :)

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

    Awesome video, thank you

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

    Thanks a lot
    I'm also searching for this

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

    Awesome talk!

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

    This channel and your content is very helpful in understanding how to go about security research and finding bugs. I have one question though : Are there any tools to identify how client applications communicate with servers without looking at the code ?(Or if the client app code is not available )

  • @RealCyberCrime
    @RealCyberCrime Рік тому +22

    I’m thinking about making a similar video in documentary format

    • @AkashSingh-uk5ub
      @AkashSingh-uk5ub Рік тому +4

      Congrats,your comment worked, i just subscribed. Make that video soon

    • @joshiy13
      @joshiy13 Рік тому +2

      + sub im exited

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

    Much needed Motivation

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

    great video!

  • @anon_y_mousse
    @anon_y_mousse Рік тому +3

    You tried Chrome for pipelining, but several other browsers still have it. Also, wouldn't multiplexing work just as well?

  • @testtest-xz6ec
    @testtest-xz6ec Рік тому +1

    This is not the first video of this channel about language servers. The video "Google Paid Me to Talk About a Security Issue!
    " it is explained how a language server with hacker controlled code can be used to execute code.

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

    It was very usefull 👍

  • @berndeckenfels
    @berndeckenfels Рік тому +3

    Isn’t LSP also used when VSCode is running in the browser, then it will use http and the LSP needs to be the server - or is a server side component doing that?

    • @1vader
      @1vader Рік тому

      Afaik in that case there is a separate VSCode server running somewhere else which among other things runs extensions and launches and connects to the LSP servers. It also works like this when you connect VSCode to a remote (though there also are extensions that run locally in that case, not sure how exactly that behaves in the browser, I guess maybe the local extensions can only be JS and run in the browser). Also keep in mind that the LSP "servers" aren't the kind of servers that run somewhere else in the cloud or something. If you run VSCode locally, they are just programs that will be started by VSCode on your PC.

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

    7:13 "Can an attacker mess mess with it?" :P

  • @strager_
    @strager_ Рік тому +2

    14:13 Could you write the second message in the body of the first message? The first message's HTTP body would be:
    {initialize-response-stuff}Content-Length: 123
    {malicious-request}

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

    Hey awesome research, just curious when you made it use socket instead of IPC (at 09:36) didn't you increased the attacks surface so that browser can be used? I mean if it just have used IPC it won't be vulnerable to this attack, right?

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

      Nvm, you did it for extension not the server. 👍

  • @Ashnurazg
    @Ashnurazg Рік тому +2

    I noticed the dog in the background at 14:22 for a few seconds :3

  • @ironnoriboi
    @ironnoriboi Рік тому +14

    4:20 This is actually false for Microsoft's own C# extension in vscode. That extension downloads the server and other tools (same ones that are used for visual studio and msbuild). They even auto-update by default.

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

    Thank you, Can you made a video series on " How to build Operating System" for example xv6 which is unix based open source project.

  • @LuLeBe
    @LuLeBe Рік тому +2

    Maybe it was just me, but even half way through the video I still wasn't sure whether you're trying to figure out whether a malicious codebase opened in VSCode with your extension active, or the extension itself is the attack. So are you trying to protect users of your extension, or are you trying to figure out whether an extension itself can be malicious? Maybe I missed it but that made it harder for me to follow.

    • @LiveOverflow
      @LiveOverflow  Рік тому +2

      I’m trying to figure out whether a malicious website can attack a VSCode extension that uses a language server via socket transport. Ultimately in the end I want to check whether my extension is safe against this potential attack

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

    I have one question for u, If IDE use languages code server for checking code on IDE, I think if we close the internet when we write code , Why IDE can check code error or not ?

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

    I dont think it is failed research. It is a clue which indicates that an attacker can probably not attack you using this method. I think that's worth a lot.

  • @Sumonsheikh-pz6ln
    @Sumonsheikh-pz6ln 10 місяців тому

    Awesome

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

    @LiveOverflow Can't you include another Content-Length header k-v pair in the request body?

  • @ilyasamarov
    @ilyasamarov Рік тому +2

    14:31 Isn’t it’s possible to overcome with web sockets? I think it’s possible to exchange messages on the same TCP connection.
    Also, all HTTP related tricks might not be needed. If I’m not wrong

    • @LiveOverflow
      @LiveOverflow  Рік тому +5

      Websocket is a bit more complex protocol that requires the server to play along

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

    Since pipelining did not work, have you tried relying on HTTP keep-alive? Since vscode won't close the connection, we only have to prevent the browser from closing it. If this works, you can just do two HTTP requests.
    Also, have you tried sending two payloads in the same message body (repeating the content-type for the second one)? I think VSC only reads only the number of bytes it needs to read to process the message (for perf reasons). So we maybe could just send two messages in a single request. Of course, this only works if the server doesn't expect anything from his first response in our second message.

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

    Would using WebSockets be an option? Or a custom http client being executed via WASM in a webworker?

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

    G🐐A T E D

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

    Why did that need to be from the browser anyway, since doing it from the user would require him to open the browser at the right time so attacking from the outside would be the only option, that could be possible since to my knowledge the messages aren’t encrypted and TCP spoofing could be possible, but since these connections will be made on loopback and cant be sniffed (by an outsider), it would require guessing the sequence number (which is technically possible i guess) and which open port is the server

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

      Because code in the browser has a lower trust level, websites are sandboxed. If an application running on your machine communicates with other applications, it’s expected. If you allow a website to execute code on your machine it’s much worse.

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

    Nice

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

    i like working backwards straight from what can i change/what is the user input :)

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

    Language server protocol, the way you explaining its pretty intresting.. though I know this stuff awesome video

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

    Let's be grateful that there's no security vulnerability to exploit in vs-code.
    So this is not a failure, but good news

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

    Push!

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

    Wouldn't it be possible for a malicious website to serve a web assembly program dealing with the communication to the language extension server that the connected clients run?

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

    I like when you talk fast and move your hands like you’re rapping 😂 I dare you to do a rap song about coding just for the lol’s 🤣🤣🤣

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

    Im gonna pick up the pieces and build a lego house

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

    Thank you.... i always wanted to do this... i am currently interested in LSP as i wasted past year configuring nvim.....
    Maybe i may try the same in neovim lsp... if it works....

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

      The LSP protocol is entirely different from this.

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

    if security research never failed, it would mean everything would be a vulnerability

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

    14:23 DOG!!!

  • @user-ot8tb8jk3t
    @user-ot8tb8jk3t Рік тому +1

    Curious. Is this video stretched in width? He looks wide.

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

    Hi, may I know how do you know it's port 1219?

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

    You said, it expects 2 messages. Can't you just post two of them as one block of POST? Faking ends and headers in the middle of your data if necessary? LG chris :)

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

    So connecting between processes using TCP is not secure because a browser can be running in the background.
    Well you can certanly find antipatterns in programs using it. Thats really strange that TCP can be supported at all
    On the second thought using TCP and assuming data that comes from it is somehow safe is wrong at all times.

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

      It's not that strange when you consider that it can be used remotely, e.g. for remote editor environments (like Visual Studio Code supports).
      Using TCP with TLS wouldn't make sense locally, because the request and responses would have to be encrypted and decrypted on the same machine anyway. In this case you can use TLS on top of the TCP connection that is established with a remote LSP.

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

    can we have an rpc deepdive?

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

    multipart/x-mixed-replace ??

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

    Pipes on windows or ports on mac? What? You mean pipes and ports everywhere?

  • @luizzeroxis
    @luizzeroxis Рік тому +4

    Wait, could you not just send multiple requests through the fetch api in a website?

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

    wouldnt http streams work with this?

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

    3 sekunden ich wusste sofort der spricht deutsch 😂

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

    Why was attacking it via a browser so important? Like you showed in python it's just a few lines of code.

    • @LiveOverflow
      @LiveOverflow  Рік тому +2

      It’s easy for an attacker to make the victim open a malicious website.
      Getting python code execution on the local computer is already game over ;)

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

    Looking at how frequently the lsp server is called why did they choose to go with json as opposed to binary encoding? Seems like a bad choice.

    • @Uerdue
      @Uerdue Рік тому +2

      I don't think it would make much of a difference performance-wise.
      Since no bytes have to be transmitted over the (slow) network, the performance cost of a single call to the language server is probably not going to depend too much on the length of the data to be sent, but will just be some more or less constant amount of time spent in kernel code (for the underlying IPC mechanism).
      So, with performance not being an issue, it makes sense to just make the API for the language server as programmer-friendly as possible. And there, JSON just wins over binary encoding. Sadly. :D

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

    It might not be a practical attack, but it's still a near-vulnerability, a la the swiss cheese risk model. And one straightforward measure that would stop any exploit dead would be forcing that initial status message to include an authentication token passed to the process in an environment variable.

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

      or just require that a particular header is set that no website sends by default

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

    4:31 someone clip this 😂

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

    Who do we not trust? some extension? some external attacker getting RCE on a computer because LSP is running on it? - What's the intro? What's the context?

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

      A malicious website. That’s why we explore whether we can attack the extension from the browser

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

      @@LiveOverflow Yeah, eventually that was answered. But initially it was not clear.
      - Also, I think it's just what direction the search turned toward. Not the initial goal.
      - I guess the initial goal was "try to find any vulnerability" be it local escalation, or external access etc ... but that's a weird goal to have... but I guess it's just "how safe is it to let someone use VSCode+LSP" inside our reasonably trusted LAN etc ...

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

      You literally described the video :D I had to do a security review of a vscode extension. And in the video I take you along researching one particular attack surface. It’s just the story from start to research result ;)

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

      And yes, that’s research. „Initially the goal wasn’t clear“. Of course it’s not clear, that’s science and looking into the unknown;)

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

      @@LiveOverflow Yeah, my bad. I didn't know exactly what "security review" is, so I was confused the first 75% of the video, before I figured out what the objective was.
      - As a software developer, I usually start by defining an attack surface. Don't worry with anything in the "trusted" scope, trust "nothing" in the outside world. Only caring about that one well defined surface to not go crazy. Otherwise I would never get anything done.
      - That's why it was hard for me to go along and think about the problem when that was not clear upfront.
      - It would have been useful for me to mention near the start we are looking for a vulnerability at any possible "level" (except not really untrusted extensions themselves?).
      - With VSCode extensions, I would be much more worried about evil/hacked extensions, dependency running a hacked script etc ... than an existing "backdoor" using it for escalation, or website injecting a script in my build...
      - But the browser direction was interesting. I always assume only local things can open connections to loopback ports, so never considered worrying about it (except extensions, tools that are local servers, etc) ... I wonder if my assumption is even right ... I never considered CORS at development time running on localhost.... O.O
      Great video, though. Thanks!

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

    07:13 2 mess?

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

    hellow everyone

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

    Been offered a really cheap deal for 1Gbps fiber but it's CGNAT only should I take it anyone? Yes or No? Answers appreciated.

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

    Am I completely off the mark for seeing this as quite a major at least privacy if not also security hazard?
    The JSON RPC language server can effectively read all the code you're writing. Also you were able to read TCP traffic in cleartext using Wireshark. What's stopping a MITM in this case?

    • @tropicbliss1198
      @tropicbliss1198 Рік тому +5

      If malicious code is able to read raw tcp requests like that, it’s effectively game over for the system, and there’s no need to exploit vscode to achieve what the hacker wants. And in reality not all communication within the system needs to be encrypted. One concern which is valid is privacy concerns, and unfortunately if you install an app on your system, you’re essentially giving it free reign to access whatever file it wants

    • @dealloc
      @dealloc Рік тому +4

      I think you'd have more important concerns if malware ended up on your computer in the first place.

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

    Please explain CVE-2022-37421 with example/demo or reply please

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

    first

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

    FYI your Twitch Link is missing a "/" after the ".tv"