WEBVTT

00:00.000 --> 00:04.040
All right, everyone, thank you very much for joining us.

00:04.300 --> 00:14.680
Our next talk is SDLC Nightmares, Defeating Secure Code Review, GPT Hallucination with Julo and April.

00:16.200 --> 00:17.040
Hello

00:24.550 --> 00:36.510
, my name is Julo and I just graduated from the Pennsylvania State University last year and now I'm working as a security engineer in industry.

00:36.530 --> 00:42.610
And my research interest is focused on applying deep learning in cybersecurity.

00:44.330 --> 00:51.350
And I'm April, Carnegie Mellon University graduate and currently a security engineer as well.

00:51.550 --> 00:57.930
A fun fact about me is I learned and applied my InfoSec knowledge during writing science fictions.

00:59.030 --> 01:01.830
Okay, let's get started.

01:01.830 --> 01:12.370
As most of us might have noticed, nowadays, large language models have been playing an increasingly important role in our daily work and lives.

01:12.370 --> 01:22.690
Today we'll discuss how LLMs can be applied to security code analysis and evaluate their reliability in understanding program logic.

01:24.550 --> 01:26.730
Overview of our talk today.

01:26.730 --> 01:35.250
First, we'll introduce LLMs and their strengths in SDLC, then we'll uncover their limitations through an experiment.

01:35.250 --> 01:42.170
Based on our findings, we'll further discuss the root causes and their other related issues.

01:42.170 --> 01:48.770
Finally, we'll summarize key takeaways on how to better utilize LLMs in our work.

01:51.140 --> 01:55.040
So, first of all, what is a large language model?

01:55.040 --> 02:06.400
Basically, LLM is advanced machine learning models that understand and generate human-like text by learning from fast data sets.

02:06.400 --> 02:15.040
They use deep learning, especially transformer architectures, to predict the most probable word in a sentence.

02:15.040 --> 02:25.940
For example, in this figure, it estimates a 91% probability that the word blue follows the phrase, the color of the sky is.

02:25.940 --> 02:38.040
LLMs generate coherent and contextually appropriate text, enabling tasks like answering questions, translation, and our topic today, code analysis.

02:38.880 --> 02:42.840
Now, let's talk about SDLC.

02:42.840 --> 02:51.100
A typical software development lifecycle involves various stages where LLMs can significantly assist.

02:51.100 --> 03:08.700
By understanding semantics and recognizing patterns, LLMs can comprehend natural language and analyze code, performing tasks like code generation, test case creation, and also documentation.

03:08.700 --> 03:22.720
From a security perspective, they also help with threat modeling and identifying vulnerabilities, ultimately boosting the efficiency and quality throughout the SDLC.

03:23.180 --> 03:26.860
However, LLMs can make mistakes.

03:26.860 --> 03:29.640
Here are two famous examples.

03:29.640 --> 03:36.620
When Google introduced their chatbot bot, it made a factual error during its very first demo.

03:36.620 --> 03:50.040
Another instance involved ChatGPT, which confidently asserted that 9.11 is greater than 9.9, a mistake even an elementary student would recognize.

03:50.100 --> 03:56.460
These errors stem from the tendency to state incorrect information as facts.

03:56.460 --> 04:04.400
LLMs often hallucinate, like what I do every time before sleeping or conceiving a science fiction story.

04:04.400 --> 04:12.720
They tend to make up information because they are essentially autocomplete systems based on probability rather than facts.

04:13.280 --> 04:18.600
Now, let's see their performance in code analysis.

04:18.960 --> 04:26.360
Before diving into the experiment, let's first take a closer look at the code itself.

04:26.360 --> 04:35.560
Technically, source code is a sequence of tokens consisting of three types, keywords, operators, and user-defined names.

04:35.940 --> 04:47.480
Keywords and operators are defined by the specification of each programming language, and they control the actual logic flow of the program execution.

04:47.480 --> 04:51.020
So we categorize them as logical features.

04:51.100 --> 05:02.900
Meanwhile, user-defined names, annotations, and comments, which don't influence the program's flow once it's compiled, are categorized as literal features.

05:03.780 --> 05:13.300
So our goal for the experiment is to determine what types of features in the code LLMs can actually learn and process.

05:13.300 --> 05:26.660
We'll mask the literal features by replacing the changeable names that don't affect the program flow, and then use the LLM to perform code analysis tasks on this modified code.

