HomeVideos

Vim Has A 0-Day????

Now Playing

Vim Has A 0-Day????

Transcript

287 segments

0:00

It turns out that if you just open a

0:02

file, Vim could do a remote code

0:05

execution. I know my boy Vim has been

0:07

caught. I'm not sure if it's possible to

0:09

recover from learning that my

0:11

personality, my love of my life, will

0:14

allow people to get hacked. So, you

0:15

know, I got to yap about this one just a

0:17

little bit. And of course, it turns out

0:19

that also Emacs might have something as

0:21

well. And the big kind of like might

0:23

shyamalan part here is that Claude was

0:27

the one that found both of them. We

0:29

asked Claude to find a bug in Vim. It

0:31

found an rce. Just open a file and

0:34

you're owned. We joke fine, we'll switch

0:36

to Emacs. Then Claude found an rce

0:39

there, too. All right, so let's actually

0:40

go over them cuz it is it is shockingly

0:42

interesting. I've never I didn't know

0:44

these things about Vim. All right, so

0:46

here's an example file right here. This

0:48

is a test two.typescript

0:51

file. And inside of it, I just have this

0:53

nice little test mode line. It has a 69

0:55

being returned. Nice. And over here, you

0:57

can see right here, this is called my

0:58

color column. It lets me know when I'm

1:00

at 80 columns or longer. Now, I'm going

1:02

to open this just test.ts. You'll notice

1:05

that my color columns are right here.

1:08

That is because the last line of the

1:09

file, which by the way, can be the first

1:10

couple or the last couple, has this

1:12

thing that says vim, and then actually

1:14

has a command. Hey, set the color column

1:15

to 20. If I were to go set color column

1:18

to say uh 69, nice. It would move it

1:21

over here. So upon opening this file, it

1:24

actually executes these arbitrary

1:26

commands that are right here. Now,

1:27

normally this is completely safe. But if

1:30

I open this file right here, it's not

1:33

safe. Well, it is safe for me because I

1:35

actually use Neoim. I don't know if you

1:36

know this, but like Neoim's like

1:39

but Vim uh the original, you know, the

1:42

the OG, this would actually cause a

1:45

remote code execution. So, how this one

1:47

works is actually it's it's pretty

1:49

interesting. So, I kind of spread it out

1:50

so it's a little bit easier to see. So

1:51

the first thing you need to know I'll

1:53

just do right here. If I highlight this

1:55

line, press colon, it says, "Okay, here

1:58

is a selection over this range that

2:00

you've highlighted." If I do a bang, it

2:01

says, "Okay, you can execute now

2:04

something on the command line from right

2:05

here." And we'll pipe your highlighted

2:08

selection onto the command line. So if I

2:10

just say pass in uh jq, it will actually

2:13

execute jQ with the contents of that

2:15

line. And then jq of course pitifies it

2:17

and then it will send it back into my

2:18

editor. Bada bing, bada boom. Free

2:20

pritification. By the way, that means I

2:22

can also highlight that thing. Go right

2:23

here. Passion- C and it will compact it.

2:26

So, what's happening here is first we

2:27

say, hey, show the tab panel. Here's an

2:30

example of the show tab right here. As

2:32

you can see at the top, you have your

2:33

Vim RC, you have a new file, you have a

2:35

readme open. You can think of tabs

2:37

pretty much like tabs you would have in

2:39

VS Code or anything else. But, of

2:41

course, Vim being Vim, you can actually

2:43

set how the tab panel renders. Now, the

2:46

special part about that is that with the

2:48

tab panel, it actually accepts this

2:49

little special string right here, which

2:51

will execute the insides of it as a

2:53

command. So, if it starts off with a

2:55

nice percent sign open bracket, you can

2:58

then do a command inside. And that's

2:59

what we're doing. We're doing an auto

3:01

command. If you're not familiar with an

3:02

auto command, autocomand just says,

3:03

"Hey, when some action in Vim happens,

3:06

we will call a function for you or we'll

3:08

execute a command on your behalf." And

3:10

