Live data from Hacker News

Security weaknesses of Copilot generated code in GitHub

arxiv.org

11–20 of 87 posts

Re: Security weaknesses of Copilot generated code in GitHub

#11

If a weakness is common, then of course Copilot is going to suggest it. Copilot gives you popular responses not correct ones. Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. The studies results are rather unsurprising and its conclusions are oft-repeated advice. As many have said, treat copilot’s code in the same light you would treat a junior programmer’s code.

> Yet if a weakness is common, it also means that human coders frequently make the same mistake as well.

It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution.

Anyway, i'd argue the real question is "can the chatbot fix the code if requested to".

Re: Security weaknesses of Copilot generated code in GitHub

#12
post #3

Did they prompt it to consider security weaknesses?

That would be kind of wild. Imagine a world where whether your system was secure was just a matter of remembering to tell the AI agent "& also make it secure" before it writes your code. (could be quite real!)

> also make it secure

[proceeds to simply refactor the same code]

Re: Security weaknesses of Copilot generated code in GitHub

#13

If a weakness is common, then of course Copilot is going to suggest it. Copilot gives you popular responses not correct ones. Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. The studies results are rather unsurprising and its conclusions are oft-repeated advice. As many have said, treat copilot’s code in the same light you would treat a junior programmer’s code.

> Copilot gives you popular responses not correct ones.

That also sums up most of the issues with LLMs in general in one sentence.

Re: Security weaknesses of Copilot generated code in GitHub

#14

If a weakness is common, then of course Copilot is going to suggest it. Copilot gives you popular responses not correct ones. Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. The studies results are rather unsurprising and its conclusions are oft-repeated advice. As many have said, treat copilot’s code in the same light you would treat a junior programmer’s code.

> Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution. Anyway, i'd argue the real question is "can the chatbot fix the code if requested to".

> It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution.

Copilot was primarily trained on GitHub projects, not on communication between programmers. Patterns that frequently show up in Copilot output are most likely prevalent on GitHub, which is a pretty good indicator that they're common in production code.

Re: Security weaknesses of Copilot generated code in GitHub

#15
post #5

If a weakness is common, then of course Copilot is going to suggest it. Copilot gives you popular responses not correct ones. Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. The studies results are rather unsurprising and its conclusions are oft-repeated advice. As many have said, treat copilot’s code in the same light you would treat a junior programmer’s code.

I wonder if llm are biased towards older, more insecure implementations because there is a higher volume of old code vs new code. Same thing with the data it is trained on — not all code requires all levels of refinement. Most of the data is probably around average.

This makes me wonder about training an LLM on one language and then fine tuning it for another. If you train over only, say, JavaScript, and then finetune for C, I imagine it will be quite bad at writing safe code, even if it makes the code look like C, because it didn't have to learn about freeing and such.

Similarly, would it pick up patterns from one language and keep then in the other? Maybe an LLM trained on Kotlin would be more likely to write functional code finetuned.

Re: Security weaknesses of Copilot generated code in GitHub

#16
post #15
post #5

Earlier quoted context omitted.

I wonder if llm are biased towards older, more insecure implementations because there is a higher volume of old code vs new code. Same thing with the data it is trained on — not all code requires all levels of refinement. Most of the data is probably around average.

This makes me wonder about training an LLM on one language and then fine tuning it for another. If you train over only, say, JavaScript, and then finetune for C, I imagine it will be quite bad at writing safe code, even if it makes the code look like C, because it didn't have to learn about freeing and such. Similarly, would it pick up patterns from one language and keep then in the other? Maybe an LLM trained on Kot…

Given that dataset anomalies can result in LLM output corruption, I'm not convinced that cross-training like that would even work.

Re: Security weaknesses of Copilot generated code in GitHub

#17
post #3

Did they prompt it to consider security weaknesses?

They did not prompt at all. They used GitHub’s code search to find projects where the repo owner specified that the code was generated “by Copilot” and the authors took that at face value for all code in the project. Whether the code was actually suggested by Copilot is not at all analyzed in the paper. As such, the results are highly questionable.

Re: Security weaknesses of Copilot generated code in GitHub

#18

Earlier quoted context omitted.

> Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution. Anyway, i'd argue the real question is "can the chatbot fix the code if requested to".

> It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution. Copilot was primarily trained on GitHub projects, not on communication between programmers. Patterns that frequently show up in Copilot output are most likely prevalent on GitHub, which is a pretty good indicator that they're common in production code.

That’s no longer true. Copilot uses the same ChatGPT-3.5 model as, well, ChatGPT. If it were trained on just GitHub projects, the chat features wouldn’t work at all.

Re: Security weaknesses of Copilot generated code in GitHub

#19

If a weakness is common, then of course Copilot is going to suggest it. Copilot gives you popular responses not correct ones. Yet if a weakness is common, it also means that human coders frequently make the same mistake as well. The studies results are rather unsurprising and its conclusions are oft-repeated advice. As many have said, treat copilot’s code in the same light you would treat a junior programmer’s code.

> Copilot gives you popular responses not correct ones. That also sums up most of the issues with LLMs in general in one sentence.

Sums up the issues with democracy too, and a ton of other stuff

Re: Security weaknesses of Copilot generated code in GitHub

#20
post #18

Earlier quoted context omitted.

> It only means programmers commonly talk about it. This isn't the same thing as measuring incidence in production or distribution. Copilot was primarily trained on GitHub projects, not on communication between programmers. Patterns that frequently show up in Copilot output are most likely prevalent on GitHub, which is a pretty good indicator that they're common in production code.

That’s no longer true. Copilot uses the same ChatGPT-3.5 model as, well, ChatGPT. If it were trained on just GitHub projects, the chat features wouldn’t work at all.

You're assuming that Copilot Chat and the regular completion are the same model. Do you have a source that says so? I'd assumed that they were two different models, since they're quite different tasks.
Post reply on HN