05:26.660 --> 05:37.960
By evaluating the performance, we'll assess whether the LLM can effectively process the logical features when literal features are absent or even misleading.

05:38.940 --> 05:44.660
To conceal the literal features, we'll adopt three kinds of anonymization.

05:44.660 --> 05:49.800
So here is an example of the bubble sort function in Java.

05:49.800 --> 05:53.400
And the first anonymization is for function name.

05:53.400 --> 05:59.180
So here we can replace the bubble sort string with our customized string.

05:59.180 --> 06:02.620
And the second one is for variable names.

06:02.620 --> 06:09.120
Two examples here is the begin and end, which we can replace with our strings.

06:09.120 --> 06:12.920
And the last one is the method invocation name.

06:12.920 --> 06:23.600
Here we have a function pret as one of the arguments for the bubble sort function, so we can replace the invocation name with our customized string.

06:24.760 --> 06:33.280
Meanwhile, to understand how literal features affect LLM comprehension, we also use two name replacement strategies.

06:33.280 --> 06:48.600
The first one is just replacing it with some randomly generated string, while the second one is shuffling the names with other meaningful names from the code, making it more misleading for users.

06:48.700 --> 06:49.700
For readers.

06:49.700 --> 06:50.860
Sorry.

06:51.240 --> 06:59.980
So, after the literal features are concealed, the LLM performs two main tasks related to code analysis.

06:59.980 --> 07:14.760
The first one is code clone detection, which identifies and measures the similarity between different code fragments to see if they generate the same result when given the same input.

07:15.140 --> 07:30.880
The second one is code search, where it tries to retrieve the code fragment from a larger code corpus that closely matches a developer's intent, which is expressed in natural language as the input.

07:31.960 --> 07:35.300
So, here are the results we got.

07:35.300 --> 07:44.560
It shows that anonymizing names significantly decreases model performance, especially when we replace all three kinds of names.

07:44.840 --> 08:01.820
In the code search task, we also notice that anonymizing master definition name causes more degradation than anonymizing master invocation name, indicating a stronger correlation between the master definition name and their purpose.

08:01.820 --> 08:13.980
As for different languages, anonymizing a single attribute affects Python more, but changing all naming attributes impacts Java the most.

08:13.980 --> 08:24.200
Probably because the verbosity and the structure in Java code that can mitigate partial anonymization are fully disrupted.

08:25.880 --> 08:42.920
Compared to the code clone detection task, the performance degradation is more pronounced in code search task, since well-defined variable and method names are crucial for relating the code snippet to its descriptive purpose.

08:43.640 --> 08:57.360
So, overall, the results clearly show that while logical features are what matters for a program to execute, what LLMs processed are mostly the literal features from the code.

08:57.360 --> 08:59.740
Now I'll hand it over to Dr.

08:59.740 --> 09:03.740
Zhilong to discuss the reasons and possible solutions.

09:04.320 --> 09:05.280
Okay.

09:08.500 --> 09:14.360
So, let's discuss some root cause for the misleading names and comments in the code.

09:14.360 --> 09:22.820
Basically, we just observed three types of the root cause for these misleading names and comments.

09:22.820 --> 09:29.380
And they are malicious code committers and outdated comments and bad coding practice.

09:33.320 --> 09:44.120
Malicious code contributors can contribute some malicious code to the open source projects, and to avoid being detected by the code reviewers.

09:44.120 --> 09:53.080
And they usually can change the naming to some misleading names to avoid being detected by the code reviewer.

09:56.610 --> 10:09.430
Secondly, in software development, programs often frequently update their code to fix some bugs or add some new features.

10:09.450 --> 10:15.770
Well, the comments corresponding to the code may not be updated in time.

10:15.870 --> 10:27.410
In this example, partial code was removed during a new commit, and, however, the corresponding comment was not removed accordingly.

10:29.030 --> 10:38.570
Comments that are not updated can cause inconsistency with the code, and we call them outdated comments.

10:38.570 --> 10:44.470
Outdated comments can mislead the light learning model during code analysis.

10:47.280 --> 11:03.420
Also, in bad coding practice, confusing variable names and misleading variable names could be given by even a benign programmer and developer, which can mislead the code reviewer, too.

