ASE2023_SCPatcher_Presentation_V5.pptx

Sep. 12, 2023
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
ASE2023_SCPatcher_Presentation_V5.pptx
1 of 26

More Related Content

Similar to ASE2023_SCPatcher_Presentation_V5.pptx

Dsp lab manual 15 11-2016Dsp lab manual 15 11-2016
Dsp lab manual 15 11-2016Gopinath.B.L Naidu
2a Mini-conf PredictCovid. Field: Artificial Intelligence2a Mini-conf PredictCovid. Field: Artificial Intelligence
2a Mini-conf PredictCovid. Field: Artificial IntelligenceAlex Camargo
CppcheckCppcheck
CppcheckPVS-Studio
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderA Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderAndrey Karpov
JavaSecureJavaSecure
JavaSecureSangbeomKim
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfGeorge Papaioannou

Recently uploaded

Database Storage Engine InternalsDatabase Storage Engine Internals
Database Storage Engine InternalsAdewumiSunkanmi
Climate Impact of Software TestingClimate Impact of Software Testing
Climate Impact of Software TestingKari Kakkonen
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...Roberto Pérez Alcolea
Fuzzing for CPS Mutation TestingFuzzing for CPS Mutation Testing
Fuzzing for CPS Mutation TestingLionel Briand
Snowflake_free_trial_LabGuide.pdfSnowflake_free_trial_LabGuide.pdf
Snowflake_free_trial_LabGuide.pdfAdrianMontero30
Choosing the Right Billing Strategy for Software Projects.pdfChoosing the Right Billing Strategy for Software Projects.pdf
Choosing the Right Billing Strategy for Software Projects.pdfRichard Piacentini

ASE2023_SCPatcher_Presentation_V5.pptx

