start	end	text
0	7520	All right, everyone, thank you very much for joining us. Our next talk is SDLC Nightmares,
7520	14680	Defeating Secure Code Review, GPT Hallucination with Julo and April.
16200	31710	Hello, my name is Julo and I just graduated from the Pennsylvania State University last
31710	39430	year and now I'm working as a security engineer in industry. And my research interest is focused
39430	42610	on applying deep learning in cybersecurity.
44330	50070	And I'm April, Carnegie Mellon University graduate and currently a security engineer
50070	56590	as well. A fun fact about me is I learned and applied my InfoSec knowledge during writing
56590	57930	science fictions.
59030	66470	Okay, let's get started. As most of us might have noticed, nowadays, large language models
66470	73170	have been playing an increasingly important role in our daily work and lives. Today we'll
73170	79730	discuss how LLMs can be applied to security code analysis and evaluate their reliability
79730	82690	in understanding program logic.
84550	91910	Overview of our talk today. First, we'll introduce LLMs and their strengths in SDLC, then we'll
91910	97750	uncover their limitations through an experiment. Based on our findings, we'll further discuss
97750	105050	the root causes and their other related issues. Finally, we'll summarize key takeaways on
105050	108770	how to better utilize LLMs in our work.
111140	118460	So, first of all, what is a large language model? Basically, LLM is advanced machine
118460	125440	learning models that understand and generate human-like text by learning from fast data
125440	133280	sets. They use deep learning, especially transformer architectures, to predict the most probable
133280	140480	word in a sentence. For example, in this figure, it estimates a 91% probability that
140480	148240	the word blue follows the phrase, the color of the sky is. LLMs generate coherent and
148240	155200	contextually appropriate text, enabling tasks like answering questions, translation, and
155200	158040	our topic today, code analysis.
158880	167300	Now, let's talk about SDLC. A typical software development lifecycle involves various stages
167300	176140	where LLMs can significantly assist. By understanding semantics and recognizing patterns, LLMs
176140	184780	can comprehend natural language and analyze code, performing tasks like code generation,
184780	191900	test case creation, and also documentation. From a security perspective, they also help
191900	199780	with threat modeling and identifying vulnerabilities, ultimately boosting the efficiency and quality
200460	209900	throughout the SDLC. However, LLMs can make mistakes. Here are two famous examples. When
209900	216620	Google introduced their chatbot bot, it made a factual error during its very first demo.
216620	226320	Another instance involved ChatGPT, which confidently asserted that 9.11 is greater than 9.9, a
226320	233880	mistake even an elementary student would recognize. These errors stem from the tendency to state
233880	240880	incorrect information as facts. LLMs often hallucinate, like what I do every time before
240880	247020	sleeping or conceiving a science fiction story. They tend to make up information because they
247020	254720	are essentially autocomplete systems based on probability rather than facts. Now, let's
254720	263240	see their performance in code analysis. Before diving into the experiment, let's first take
263300	270240	a closer look at the code itself. Technically, source code is a sequence of tokens consisting
270240	278480	of three types, keywords, operators, and user-defined names. Keywords and operators are defined
278480	285580	by the specification of each programming language, and they control the actual logic flow of
285580	292700	the program execution. So we categorize them as logical features. Meanwhile, user-defined
292700	299820	names, annotations, and comments, which don't influence the program's flow once it's compiled,
299820	307900	are categorized as literal features. So our goal for the experiment is to determine what
307900	314700	types of features in the code LLMs can actually learn and process. We'll mask the literal
314700	320400	features by replacing the changeable names that don't affect the program flow, and then
320400	329080	use the LLM to perform code analysis tasks on this modified code. By evaluating the performance,
329080	334860	we'll assess whether the LLM can effectively process the logical features when literal
334860	342260	features are absent or even misleading. To conceal the literal features, we'll adopt
342260	348840	three kinds of anonymization. So here is an example of the bubble sort function in
348840	356400	Java. And the first anonymization is for function name. So here we can replace the bubble sort
356400	363340	string with our customized string. And the second one is for variable names. Two examples
363340	371060	here is the begin and end, which we can replace with our strings. And the last one is the
371060	377520	method invocation name. Here we have a function pret as one of the arguments for the bubble
377520	385880	sort function, so we can replace the invocation name with our customized string. Meanwhile,
385880	392060	to understand how literal features affect LLM comprehension, we also use two name replacement
392060	399080	strategies. The first one is just replacing it with some randomly generated string, while
399080	405440	the second one is shuffling the names with other meaningful names from the code, making
405440	413680	it more misleading for users. For readers. Sorry. So, after the literal features are
413680	421340	concealed, the LLM performs two main tasks related to code analysis. The first one is
421340	427420	code clone detection, which identifies and measures the similarity between different
427420	435860	code fragments to see if they generate the same result when given the same input. The
435860	441920	second one is code search, where it tries to retrieve the code fragment from a larger
441920	448880	code corpus that closely matches a developer's intent, which is expressed in natural language
448880	458340	as the input. So, here are the results we got. It shows that anonymizing names significantly
458340	465620	decreases model performance, especially when we replace all three kinds of names. In the
465620	472140	code search task, we also notice that anonymizing master definition name causes more degradation
472140	478860	than anonymizing master invocation name, indicating a stronger correlation between the master
478860	486460	definition name and their purpose. As for different languages, anonymizing a single
486460	493980	attribute affects Python more, but changing all naming attributes impacts Java the most.
493980	500900	Probably because the verbosity and the structure in Java code that can mitigate partial
500900	510920	anonymization are fully disrupted. Compared to the code clone detection task, the performance
510920	517140	degradation is more pronounced in code search task, since well-defined variable and method
517140	525060	names are crucial for relating the code snippet to its descriptive purpose. So, overall, the
525060	532340	results clearly show that while logical features are what matters for a program to execute,
532580	538780	what LLMs processed are mostly the literal features from the code. Now I'll hand it over
538780	543740	to Dr. Zhilong to discuss the reasons and possible solutions.
544320	554360	Okay. So, let's discuss some root cause for the misleading names and comments in the code.
554360	561420	Basically, we just observed three types of the root cause for these misleading names
561420	567880	and comments. And they are malicious code committers and outdated comments and bad coding
567880	578420	practice. Malicious code contributors can contribute some malicious code to the open
578420	585640	source projects, and to avoid being detected by the code reviewers. And they usually can
585640	593080	change the naming to some misleading names to avoid being detected by the code reviewer.
596610	605450	Secondly, in software development, programs often frequently update their code to fix
606130	612530	some bugs or add some new features. Well, the comments corresponding to the code may
612530	621810	not be updated in time. In this example, partial code was removed during a new commit,
621810	627410	and, however, the corresponding comment was not removed accordingly.
629030	638570	Comments that are not updated can cause inconsistency with the code, and we call them outdated comments.
638570	644470	Outdated comments can mislead the light learning model during code analysis.
647280	654740	Also, in bad coding practice, confusing variable names and misleading variable names could
654740	663420	be given by even a benign programmer and developer, which can mislead the code reviewer, too.
666800	674080	So, next, we are going to cover some other issues when using the light learning model
674080	686780	to do the code analysis. Besides the aforementioned limitations, we also observe two limitations.
686780	695680	The first one is lack of context, and the second one is diverse performance on different
695680	708520	program language. We will show the detail. Most light learning models can only handle
708760	719400	a sequence of a limited length. For example, GPT-3 can handle a sequence with 2,048 tokens
719400	730080	at most, and GPT-4 can handle 32,000 tokens at most. However, the code for even small
730080	737320	projects can have thousands lines of code, and each line of code contains usually more
737320	744580	than 10 tokens. Therefore, the light learning model cannot consume all the code at once,
744580	754480	which will lead to a lack of context issue. Let's show this figure. We have a big project
754480	761710	here showing this figure, and let's consider the context of the light learning model through
762240	773680	this blue box. And when we use the light learning model to analyze this whole project, we need
773680	790420	to analyze a part of them individually. So, based on our observation, in most cases, the
790420	796620	light learning model is used to analyze each function individually, and it cannot have
796780	806820	a big picture of the whole project. So, we actually have written an ARX preprint to dive
806820	814360	into this problem. We also proposed some solutions to solve this problem. And for people who
814360	827130	are interested in the details can read this ARX preprint. Also, we observed that the light
827130	833450	learning model has a diverse performance across different program languages. And different
833450	839010	light learning models also have different strengths across different program languages.
839010	845210	And we did a quick experiment to evaluate the light learning model's ability to infer
845210	853610	the program logic on two program languages. And the result is shown in the table here.
855060	866150	We can observe that the GPT 3.5 has shown the best results on PHP and Go. However, Gemini
866150	882820	can show the best results on PHP and Python. Okay. So, next, we will discuss how to avoid
882820	892460	this issue in using light learning model for code analysis. So, we start from some ad hoc
892460	901140	solutions. And if the code is committed by the trusted developer, we should expect them
901140	908200	to improve the quality of the name convention. And if the code is committed by some untrusted
908200	914920	developer, and we should pay special attention in case the light learning model is fooled
914920	922260	by the malicious code committer, which can easily be achieved based on experiments. And
922260	931120	for example, we could deploy some naming logic in constancy detection and use it to detect
931120	943780	the inconsistency before we perform the code review. However, to really solve this problem,
943780	951520	we believe that we need to change the model a little bit to specifically for the code
951520	957640	analysis. And the current popular pre-training task for the light learning model, as far
957640	964920	as we know, is the mask token prediction. In mask token prediction task, it masks off
964920	971920	some tokens in the sequence. Here, if I take this as example, and it masks off some of
971920	981280	that tokens from its sequence and uses neural network to predict this token. And this is
981280	988260	how current light learning model is trained, as far as we know. And the mask token prediction
988260	997120	task mainly focuses on the literal feature when applied to the source code analysis.
997140	1005400	But if we apply this model to the neural language NLP, it's okay, because it does not have too
1005400	1010200	much of the logic features. But for the source code, we have a lot of the logic features.
1010200	1019600	So, to really solve this problem, we think that we need to add some more pre-training
1019600	1030900	tasks to train a new large program language model, which we should add some logic feature
1030900	1037500	prediction tasks so that it can better capture the logic feature, not the literal feature.
1037500	1045500	Because, as we show, relying too much on the literal feature will result in some issues
1046020	1057540	as we have demonstrated in the experiments. So, for the audience who are interested in
1057540	1066560	the details of this talk, you can refer to this ARX preprint for more details. And here
1066560	1071960	is our contact information. And that's all of our talk.
