TRANSCRIPTEnglish

OpenCode Got Hacked Badly (My API Keys Got Drained)

19m 8s3,513 words506 segmentsEnglish
“You can only show the real first and last eight characters if the real key is what's stored.”
▶ 7:14 · HEAR IT IN THE VIDEO

FULL TRANSCRIPT

0:00

You know that specific kind of dread

0:02

when you check your email in the

0:03

morning, half asleep and still holding

0:05

your coffee and the subject line says

0:08

unusual activity on your account and

0:10

your stomach just drops. Now imagine

0:13

that email is from Open AI or Anthropic

0:15

and instead of we noticed a login from a

0:18

new device, it says your API key was

0:21

used for 35 million tokens overnight

0:24

while you were asleep. That is not a

0:26

hypothetical. It happened to real

0:28

developers who were just building stuff

0:30

with AI tools and woke up to bills they

0:32

never ran up. One person lost $16 and

0:35

another person hit by the same attacker

0:38

on the same night lost $3,000.

0:41

And the crazy part is that the gap had

0:43

nothing to do with who the hacker was or

0:45

how sophisticated the attack was because

0:47

it came down to one setting that most of

0:50

us never even thought to set up. So, I'm

0:53

going to walk through what actually

0:54

happened with the Open Code hack and

0:56

then what we should all change before we

0:58

become the next person posting in a

1:00

developer forum at 2 a.m. asking why our

1:02

account just got drained. If you haven't

1:04

used Open Code, the short version is

1:06

that it is an AI coding assistant that

1:08

lives right inside the terminal, which

1:10

is where the code actually happens

1:12

anyway. And it lets us bring Claude,

1:14

GPT, Gemini, and the rest right there

1:17

alongside the work. I've been using

1:19

tools like this and the pitch really is

1:21

hard to resist. When we're three levels

1:23

deep into some rabbit hole, we just ask

1:26

right there instead of all tabbing out

1:27

to a browser and it feels like the

1:30

future. And that context matters for

1:32

understanding why so many developers

1:33

trusted it with their API keys since it

1:36

was not carelessness at all. And the

1:37

whole point of the tool is that you

1:39

paste your key in and everything just

1:41

works. Now this distinction is going to

1:43

matter a lot in a minute. Open code has

1:46

two parts. There is the terminal app

1:48

which runs locally on your machine and

1:51

then there is the console which is open

1:52

code's web dashboard. It works like a

1:55

settings panel in the browser where you

1:57

manage workspaces and paste in your own

1:59

API keys to use through their servers.

2:01

And that second part, the conso's bring

2:04

your own key feature is where everything

2:06

went wrong. When we look at the

2:08

timeline, I want you to notice not just

2:10

what happened, but how fast it escalated

2:12

because it is kind of terrifying. It

2:14

starts on Saturday, October 17th at 0:30

2:18

UTC, which is the middle of the night

2:20

for most of the world. That is the

2:22

moment when what Open Code later

2:24

described as a breach of a legacy system

2:26

apparently begins. Now, for a few hours,

2:30

nothing publicly visible happens while

2:32

the world is asleep and the keys are

2:34

just sitting there. And then at around 2

2:37

am Eastern, which is 6 a.m. UTC, a

2:40

developer named Colin Parsons watches

2:42

his Open AI key get pounded, which is

2:45

his word, not mine, for $281 worth of

2:49

API calls. And then his anthropic key

2:52

goes for another $168,

2:54

all within hours. Both keys, he said

2:57

later, had only ever been used in open

3:00

code. And that last part is what locks

3:02

this in because it was not a reused

3:04

password or some fishing site. So the

3:06

only place those keys had ever lived

3:08

outside his own machine was inside Open

3:10

Code's console. So he does what any

3:12

developer would do, which is post about

3:14

it publicly and ask Open Code directly

3:16

whether they'd been hacked. Within the

3:18

hour, someone else replies with a $1,700

3:22

loss. And then Matt Johansson posts

3:24

confirmed, open code hacked, key stolen,

3:27

and that post gets almost 800,000 views.

3:30

But Open Code's first public statement

3:32

does not go up until 1756 UTC, which is

3:36

17 1/2 hours after the exposure window

3:38

opened. To be fair, that's not nothing,

3:41

