Skip to main content
QUICK REVIEW

[Paper Review] LLMs in Web Development: Evaluating LLM-Generated PHP Code Unveiling Vulnerabilities and Limitations

Rebeka Tóth, Tamás Bisztray|arXiv (Cornell University)|Apr 21, 2024
Semantic Web and OntologiesComputer Science3 citations
TL;DR

This study evaluates GPT-4-generated PHP code for security vulnerabilities using a hybrid approach combining Burp Suite scanning, static analysis, and manual verification on 2,500 AI-generated websites. It finds that at least 27% of the code contains vulnerabilities, highlighting major security risks and limitations in using LLMs for production web development without rigorous testing.

ABSTRACT

This study evaluates the security of web application code generated by Large Language Models, analyzing 2,500 GPT-4 generated PHP websites. These were deployed in Docker containers and tested for vulnerabilities using a hybrid approach of Burp Suite active scanning, static analysis, and manual review. Our investigation focuses on identifying Insecure File Upload, SQL Injection, Stored XSS, and Reflected XSS in GPT-4 generated PHP code. This analysis highlights potential security risks and the implications of deploying such code in real-world scenarios. Overall, our analysis found 2,440 vulnerable parameters. According to Burp's Scan, 11.56% of the sites can be straight out compromised. Adding static scan results, 26% had at least one vulnerability that can be exploited through web interaction. Certain coding scenarios, like file upload functionality, are insecure 78% of the time, underscoring significant risks to software safety and security. To support further research, we have made the source codes and a detailed vulnerability record for each sample publicly available. This study emphasizes the crucial need for thorough testing and evaluation if generative AI technologies are used in software development.

Motivation & Objective

  • To assess the security and functional reliability of PHP code generated by GPT-4 in a zero-shot setting without human intervention.
  • To evaluate whether AI-generated PHP websites and their associated database schemas (from GPT-3.5) are realistic and production-ready.
  • To identify and classify common vulnerabilities in LLM-generated web applications, particularly in file upload, SQL injection, and XSS.
  • To contribute a publicly available dataset (ChatPHP-DB) with vulnerability labels for future research in AI-generated code security.
  • To highlight the limitations of current LLMs in producing secure, complete, and production-viable web applications.

Proposed method

  • Generated 2,500 standalone PHP websites and corresponding init.sql database schemas using GPT-4-0125-preview and GPT-3.5 via zero-shot prompts.
  • Deployed each website in a Docker container to enable consistent, isolated execution and active scanning.
  • Applied a hybrid vulnerability detection methodology combining Burp Suite active scanning, static code analysis, and manual code audits.
  • Classified vulnerabilities using CWE identifiers based on manual verification and static analysis results.
  • Conducted manual penetration testing on a subset of 50 sites to validate automated findings and detect false negatives.
  • Published the full dataset, scan reports, and vulnerability labels on GitHub to enable reproducibility and benchmarking.

Experimental results

Research questions

  • RQ1To what extent does code generated by GPT-4 in a zero-shot setting exhibit vulnerabilities when produced through straightforward text prompts?
  • RQ2Does PHP code produced by GPT-4 and the corresponding init.sql file from GPT-3.5 result in a level of complexity and realism suitable for real-life deployment without major human intervention?
  • RQ3What is the frequency and nature of specific vulnerabilities—such as File Upload, SQL Injection, and XSS—in AI-generated PHP websites?

Key findings

  • At least 27% of the 2,500 AI-generated websites were found to be vulnerable, representing a conservative lower bound estimate.
  • Among 482 websites with file upload functionality, 376 were vulnerable according to static analysis, indicating a high prevalence of insecure upload handling.
  • In 1,150 cases, SQL queries were generated without prepared statements, increasing the risk of SQL injection attacks.
  • Manual code audits on 50 selected sites revealed 19 vulnerable instances, and penetration testing confirmed 4 exploitable vulnerabilities.
  • Seventy-four percent of the 50 manually reviewed sites were deemed too simplistic or incomplete to support real-world deployment, lacking essential security practices.
  • A total of 2,440 insecure or potentially vulnerable coding patterns were identified across the dataset, with 7 distinct CWE identifiers linked to the detected vulnerabilities.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.