11:06.800 --> 11:16.060
So, next, we are going to cover some other issues when using the light learning model to do the code analysis.

11:20.400 --> 11:26.780
Besides the aforementioned limitations, we also observe two limitations.

11:26.780 --> 11:37.160
The first one is lack of context, and the second one is diverse performance on different program language.

11:37.160 --> 11:39.240
We will show the detail.

11:46.080 --> 11:50.900
Most light learning models can only handle a sequence of a limited length.

11:50.900 --> 12:06.700
For example, GPT-3 can handle a sequence with 2,048 tokens at most, and GPT-4 can handle 32,000 tokens at most.

12:07.160 --> 12:19.280
However, the code for even small projects can have thousands lines of code, and each line of code contains usually more than 10 tokens.

12:19.980 --> 12:28.660
Therefore, the light learning model cannot consume all the code at once, which will lead to a lack of context issue.

12:29.840 --> 12:32.220
Let's show this figure.

12:32.520 --> 12:47.540
We have a big project here showing this figure, and let's consider the context of the light learning model through this blue box.

12:47.540 --> 12:56.920
And when we use the light learning model to analyze this whole project, we need to analyze a part of them individually.

13:04.800 --> 13:19.360
So, based on our observation, in most cases, the light learning model is used to analyze each function individually, and it cannot have a big picture of the whole project.

13:19.360 --> 13:27.980
So, we actually have written an ARX preprint to dive into this problem.

13:27.980 --> 13:32.680
We also proposed some solutions to solve this problem.

13:32.680 --> 13:39.980
And for people who are interested in the details can read this ARX preprint.

13:44.290 --> 13:52.890
Also, we observed that the light learning model has a diverse performance across different program languages.

13:52.890 --> 13:59.010
And different light learning models also have different strengths across different program languages.

13:59.010 --> 14:09.750
And we did a quick experiment to evaluate the light learning model's ability to infer the program logic on two program languages.

14:10.250 --> 14:13.610
And the result is shown in the table here.

14:15.060 --> 14:24.550
We can observe that the GPT 3.5 has shown the best results on PHP and Go.

14:24.550 --> 14:31.550
However, Gemini can show the best results on PHP and Python.

14:38.240 --> 14:38.760
Okay.

14:38.760 --> 14:47.480
So, next, we will discuss how to avoid this issue in using light learning model for code analysis.

14:50.180 --> 14:53.760
So, we start from some ad hoc solutions.

14:53.880 --> 15:04.600
And if the code is committed by the trusted developer, we should expect them to improve the quality of the name convention.

15:04.740 --> 15:21.940
And if the code is committed by some untrusted developer, and we should pay special attention in case the light learning model is fooled by the malicious code committer, which can easily be achieved based on experiments.

15:22.140 --> 15:36.840
And for example, we could deploy some naming logic in constancy detection and use it to detect the inconsistency before we perform the code review.

15:40.680 --> 15:52.780
However, to really solve this problem, we believe that we need to change the model a little bit to specifically for the code analysis.

15:52.780 --> 16:01.100
And the current popular pre-training task for the light learning model, as far as we know, is the mask token prediction.

16:01.900 --> 16:07.160
In mask token prediction task, it masks off some tokens in the sequence.

16:07.420 --> 16:20.740
Here, if I take this as example, and it masks off some of that tokens from its sequence and uses neural network to predict this token.

16:20.740 --> 16:26.220
And this is how current light learning model is trained, as far as we know.

16:26.240 --> 16:37.120
And the mask token prediction task mainly focuses on the literal feature when applied to the source code analysis.

16:37.140 --> 16:47.100
But if we apply this model to the neural language NLP, it's okay, because it does not have too much of the logic features.

16:47.100 --> 16:50.200
But for the source code, we have a lot of the logic features.

16:50.200 --> 17:17.500
So, to really solve this problem, we think that we need to add some more pre-training tasks to train a new large program language model, which we should add some logic feature prediction tasks so that it can better capture the logic feature, not the literal feature.

17:17.500 --> 17:29.160
Because, as we show, relying too much on the literal feature will result in some issues as we have demonstrated in the experiments.

17:33.820 --> 17:45.200
So, for the audience who are interested in the details of this talk, you can refer to this ARX preprint for more details.

17:45.540 --> 17:49.480
And here is our contact information.

17:49.580 --> 17:51.960
And that's all of our talk.

