{"slug": "ai-generated-code-security-risks-what-qodana-found-in-a-java-app", "title": "AI-Generated Code Security Risks: What Qodana Found in a Java App", "summary": "A focused Qodana static-analysis scan of the Corporate Payments Portal, a Java 21 and Spring Boot application from the RealVuln Benchmark that deliberately seeds vulnerabilities in AI-generated code, produced 65 findings across 21 files, JetBrains' Qodana team reported. The scan targeted data flows, vulnerable dependencies, hardcoded passwords and dependency licenses, and the team framed the results as a triage queue rather than proof of exploitable flaws, noting that reviewers must still confirm whether each path is reachable in production. The team cited a study of AI-generated Python and JavaScript snippets in public GitHub projects that found weaknesses across 43 Common Weakness Enumeration (CWE) categories, and OWASP guidance recommending review of any fully agent-produced changes, including dependencies and tests.", "body_md": "## Qodana\n\nThe code quality platform for teams\n\n# AI-Generated Code Security Risks: What Qodana Found in a Java App\n\nAdding search functionality, converting a document, or connecting a service sound like small changes. An AI coding agent may take it on in one pass, changing application logic, dependencies, configuration, and tests along the way. The result may pass functional tests and still contain security vulnerabilities.\n\nStatic analysis can surface some AI-generated code security risks, while reviewers and targeted tests determine which findings matter in practice. Where can external input travel? What happens if a configuration value is missing? Do the new dependencies introduce risks the functional tests never exercise? The same questions matter in any codebase, including code written with AI.\n\nA study of [AI-generated Python and JavaScript snippets](https://arxiv.org/abs/2310.02059) in public GitHub projects found weaknesses across 43 Common Weakness Enumeration (CWE) categories. [OWASP recommends](https://cheatsheetseries.owasp.org/cheatsheets/Secure_Coding_with_AI_Cheat_Sheet.html) reviewing any fully agent-produced changes, including dependencies and tests. Passing tests are useful evidence, but they don’t answer every security question. \n\nStatic analysis gives reviewers a place to start. It can point to [data flows](https://blog.jetbrains.com/qodana/2025/05/taint-analysis-qodana/), unsafe code patterns, vulnerable dependencies, and hardcoded values, but each finding still needs context. A reviewer must check whether the path is reachable, what runs in production, and which fix fits the application. \n\n## Table of Contents\n\n## Why AI-generated code still needs a security review\n\nAn agent may implement the requested behavior while missing constraints that live outside the feature description. Passing functional tests may still leave questions about how data crosses trust boundaries or how deployment settings affect security. [OWASP’s secure code review guidance](https://cheatsheetseries.owasp.org/cheatsheets/Secure_Code_Review_Cheat_Sheet.html) calls for understanding business requirements, tracing data flows, and checking configuration and deployment. These checks often span modules.\n\nQodana points to relevant paths and patterns, then reviewers supply the application context needed to judge them.\n\n## Scanning the Corporate Payments Portal with Qodana\n\nWe examined the Corporate Payments Portal, a Java app from the [RealVuln Benchmark](https://github.com/kolega-ai/Real-Vuln-Benchmark), alongside its [public Qodana report](https://jb.gg/778nvr). The benchmark deliberately seeds vulnerabilities in AI-generated code, giving us concrete findings to investigate. We’ll follow several of them from the code to the questions a reviewer would ask. This single case does not tell us how often AI introduces vulnerabilities.\n\nThe Corporate Payments Portal uses Java 21 and Spring Boot and includes a web portal, a payment API, a mock core banking service, and a batch worker. We use a [pinned source revision](https://github.com/kolega-ai/vc-sonnet-5-claude-code-seeded-v4-corp-payments-springboot/tree/122bbdf32a14101665621cfe9b1d9a0377a9d320) so the excerpts match the report. That matters because a risky flow may begin with a controller and end with a service, while a dependency or configuration value can create a separate concern even when a Java method looks ordinary.\n\nWe ran a focused Qodana scan for data flows, vulnerable dependencies, hardcoded passwords, and dependency licenses. The password inspection was configured more broadly than its defaults for this example. Qodana’s findings provide starting points – a trace can show where data may travel, and a dependency alert can identify a version with known advisories. Neither, by itself, settles whether a specific attack is reachable in this deployment.\n\n## What Qodana found in the application\n\nThe public Qodana report lists 65 findings across 21 files. That is a triage queue, not a count of exploitable vulnerabilities. Alerts repeat across modules, and some point to synthetic values in tests and documentation. The examples below show how a finding can lead to a concrete question about code, configuration, or dependencies.\n\n### A vulnerable dependency and an XML-processing call\n\nThe Corporate Payments Portal’s web module parses XML drafts using XStream. Its build file, `portal/build.gradle`, declares version 1.4.7:\n\n```\nimplementation 'com.thoughtworks.xstream:xstream:1.4.7'\n```\n\n[Qodana’s dependency check](https://qodana.cloud/projects/v5gMK/reports/5vVBLn?problem=2249ea81f4d24db1a818edbd43a8e0582b149114ed708ff74c75a12d1165c89a) flags this version and lists known advisories. [A separate taint finding](https://qodana.cloud/projects/v5gMK/reports/5vVBLn?problem=ffb23503bdc487810d366126ece7d40667c2a81bfb2e3ff6d1cf2746ff3c35c2) points to the call that turns the XML string into Java objects:\n\n```\nnew com.thoughtworks.xstream.XStream().fromXML(draft)\n```\n\nThese two signals answer different questions. The dependency alert says the application includes a version with known issues. The fromXML(draft) call takes its XML from the cpDeskDraft browser cookie. The controller checks only whether the cookie is empty. Because a client can change its cookie, this is considered untrusted input. XStream 1.4.7 does not use a type allowlist by default, so deserialization can instantiate unintended types. The exact impact depends on the payload and runtime environment.\n\nThe taint finding is labeled path traversal in this report, and the vulnerable API usage inspection did not produce a separate result. It would be misleading to tie a specific CVE to this call from these findings alone. Review whether XML deserialization is needed at all. If it is, update the dependency, [allow only expected types](https://x-stream.github.io/security.html), and test that unexpected XML is rejected.\n\n### A hardcoded fallback remains in configuration\n\nIn the Corporate Payments Portal’s payment API, the legacy report bridge reads an intake key from a Spring configuration property. [The colon inside the Spring placeholder](https://docs.spring.io/spring-boot/reference/features/external-config.html#features.external-config.files.property-placeholders) defines a fallback value:\n\n```\nlegacy-report-bridge:\n  intake-key: ${LEGACY_REPORT_BRIDGE_KEY:legacy-bridge-dev-key-9c1e}\n```\n\nSpring reads the value after the colon when `LEGACY_REPORT_BRIDGE_KEY` is absent. The same fallback also appears in `LegacyReportBridge`‘s Java constructor. That component sends the resulting key to an internal reporting service as a `bridge-key` query parameter. In this benchmark, the value is synthetic, but a deployment that omits the environment variable could silently use a credential stored in source control.\n\n[Qodana’s Hardcoded passwords inspection](https://qodana.cloud/projects/v5gMK/reports/5vVBLn?problem=e558dd4ead95cf3b59b9d24a9bb43c9b8f7e19e197134f6bcb37a353f435e609) flagged this example after we [enabled detection based on suspicious variable names](https://www.jetbrains.com/help/qodana/detect-passwords.html). Its default configuration would not flag this exact pattern. For production, remove the fallback in both the `application.yml` and `LegacyReportBridge`‘s `@Value` annotation. Require the key from an external secret source and fail startup if it is missing. Keep any development default confined to a development profile, and confirm whether the bridge is enabled in deployed environments.\n\nFor another example of Qodana detecting a hardcoded password, watch Helen’s video walkthrough:\n\n### A license finding raises a different question\n\nOne finding concerns dependency policy rather than an exploitable bug. In the Corporate Payments Portal, [Qodana’s license audit](https://qodana.cloud/projects/v5gMK/reports/5vVBLn?problem=9fc1da35ab8df6c7fb77ecfb24fe510528a3afd691b0ef6f859b904fdd1e397a) flags `hibernate-core 6.5.3.Final`, brought in transitively, because its LGPL-2.1-or-later license is on the report’s prohibited list for a project marked `PROPRIETARY-LICENSE`. Transitive means another dependency brings the component into the build; it may not appear in the developer’s direct dependency list.\n\nThe risk is making a distribution decision without reviewing the dependency’s obligations. This is a policy signal, not a legal conclusion or evidence that `hibernate-core` is insecure. A reviewer should confirm the project’s actual policy and distribution model, [review the applicable terms](https://www.jetbrains.com/help/qodana/license-audit.html), and then document an accepted exception or choose another dependency path. Repeated alerts across modules do not necessarily represent different libraries.\n\n## How to use the findings in a security review\n\nAn alert becomes useful when it changes a review decision. The examples give us different kinds of evidence, and each leaves a different question open. The table summarizes selected signals:\n\n| **Pattern** | **What Qodana shows** | **Review question** | \n| Vulnerable dependency | Advisories and an XML call | What objects could XStream create from this cookie? | \n| Credential fallback | Constant key in configuration | Could the fallback run in production? | \n| License policy | Transitive license policy alert | Does the project policy allow it? | \n\nA developer using [JetBrains Air](https://www.jetbrains.com/air/) can open an agent’s diffs in context and leave comments on specific lines for the agent to act on. Qodana adds a different view, scanning the codebase and reporting issues found by its inspections. The developer can weigh both when deciding what to fix. The findings discussed in this article were derived solely from Qodana.\n\nFrom there, the team checks whether input reaches each operation, whether an affected component is actually used, and which configuration applies in deployment. It fixes the relevant code or policy, tests the change, and records why any remaining alerts are accepted or dismissed. Supported checks can also run in CI, so later changes receive the same review signals.\n\nStatic analysis makes these questions visible and repeatable. It helps the team spend review time on specific paths and components, while developers supply the application context and decide whether a change is ready to ship.\n\nYou can explore the evidence in our public report. If you would like to run the experiment yourself, leave a comment, and we’ll get in touch to help with the setup.\n\n## FAQ\n\n### **Is AI-generated code more vulnerable than human-written code?**\n\nThere is no universal answer. Results depend on the tool, task, application context, and review process. This deliberately vulnerable benchmark cannot establish a comparative rate.\n\n### **Can static analysis detect every security issue in AI-generated code?**\n\nNo. It can identify supported patterns and trace some data flows, but it can miss application-specific authorization rules and runtime behavior. Combine it with human review and targeted testing.\n\n### **Can Qodana automatically secure AI-generated code?**\n\nQodana can automate supported inspections and surface findings for triage. It cannot determine whether every flagged path is exploitable or whether the application’s security requirements are complete.\n\nGet more practical insights on code quality and security. [Subscribe to the Qodana blog](https://jb.gg/6hazvh) for new posts.\n\n#### Subscribe to Qodana Blog updates", "url": "https://wpnews.pro/news/ai-generated-code-security-risks-what-qodana-found-in-a-java-app", "canonical_source": "https://blog.jetbrains.com/qodana/2026/11/ai-generated-code-security-risks/", "published_at": "2026-11-17 11:33:51+00:00", "updated_at": "2026-11-17 19:54:17.490509+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-safety", "artificial-intelligence"], "entities": ["Qodana", "JetBrains", "Corporate Payments Portal", "RealVuln Benchmark", "OWASP", "Common Weakness Enumeration", "Spring Boot", "Java 21"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/ai-generated-code-security-risks-what-qodana-found-in-a-java-app", "markdown": "https://wpnews.pro/news/ai-generated-code-security-risks-what-qodana-found-in-a-java-app.md", "text": "https://wpnews.pro/news/ai-generated-code-security-risks-what-qodana-found-in-a-java-app.txt", "jsonld": "https://wpnews.pro/news/ai-generated-code-security-risks-what-qodana-found-in-a-java-app.jsonld"}}