Live data from Hacker News

How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

research.kudelskisecurity.com

11–20 of 244 posts

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#11
post #6

> After responsibly disclosing this critical vulnerability to the CodeRabbit team, we learned from them that they had an isolation mechanism in place, but Rubocop somehow was not running inside it. Curious what this (isolation mechanism) means if anyone knows.

you could say that they have vibe forgotten to sandbox it.

(likely asked AI to implement x and ai completely disregarded the need to sandbox).

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#12
post #10
post #6

> After responsibly disclosing this critical vulnerability to the CodeRabbit team, we learned from them that they had an isolation mechanism in place, but Rubocop somehow was not running inside it. Curious what this (isolation mechanism) means if anyone knows.

> Curious what this (isolation mechanism) means if anyone knows. If they're anything like the typical web-startup "developing fast but failing faster", they probably are using docker containers for "security isolation".

[deleted]

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#13
post #8

I did not understand something: why did CodeRabbit run external tools on external code within its own set of environment variables? Why are these variables needed for this entire tooling?

Their own tools would need the various API keys, of course, and they did build a method to filter out those variables and managed most user code through it, but it sounds like they forgot to put Rubocop through the special method. So this researcher may have gotten lucky in choosing to dig into the tool that CodeRabbit got unlucky in forgetting.

It sounds like a pretty bad approach in general to have to "filter out the bad stuff" on a case-by-case basis. It should be as simple as launching everything from a sanitized parent environment, and making it impossible to launch any tool otherwise. Or better, make that sanitized environment the default and make privileged operations be the thing that jumps through hoops to talk to a bastion/enclave/whatever that holds the actual keys.

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#14

I did not understand something: why did CodeRabbit run external tools on external code within its own set of environment variables? Why are these variables needed for this entire tooling?

It sounds like they were putting these processes in a chroot jail or something and not allowing them to access the parent process env vars. There's a continuum of ways to isolate child processes in Linux that don't necessarily involve containers or docker.

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#15
post #8

Earlier quoted context omitted.

Their own tools would need the various API keys, of course, and they did build a method to filter out those variables and managed most user code through it, but it sounds like they forgot to put Rubocop through the special method. So this researcher may have gotten lucky in choosing to dig into the tool that CodeRabbit got unlucky in forgetting.

It sounds like a pretty bad approach in general to have to "filter out the bad stuff" on a case-by-case basis. It should be as simple as launching everything from a sanitized parent environment, and making it impossible to launch any tool otherwise. Or better, make that sanitized environment the default and make privileged operations be the thing that jumps through hoops to talk to a bastion/enclave/whatever that hol…

[deleted]

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#17
post #2

> While running the exploit, CodeRabbit would still review our pull request and post a comment on the GitHub PR saying that it detected a critical security risk, yet the application would happily execute our code because it wouldn’t understand that this was actually running on their production system. What a bizarre world we're living in, where computers can talk about how they're being hacked while it's happening. A…

[deleted]

Re: How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

#20
post #8

Earlier quoted context omitted.

Their own tools would need the various API keys, of course, and they did build a method to filter out those variables and managed most user code through it, but it sounds like they forgot to put Rubocop through the special method. So this researcher may have gotten lucky in choosing to dig into the tool that CodeRabbit got unlucky in forgetting.

It sounds like a pretty bad approach in general to have to "filter out the bad stuff" on a case-by-case basis. It should be as simple as launching everything from a sanitized parent environment, and making it impossible to launch any tool otherwise. Or better, make that sanitized environment the default and make privileged operations be the thing that jumps through hoops to talk to a bastion/enclave/whatever that hol…

Yes although somewhere there will be an `if` statement to determine if the process being started should get the complete environment or a key to get the other keys or whatever. Best to make that `if` at the highest level of the architecture as possible and wrapped in something that makes it obvious, like a `DangerousUserCodeProcess` class.

The only other safety I can think of is a whitelist, perhaps of file pathnames. This helps to maintain a safe-by-default posture. Taking it further, the whitelist could be specified in config and require change approval from a second team.

Post reply on HN