Editor's Notes

  1. Hello everyone, my name is Ziyou Jiang, and I’m from Institute of Software, Chinese Academy of Sciences. Today, I’m going to introduce our work, the SCPatcher, which aims to mine the crowd discussions to enrich the secure coding practices.
  2. We will introduce our work in these six sections.
  3. First, we introduce what is the public secure coding practices. The security teams of IT companies, universities and organizations, analyze the open-source projects, and find how to develop the reliable software. Then, they formulate these findings to the guidelines to instruct the developers who need to build a secure software, and publish it to the community. These guidelines are secure coding practices in the public, also represented as public SCP in our paper. However, we find that the public SCPs are not specific enough. Taking the OWASP as an example. For developers that are not familiar with the software security, they pointed out that the OWASP’s SCPs are usually one-sentence, and hard to understand. Beyond these public SCPs, they still need some detailed codes to help them. So, we believe that the public SCP may need to be enriched with the coding examples.
  4. But where can we find these coding examples? We pay attention to the knowledge-sharing platforms. Many developers discuss and share their security experiences on these platforms. The stack overflow, for example, is one of the Q&A platform that contain the massive security posts. In this example, the post has the detailed codes for how to make Firebase data models secure, and security practitioner in Twitter referenced it and said that it is a typical SCP for the Firebase security. So, we can see that, the crowd security discussions are helpful, which may contain the SCP with some detailed coding examples.
  5. However, if people need to manually mine these knowledge, it is very costly and low-efficient. So, can we propose a method to automatically extract these information? What is the most important knowledge that need to be extracted? We present our motivation example here. From the left figure, we can see that, a post in Stack Overflow contain question and accepted answer. The question part has the insecure coding example and its explanation, and the accepted answer proposes the corresponding secure information. Also, we find that the post can match “Access Control” in OWASP, which is an one-sentence SCP without any coding details, so we believe that we can use this coding examples and explanations to enrich this SCP. We define the extracted and matched components as SCP specification, and we build an automatic approach to extract it, named as SCPatcher.
  6. The SCPatcher contain three major steps. The first is the area extraction; The second step extract the coding examples and explanations from previous located areas. And the third step is two matchers, we can not only match the public SCP, but also find the relevant CWE, which is the weakness type in the common weakness enumeration.
  7. For the step A, Since the security posts always contain massive non-relevant codes and sentences. We find that is too difficult to extract them directly. But if we first locate the areas, it will be much easier to extract these information. To extract the areas, we utilize the generative large-language model, which is recently very useful in natural language process. We first define the prompt. We utilize the cloze-template, which has advantages in our task compared with others. We will discuss it later. For this prompt, [X] is the input post, and [Y] is the cloze-testing results, which contain the areas. For the question part, we use these TQ to extract the areas of insecure coding examples and explanations; for the accepted answer, we use the TA to extract the area of secure information. Second, we select the LLM from the five candidate SOTAs, and we find that GPT-three has the best performance, so we use it as our model to select the areas. Finally, we fine-tune the model with the Cringe loss, which is a typical method for training the generative LLM.
  8. For the step B, we propose two modules, the hierarchical slicer to extract the coding examples, and the summarizer to extract coding explanations from these areas. Before the extraction, we define the security feature vector, which is a high-level representations of security knowledge. We define the SFV according to the previous works, which are five types of keywords, from WW to CW. We utilize the GloVe method to embed all the extracted words, and concatenate them to a single vector. This vector is used to enhance the accuracy of extraction.
  9. Then, we propose the attention-based selector, which is the core module of slicer and summarizer. The selector has a task-oriented encoder, which can embed each element of the area to a single embedding. Then it use the multi-head attention to enhance the embeddings with the SFV, which is a novel method that introduce the external knowledge to the embeddings. Finally, it use the transformer decoder to predict the probabilities, which is compatible to the multi-head attention. The probabilities decide which element need to be chosen, and we use some cut-off value to determine the selected elements. For the slicer, we first determine the lengthy code. According to Hu’s work, the lengthy code is difficult to be understood when it exceeds 15 lines, so we slice these codes to make them understandable. Then, we transform the code to the Abstract Syntax Tree, which is a typical code representation. We use the CAST as the task-oriented encoder, which is a novel method to embed the AST trees. Third, we utilize selector with three hierarchical levels, function, comments, and empty lines. We iterative slice the lengthy codes until it is understandable. For the summarizer, we choose the BERT as the task-oriented encoder, which is a representative method to embed the sentences with bi-directional contexts. Then, we use the selector to summarize the final coding explanations.
  10. To fine-tune the both models, considering the time aspect, we use the multitask fine-tuning to train the two modules jointly.
  11. So, we have obtained the coding examples and explanations, and we need to match them to the CWE and public SCP. We define the semantic similarity based on the security keywords, and we propose the equations, as is shown in this page. The equation outputs the highest cosine similarity of keywords between posts and CWE & public SCP. We also defines two thresholds. If the semantic similarity is higher than threshold, the post can be successfully matched. Otherwise, we need to set the SCP specification as “unmatched”. So here we can finally obtain the result, the six-tuple SCP specification.
  12. To evaluate the performance of SCPatcher. We first build the dataset with four steps, the data collection, preprocessing, labeling and augmentation. We first collect the original dataset with “security” and its equivalent tags Then, we manually label it, where we build a team with eight experienced lablers in software security, and they discuss with each other until the labels are decided. After the labeling, we find that the dataset is imbalanced and few-shot, so we augment them to the balanced dataset with EDA, a widely-used data augmentation method.
  13. To evaluate the performance of SCPatcher, we propose four RQs.
  14. For RQ-one, we analyze the performance on extracting the coding examples, with three SOTA baselines. We compare it with GPT-three, and other two baselines, the VulSlicer and Deepbalance. To demonstrate the ability of area and SFV, we propose two variants for the baselines. Note that, all the baselines are fine-tuned on our dataset. We use the three metrics on code generation to evaluate the performances, the Rouge-L, MatchToken and MatchLine. From the results, we can see that, SCPacther can outperform the SOTA baseline, the GPT-three plus area, on all the metrics, and the time cost is only longer than the two original baselines for VulSlicer and DeepBalance. So, we believe that SCPatcher has the advantage on extracting coding examples.
  15. Samely, for RQ-two, we analyze the performance on extracting the coding explanation. We also choose GPT-three and other two SOTA summarization baselines. We use the precision, recall, and F-one, as the metrics. The result shows that. SCPatcher also can outperforms all the baselines in this RQ, which also has advantages on extracting the coding explanations.
  16. For RQ-three, we analyze the performance of matching the CWE. We use the precision as the metric, which can better reflect to the matching rate for CWE. The results of the CWE matcher is around 80 percent, which means the CWE is accurately matched with our model.
  17. For RQ-four, we analyze the performance on enriching the public SCP in OWASP (We take OWASP as example). We calculate the LOC and sentences that can be used to enrich the public SCP. We find that, SCPatcher can enrich the public SCP with around 400 specifications, 3000 LOC, and 2000 sentences, which means it has the practical ability to enrich the public SCP. Also, the precision is 78 percent, which means the SCP matcher is also accurate.
  18. Finally, in the discussion, we analyze the effect of prompt template. We design two types of prompts, the prefix template is the typical Q&A format template, and the cloze templates. The comparison results shows that the cloze template is better than the prefix in our task, the cloze two (our template), is the best for SCPatcher. We also analyze the effect of sentence numbers and code-block numbers in the security posts, and we compare the SCPatcher with the GPT-three plus Area. We find that SCPatcher are mostly higher than the GPT-three in all intervals, which means the it can adapt to different types of security posts.
  19. We use the case study to demonstrate the advantage of SCPatcher. We find that, to extract the SCP specification from the motivation example, SCPatcher is more accurate than the GPT-three, and GPT-three has some mispredictions in this figure. Although SCPatcher is accurate, we find that around ten percent of specifications are unmatched. We manually analyze these posts, then find three types of bad cases. Except to the non-scp codes and inaccurate extraction, we find that around 1.4 percent cases may have new public SCPs that are not incorporated by the OWASP, like the WAF to the log4j. These specifications may be used to complement the OWASP library later.
  20. Overall, we conclude that our paper. We introduce the SCPatcher, which is an automatic method to enrich the public SCPs by mining the security discussions. We build the dataset and conduct the experiments to evaluate the performances, together with some ablation studies. We have released the dataset and approach in this zenodo link. In the future, we plan to improve our dataset and the approach, and evaluate its practical usage on other public SCPs.
  21. Thank you for listening.