you can kind of set them up that way. If

3:12

I add, say, a bunch of white space on

3:13

the end right here, I hit save. That

3:15

white space, well, it's gone. Auto

3:17

commands. So, this tab panel when it

3:19

renders, it sets up a command that will

3:21

fire off when safe state again executes.

3:24

Now, safe state again is just when

3:26

nothing is executing in Vim. It's just

3:28

like when you return to nothing

3:29

happening. This will happen for all

3:30

files. And the command right here will

3:32

actually go out to the command line, get

3:34

your current user ID. There's mine right

3:37

there. Isn't that beautiful? Look at

3:38

that. You got u you got UID prime, you

3:40

got g, you got groups, you got docker

3:43

input wheel, and it's going to pipe this

3:45

thing out to this location right here,

3:47

temp. And then it's just going to do it

3:49

once and then unregister itself so it

3:51

doesn't do it over and over again. Now,

3:52

if I were using Vim and the correct

3:54

version, this would actually cause this

3:56

command to go and execute on the command

3:58

line. So, you could actually send

4:00

somebody a file and when they opened it,

4:03

this would just execute on their system.

4:05

Thus, you could actually go and install

4:07

something. You could put a rat and we

4:09

all know about rats since that Axios

4:11

hacking. This is crazy. I never even

4:13

knew about modeline. I didn't even know

4:14

that you could set styles or do actions

4:17

or, you know, make Vim commands happen

4:19

on a per file basis. Personally, I have

4:22

absolutely no idea why you would ever

4:25

want to do that. But here we are. We can

4:27

do that. Apparently, this has to be some

4:30

sort of holdover from a time a a time

4:33

long a gone. you know, the old days of

4:35

Yore because I have never even heard of

4:38

this. I didn't even know this was a Vim

4:39

feature. I kind of feel like I want to

4:41

abuse it now, but it just IT I WHY WOULD

4:45

ANYONE do this? I'm sure there's a

4:47

perfectly good explanation. If you if

4:48

you if you know one, please let me know.

4:52

I just thought this was so interesting.

4:53

I thought you would find it interesting,

4:54

too. I just think it's even more crazy

4:56

that tab panel can actually execute an

4:59

expression like that if you just start

5:00

it off correctly. And so this entire

5:02

thing is just so wellcraftrafted. It

5:05

just seems like such a ridiculous thing.

5:06

Yet this will allow somebody to curl

5:10

out, be able to download a script and

5:12

then execute it, thus stealing all your

5:14

credentials off your machine. So it is

5:16

actually a very serious and actually

5:18

real bug. But they first have to get you

5:20

to open a file via Vim. I mean, so they

5:23

might be able to get they might be able

5:25

to hack like 25 people with this one,

5:26

but it is ser they could they could hack

5:29

all 25 people with this one. So now you

5:31

remember that obviously they also went

5:33

off to Emmac and they're going to own

5:34

Emacs next. Now this one I actually I

5:36

don't like. I don't find this one very

5:38

cool. It is actually kind of uh ah it's

5:42

kind of stupid. So the Vim one's scary,

5:44

but the Emacs one is scary in its kind

5:46

of own weird way and it's not really an

5:49

Emac bug at all. So let me get let me

5:51

show you let me show you the the gory

5:53

details. So what ends up happening if

5:55

you look at the actual reproduction

5:57

steps is it requires you to download

5:59

this tarball and then you have to untar

6:01

it and then you have to go in here and

6:03

open any file via Emacs within that

6:06

project and by just simply opening a

6:08

file you get owned. So this sounds scary

6:10

right? Well you can also get owned by

6:14

calling get status within that project.

6:16

So what actually happens is that inside

6:18

of this project there's a.getit git

6:20

folder and inside of that docon uh git

6:22

folder there is a git config. So the

6:25

exact contents of the config file look

6:27

like this. You do core and then

6:29

fsmonitor.get

6:31

a. Now a is just an executable script as

6:33

you can see right here. It's just an

6:34

executable script that pones out and

6:36

adds a line to this tempone. Now I've

