Security Assessment of Source Code Generated by Generative Artificial Intelligence: A Composite Scoring Model
Keywords:
generative artificial intelligence, AI-generated code, software security, static and dynamic analysis, SQL injection, cross-site scripting, CWE, security metricsAbstract
Generative AI assistants now write a growing share of production code, yet empirical studies repeatedly find that a substantial fraction of the code they produce contains exploitable weaknesses such as SQL injection, cross-site scripting (XSS), weak authentication and exposed secrets. This paper proposes a transparent, reproducible framework for assessing the security of AI-generated source code and condensing the evidence into a single decision-support index. The framework combines static analysis (SAST), dynamic analysis (DAST) and data-analytic prioritisation, and aggregates five security dimensions (vulnerability resistance, data confidentiality, secure-coding conformance, authentication and access-control reliability, and robustness) into a weighted composite index S on a 0–100 scale. Dimension scores are derived from severity-weighted finding density, and a critical-finding gate prevents a high average from masking a severe flaw. The assessment maps five recurrent vulnerability classes to CWE and OWASP categories and to the tools able to detect them. A worked example gives S = 81.75 ("good"), and a sensitivity analysis shows that the index is stable under reasonable re-weighting (range 81.75–82.25) but that a single leaked credential lowers it to 70.5 and, through the gate, blocks release. Functional correctness does not imply security; automated scanning combined with expert review is the most defensible practice. The index is a model proposal and has not yet been validated on real code corpora, which is the principal direction for future work.
Downloads
References
Pearce H., Ahmad B., Tan B., Dolan-Gavitt B., Karri R. Asleep at the keyboard? Assessing the security of GitHub Copilot's code contributions. Proc. IEEE Symposium on Security and Privacy, 2022. arXiv:2108.09293.
Perry N., Srivastava M., Kumar D., Boneh D. Do users write more insecure code with AI assistants? Proc. ACM CCS '23, Copenhagen, 2023. doi:10.1145/3576915.3623157.
Khoury R., Avila A.R., Brunelle J., Camara B.M. How secure is code generated by ChatGPT? arXiv:2304.09655, 2023.
Tihanyi N., Bisztray T., Jain R., Ferrag M.A., Cordeiro L.C., Mavroeidis V. The FormAI dataset: Generative AI in software security through the lens of formal verification. Proc. PROMISE 2023, pp. 33–43. doi:10.1145/3617555.3617874.
Fu Y., Liang P., Tahir A., Li Z., Shahin M., Yu J., Chen J. Security weaknesses of Copilot-generated code in GitHub projects: an empirical study. ACM Transactions on Software Engineering and Methodology. doi:10.1145/3716848.
Veracode. 2025 GenAI Code Security Report, 30 July 2025. https://www.veracode.com/genai-code-security-report
OWASP Foundation. OWASP Top 10:2021. https://owasp.org/Top10
MITRE. Common Weakness Enumeration (CWE). https://cwe.mitre.org
Souppaya M., Scarfone K., Dodson D. Secure Software Development Framework (SSDF) Version 1.1. NIST SP 800-218, 2022. doi:10.6028/NIST.SP.800-218.
Semgrep. Static analysis tool. https://semgrep.dev
Bandit. Security linter for Python. https://bandit.readthedocs.io
SonarQube. Code quality and security platform. https://www.sonarsource.com
OWASP ZAP. Dynamic application security scanner. https://www.zaproxy.org
Downloads
Published
License
Copyright (c) 2026 Engineering problems and innovations

This work is licensed under a Creative Commons Attribution 4.0 International License.





