Live data from Hacker News

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

research.kudelskisecurity.com

21–30 of 244 posts

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

#21
post #18

Why does CodeRabbit need write access to the git repo? Why doesn't Github let me limit it's access?

Because it has the ability to write tests for the PR in question.

Then it should open a PR for those tests so it can go through the normal CI and review process.

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

#22
I've noticed CodeRabbit at times does reviews that are super. It is able to catch bugs that even claude code misses on our Github PRs. Blows my mind at times tbh.

Based on the env vars seems like they're using anthropic, openai, etc. only?

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

#23

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?

> Why are these variables needed for this entire tooling?

They are not. The Github API secret key should never be exposed in the environment, period; you're supposed to keep the key in an HSM and only use it to sign the per-repo access token. Per the GH docs [0]:

> The private key is the single most valuable secret for a GitHub App. Consider storing the key in a key vault, such as Azure Key Vault, and making it sign-only. This helps ensure that you can't lose the private key. Once the private key is uploaded to the key vault, it can never be read from there. It can only be used to sign things, and access to the private key is determined by your infrastructure rules.

> Alternatively, you can store the key as an environment variable. This is not as strong as storing the key in a key vault. If an attacker gains access to the environment, they can read the private key and gain persistent authentication as the GitHub App.

[0]: https://docs.github.com/en/apps/creating-github-apps/authent...

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

#24
post #18

Earlier quoted context omitted.

Because it has the ability to write tests for the PR in question.

Then it should open a PR for those tests so it can go through the normal CI and review process.

It updates the existing PR with the tests, I believe. They'd still get reviewed and go through CI.

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

#25
hey, this is Howon from CodeRabbit here. we wish to note that this RCE was reported and fixed in January. it was entirely prospective and no customer data was affected. we have extensive sandboxing for basically any execution of anything now, including any and every tool and all generated code of any kind under the CodeRabbit umbrella.

if you want to learn how CodeRabbit does the isolation, here's a blog post about how: https://cloud.google.com/blog/products/ai-machine-learning/h...

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

#26
It is incredibly bad practice that their "become the github app as you desire" keys to the kingdom private key was just sitting in the environment variables. Anybody can get hacked, but that's just basic secrets management, that doesn't have to be there. Github LITERALLY SAYS on their doc that storing it in an environment variable is a bad idea. Just day 1 stuff. https://docs.github.com/en/apps/creating-github-apps/authent...

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

#27
post #24

Earlier quoted context omitted.

Then it should open a PR for those tests so it can go through the normal CI and review process.

It updates the existing PR with the tests, I believe. They'd still get reviewed and go through CI.

Right, the downside being that the app needs write access to your repository.

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

#28
global scoped installations or keys always scare me for this reason

i believe the answer here was to exchange the token for something scoped to the specific repo coderabbit is running in, but alas, that doesn't remove the "RCE" _on_ the repo

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

#29

hey, this is Howon from CodeRabbit here. we wish to note that this RCE was reported and fixed in January. it was entirely prospective and no customer data was affected. we have extensive sandboxing for basically any execution of anything now, including any and every tool and all generated code of any kind under the CodeRabbit umbrella. if you want to learn how CodeRabbit does the isolation, here's a blog post about h…

How can you guarantee that nobody ripped the private key before the researcher told you about the issue though?

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

#30

hey, this is Howon from CodeRabbit here. we wish to note that this RCE was reported and fixed in January. it was entirely prospective and no customer data was affected. we have extensive sandboxing for basically any execution of anything now, including any and every tool and all generated code of any kind under the CodeRabbit umbrella. if you want to learn how CodeRabbit does the isolation, here's a blog post about h…

The chuzpe to use this as PR.
Post reply on HN