6:39

set this up myself right here. So every

6:41

time I I cat this out, you can see that

6:43

it just keeps on getting longer because

6:45

every single time it changes, something

6:46

about the damon of the get fs monitor

6:50

gets executed, letting you know

6:51

something has changed. Thus, it keeps

6:53

getting longer. So when I call get

6:54

status, it will actually get longer by a

6:56

lot. So if I call this a whole bunch,

6:58

then I can go like this cat this bad boy

6:59

out. Now it's actually really, really

7:01

long. So that means whenever you make

7:03

any sort of change, git could end up

7:05

executing and doing something on your

7:07

behalf you don't even realize is

7:09

happening. But I want you to notice

7:11

something. Notice that I never once

7:12

opened Emac. So this entire thing right

7:14

here is a bit of a farce. But it also

7:18

kind of reveals a really crazy

7:21

insecurity I guess about Git. Something

7:23

I've never known. If you ever download a

7:27

project in and inside of there is a Git

7:30

folder. I would be a little nervous. I

7:32

never realized this could actually

7:34

happen. I can't believe it actually can

7:36

happen. And that means somebody could

7:37

have it. So that if you just simply go

7:39

into that folder, you get G get to do a

7:42

little bit of magic. Bada bing, bada

7:44

boom, you could be had by just simply

7:46

executing get status or having your uh

7:48

command line figure out what branch

7:50

you're on. Not cool. It's not this not

7:53

this is not cool. I will say at the end

7:55

of this they kind of say, hey, they

7:57

reported the bug to the maintainers and

7:58

the maintainers declined to address the

7:59

issue attring it to get. There is

8:01

something kind of weird about this. Like

8:02

this article is pretty cool that they

8:04

found such an amazing bug in Vim cuz

8:06

honestly super cool bug they found in

8:08

Vim. But the one in Emacs, I mean it's

8:11

evidently and obviously has nothing to

8:13

do with Emacs. It has everything to do

8:16

with Git. And this is one of the

8:18

problems of this future we're kind of

8:20

living in, which is that people file bug

8:23

reports without actually understanding

8:24

how these things work. It is very very

8:26

obvious exactly how this works. And just

8:29

a couple seconds of thinking through

8:30

this, you would go, "Oh, this is

8:32

actually a core git problem." But it can

8:35

only happen by overwriting a file that

8:37

only gets created at initialization

8:40

time, which means you're only

8:41

susceptible to this if you actually

8:43

download the entire directory and then

8:45

go into it because that would be the

8:47

only way they could sneak in a config

8:49

file, which still, by the way, I still

8:50

don't I I don't necessarily feel

8:52

comfortable. I feel like this one should

8:54

still like it. This still feels like a

8:56

problem with Git, but it certainly isn't

8:58

a bug with Emacs. And this is the

9:00

problem about giving people a really

9:02

great tool is that you can just inundate

9:04

people who are maintaining software

9:06

reporting bugs that aren't even related

9:08

to the software. Like this happened to

9:10

Curl. This is why Curl shut down their

9:13

hacker one stuff is because they kept

9:15

getting slop bug after slop bug. And

9:18

this just burns maintainers time. And so

9:20

the second one, I'm not going to lie to

9:22

you. I I really didn't feel too good

9:24

about seeing this one. But the first

9:25

one, I'll still give it to you. The

9:27

first one, that one was incredible. That

9:29

one blew my mind that you can actually

9:32

do that from Vim. The name

9:36

is the Vime. Hey, is that HTTP? Get that

9:40

out of here. That's not how we order

9:41

coffee. We order coffee via ssh

9:44

terminal.shop. Yeah. You want a real

9:46

experience? You want real coffee. You

9:48

want awesome subscriptions so you never

9:50

have to remember again. Oh, you want

9:52

exclusive blends with exclusive coffee

9:54

and exclusive content? Then check out

9:57

Cron. You don't know what SSH is?

10:00

>> Well, maybe the coffee is not for you.

10:07

Living the dream.

Interactive Summary

Loading summary...