and they were clearly scrambling

3:43

internally. But from the outside,

3:45

watching people post their losses in

3:47

real time while waiting for official

3:48

word was rough. And the detail that

3:51

really got me is that some of the

3:52

providers moved faster than Open Code

3:55

did. One user said OpenAI warned him 9

3:58

hours before Open Code did. And

4:00

Anthropics Lydia Halley posted at 9:00

4:02

p.m. that they had already revoked the

4:04

clawed API keys they believed were

4:06

affected. So the company that lost the

4:08

keys was the last one to tell people.

4:10

Now we get to the part I find genuinely

4:12

fascinating from a technical standpoint

4:14

and also depending on how you look at

4:16

it, slightly face palinducing. Open

4:19

Code's official email to affected users

4:22

described the breach as reaching a

4:24

legacy system that we were in the

4:26

process of decommissioning. And that

4:28

phrase sounds like a dusty server in a

4:30

closet, something from years ago that

4:32

nobody uses anymore. But the actual

4:34

story is a little different. Open Code's

4:36

code is public, so anyone can read it.

4:39

And if we go and look, there's a commit

4:41

from Monday, October 12th, 5 days before

4:44

the breach, called remove legacy

4:47

database from console, which sounds

4:49

pretty thorough, right? But production

4:51

systems do not quite work that way. And

4:53

this is a nuance that matters. When you

4:56

deploy code, the code you deploy owns

4:58

the things it creates. But if a database

5:01

already existed before your code and

5:03

your code just had a pointer to it, then

5:05

deleting the pointer doesn't delete the

5:08

database which just sits there

5:09

unconnected and no longer used by the

5:12

new system but still very much alive.

5:14

What the deploy actually did was delete

5:16

the old login service and the database

5:19

password that lived in the new codebase.

5:21

The production database itself, the

5:23

actual thing holding the keys, was not

5:25

something that deploy had the authority

5:26

to wipe. So it was still out there and

5:29

in the dev environment the attempt to

5:31

delete it failed three times because it

5:34

was protected from deletion. So legacy

5:37

doesn't mean a forgotten relic from 5

5:39

years ago. It means a database the new

5:41

system had stopped pointing at still

5:43

holding live API keys 5 days after

5:46

somebody wrote a commit saying they had

5:48

removed it. I want to be fair here

5:50

because this kind of thing happens and

5:52

migrations are hard. Anyone can write a

5:54

commit in good faith called remove

5:56

legacy database and not realize the

5:58

production database isn't owned by their

6:00

deployment process. Still 5 days is not

6:03

a lot of time. There is one more

6:05

technical detail about how this data was

6:07

stored and I'm going to walk through it

6:09

carefully because it matters. In the old

6:11

database schema which is also visible in

6:13

open codes public repo. Your API key

6:16

went into a table called provider into a

6:18

column called credentials stored as

6:21

plain text which means it was not hashed

6:23

and it was not encrypted at the

6:25

application level. So it was just a raw

6:27

string exactly as you pasted it in. Now

6:30

to be fair there is context here because

6:33

database hosts almost always encrypt

6:35

data at rest. Meaning the files on disk

6:38

are scrambled. So it's not like anyone

6:40

with physical access to a hard drive

6:41

could read the keys off a platter. But

6:44

encrypted at rest and stored as plain

6:47

text can both be true at the same time.

6:49

This encryption protects against someone

6:51

stealing the physical hardware, but it

6:54

does nothing against someone who gets

6:55

access to query the database. And any

6:57

process that could run a select

6:59

statement on that table could read every

7:01

key in full. And the detail that

7:03

confirms it is the settings page. It

7:06

shows a masked version of your key with

7:08

the first eight characters and the last

7:10

eight and asterisks in the middle. And

7:12

in the code, that mask is generated from

7:14

the stored value. You can only show the

7:17

real first and last eight characters if

7:19

the real key is what's stored. And if

7:21

they had stored a hash, the masking

7:23

wouldn't work. So the keys were all

7:25

there, readable by anything with

7:27

database access. I'm not saying this to

7:29

pile on open code because they are

7:31

clearly making fixes and their founders

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, concept maps, and more. No credit card required.

OpenCode Got Hacked Ba… - Full Transcript | YouTubeTranscript.dev