Mitigação de Vulnerabilidades de Segurança em Código Gerado por Inteligência Artificial: um Guia Técnico e uma Arquitetura de Análise Automatizada
Resumo
Código produzido por assistentes de programação baseados em inteligência artificial reproduz, com frequência, padrões conhecidos de falhas. Este artigo apresenta dois artefatos complementares: um guia técnico de mitigação que organiza em sete categorias (GIA-001 a GIA-007) as vulnerabilidades recorrentes em código gerado por IA, com mapeamento para CWE e OWASP e recomendações acionáveis; e uma arquitetura de análise em filtros e dutos, independente de linguagem, que integra análise estática, heurísticas sobre AST, classificação e recomendação, avaliada por um protótipo em Python. Em corpora rotulados por terceiros, ela empata com uma ferramenta SAST consolidada na detecção, enquanto 98% dos achados recebem categoria do guia e 100% dos classificados recebem mapeamento CWE/OWASP e recomendação estruturada.
Referências
Fu, Y. et al. (2025). Security weaknesses of Copilot-generated code in GitHub projects: An empirical study. ACM Transactions on Software Engineering and Methodology, 34(8):1–34.
He, J. and Vechev, M. (2023). Large language models for code: Security hardening and adversarial testing. In Proceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security, pages 1865–1879. ACM.
Pearce, H. et al. (2022). Asleep at the keyboard? Assessing the security of GitHub Copilot’s code contributions. In 2022 IEEE Symposium on Security and Privacy (SP), pages 754–768. IEEE.
Pearce, H. et al. (2023). Examining zero-shot vulnerability repair with large language models. In 2023 IEEE Symposium on Security and Privacy (SP), pages 2339–2356. IEEE.
Sajadi, A. et al. (2025). Do LLMs consider security? An empirical study on responses to programming questions. Empirical Software Engineering, 30:101.
Siddiq, M. L. and Santos, J. C. S. (2022). SecurityEval dataset: mining vulnerability examples to evaluate machine learning-based code generation techniques. In Proceedings of the 1st International Workshop on Mining Software Repositories Applications for Privacy and Security, pages 29–33. ACM.
Spracklen, J. et al. (2025). We have a package for you! A comprehensive analysis of package hallucinations by code generating LLMs. In 34th USENIX Security Symposium, pages 3687–3706.
Tihanyi, N. et al. (2025). How secure is AI-generated code: a large-scale comparison of large language models. Empirical Software Engineering, 30(2):47.
Wadhams, Z. D., Reinhold, A. M., and Izurieta, C. (2024). Barriers to using static application security testing (SAST) tools: A literature review. In 39th IEEE/ACM International Conference on Automated Software Engineering Workshops. ACM.
Zhao, S. et al. (2025). Is vibe coding safe? Benchmarking vulnerability of agent-generated code in real-world tasks. arXiv:2512.03262.