Loa ding
FLASH SALE!!! Tools Kalkulator Gym, hanya 5k dengan kode ADS5K.
Learn more
Security

Qodana Scan Reveals Security Risks in AI-Generated Java Code

A 4 min read 6 0
Qodana Scan Reveals Security Risks in AI-Generated Java Code
Illustration of a Qodana security scan on a Java application

Code produced by an AI coding agent can pass functional tests and still hide security vulnerabilities. JetBrains shows this with Qodana, its static analysis tool, by scanning the Corporate Payments Portal, a Java app from the RealVuln Benchmark. The results show what to check when reviewing AI-generated code security, and where automated tools stop being helpful.

Why AI-generated code security still needs a review

Requests like adding search, converting a document, or connecting a service sound minor. An agent can handle them in one pass, changing application logic, dependencies, configuration, and tests along the way. The feature works and the tests pass, but constraints outside the feature description can slip through. For example, where can external input travel, or what happens when a configuration value is missing?

A study of AI-generated Python and JavaScript snippets in public GitHub projects found weaknesses across 43 Common Weakness Enumeration (CWE) categories. OWASP recommends reviewing any change produced entirely by an agent, including dependencies and tests. Static analysis is a useful starting point because it can point to data flows, unsafe code patterns, vulnerable dependencies, and hardcoded values. Even so, a reviewer still has to check whether the path is reachable, what runs in production, and which fix suits the application.

What Qodana found in the Corporate Payments Portal

The app uses Java 21 and Spring Boot, with a web portal, a payment API, a mock core banking service, and a batch worker. The benchmark deliberately seeds vulnerabilities in AI-generated code, so the findings are concrete enough to dig into. This single case obviously doesn't tell us how often AI introduces vulnerabilities. The scan focused on data flows, vulnerable dependencies, hardcoded passwords, and dependency licenses. Qodana's public report lists 65 findings across 21 files. That number is a triage queue, not a count of exploitable vulnerabilities, since some alerts repeat across modules or point to synthetic values in tests and documentation.

Advertisement

The first example is in the web module, which parses XML drafts with XStream. The portal/build.gradle file declares version 1.4.7. Qodana flags this version and lists known advisories. A separate taint finding points to the call new com.thoughtworks.xstream.XStream().fromXML(draft), which turns an XML string into Java objects. The two signals answer different questions:

  • Dependency alert: the application includes a version with known issues.
  • Taint finding: the XML comes from the cpDeskDraft browser cookie, and the controller only checks whether the cookie is empty. Because a client can change its cookie, this input is untrusted.

XStream 1.4.7 has no type allowlist by default, so deserialization can instantiate unintended types. The exact impact depends on the payload and the runtime environment. The report also labels that taint finding as path traversal, and the vulnerable API usage inspection produced no separate result. Tying a specific CVE to this call from these findings alone would be misleading. A sensible next step is to check whether XML deserialization is needed at all. If it is, update the dependency, allow only expected types, and test that unexpected XML is rejected.

The second example is in the payment API. The legacy report bridge reads an intake key from a Spring configuration property: ${LEGACY_REPORT_BRIDGE_KEY:legacy-bridge-dev-key-9c1e}. The colon in the placeholder defines a fallback value, so Spring uses legacy-bridge-dev-key-9c1e when the LEGACY_REPORT_BRIDGE_KEY variable is absent. The same fallback also appears in the Java constructor of LegacyReportBridge, and the key is sent to an internal reporting service as a bridge-key query parameter. In this benchmark the value is synthetic, but a deployment that forgets to set the environment variable would quietly fall back to the value baked into the code. The report also contains a dependency license finding, which raises a different kind of question: compliance rather than a technical flaw.

If your team already uses AI coding agents, this case is a reminder that green tests don't answer every security question. Treat Qodana's output as a list of places to start asking questions, then decide with your application's context which findings are truly risky.

Advertisement
Category Security
Share
A

Written by

Andreas Budi Ekayana

Andreas Budi Ekayana is the founder of AndreDEV Studio, a Bandung-based digital development studio established in 2011. Drawing on more than a decade of experience as a developer and designer, Andreas writes about techno...

See more articles

Comments 0

No comments yet. Be the first to share your thoughts.

Leave a comment

Comments are moderated automatically. Please be respectful. 0 / 1500