🌐
Codacy
blog.codacy.com › java-vulnerabilities
11 Common Java Vulnerabilities and How to Avoid Them
2 weeks ago - In this example, the code uses the Data Encryption Standard (DES) algorithm to encrypt data. DES is considered weak by today's security standards due to its small key size (56 bits), making it susceptible to brute-force attacks. To mitigate this issue, we can replace the DES algorithm with the more secure Advanced Encryption Standard (AES) algorithm, which supports larger key sizes (128, 192, and 256 bits) and is widely accepted as secure. import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; public class StrongEncryptionExample { public static void main(
🌐
Medium
medium.com › javarevisited › security-vulnerabilities-in-java-application-e844bd281ff2
Security Vulnerabilities in Java application | by Srikanth Dannarapu | Javarevisited | Medium
April 9, 2023 - Here are a few examples of common security vulnerabilities and how to fix them: SQL Injection: SQL injection is a vulnerability where an attacker can inject malicious SQL code into a query, potentially allowing ...
Discussions

security - What are common Java vulnerabilities? - Stack Overflow
Usually, the vulnerabilities are in the application and not in the language itself. ... @Vineet: To be fair, the risk of creating a buffer overflow in the Java code you write is non-existant; same for C# and other managed languages. More on stackoverflow.com
🌐 stackoverflow.com
known vulnerabilities - Vulnerable Java applications? - Information Security Stack Exchange
I think the latter is probably more useful for evaluation of tools, as they are more likely to be representative of coding patterns in real applications. ... Take a look at SpringMVC jPetStore it has a number of nice vulnerabilities. See this link for detailS, examples, code samples and fixes More on security.stackexchange.com
🌐 security.stackexchange.com
Secure Coding Practices in Java Resources
OWASP secure code review guide is good but very long. You can also look at the code review content on pentesterlab and SecureFlag (requires an OWASP membership but absolutely worth it for 50$ for the whole year). More on reddit.com
🌐 r/bugbounty
17
7
April 26, 2024
Collection of vulnerable code snippets (updated every friday)
This is gonna be picked up by GitHub Copilot 😂 More on reddit.com
🌐 r/netsec
11
214
November 18, 2022
🌐
GitHub
github.com › snoopysecurity › Broken-Vulnerable-Code-Snippets › blob › master › SQL Injection › example.java
Broken-Vulnerable-Code-Snippets/SQL Injection/example.java at master · snoopysecurity/Broken-Vulnerable-Code-Snippets
March 23, 2025 - A small collection of vulnerable code snippets . Contribute to snoopysecurity/Broken-Vulnerable-Code-Snippets development by creating an account on GitHub.
Author   snoopysecurity
🌐
DZone
dzone.com › refcards › java application vulnerabilities
Java Application Vulnerabilities - DZone Refcards
There are many instances were a Debug mode may exist within a Java application, and this varies depending on the container. Here is one example of debug_mode disabled for the jsp servlet: ... Since developers may have implemented their own custom debug mode, be sure to inspect configuration files and search the code base for things like:
🌐
GitHub
github.com › bbossola › vulnerability-java-samples
GitHub - bbossola/vulnerability-java-samples: Sample exploits of common vulnerabilities in Java librarires · GitHub
Sample exploits of common vulnerabilities in Java librarires - bbossola/vulnerability-java-samples
Starred by 27 users
Forked by 80 users
Languages   Java 97.2% | Shell 2.8%
🌐
Finitestate
finitestate.io › blog › top-10-java-vulnerabilities
10 Major Java Vulnerability Types that Threaten Your Software
September 5, 2024 - If a hacker uploads more data than your buffer can hold, it may force your application to write the rest of their input over other code you’ve written. This can leave you vulnerable to foreign code being written over your code, leading to crashes, errors, or actions the software was never meant to perform.
🌐
GitHub
github.com › DataDog › vulnerable-java-application
GitHub - DataDog/vulnerable-java-application: This repository contains a sample Java application vulnerable to command injection and server-side request forgery (SSRF). · GitHub
kubectl run vulnerable-application --port=8000 --expose=true --image ghcr.io/datadog/vulnerable-java-application kubectl port-forward pod/vulnerable-application 8000 · You can then access the web application at http://127.0.0.1:8000 ... Note how the input allows you to specify arbitrary URLs such as http://google.com, but also any internal IP such as http://169.254.169.254/latest/meta-data/
Starred by 22 users
Forked by 131 users
Languages   Java 43.1% | HTML 30.4% | JavaScript 14.9% | Smarty 4.9% | Dockerfile 3.7% | Shell 2.6% | Makefile 0.4%
🌐
Shiftleft
docs.shiftleft.io › ocular › tutorials › java-vuln
Java Vulnerable Lab | ShiftLeft Docs
This tutorial is based on the popular Java project, Java Vulnerable Lab, a benchmarking application for vulnerability discovery tools. The project includes different sample vulnerabilities, such as typical injection vulnerabilities like SQL injection.
Find elsewhere
🌐
arXiv
arxiv.org › pdf › 2203.09009 pdf
Example-Based Vulnerability Detection and Repair in Java Code Ying Zhang
ized ways introduced in Section 3.5, and 9 pairs are defined with · plain Java examples. Within the 19 pairs, 8 pairs, 6 pairs, and 5 pairs ... Two datasets to evaluate pattern application. The first dataset · is a third-party benchmark, consisting of 86 real vulnerabilities
🌐
GitHub
github.com › ScaleSec › vulnado
GitHub - ScaleSec/vulnado: Purposely vulnerable Java application to help lead secure coding workshops
Purposely vulnerable Java application to help lead secure coding workshops - ScaleSec/vulnado
Starred by 191 users
Forked by 829 users
Languages   Java 56.4% | HTML 21.7% | JavaScript 9.0% | HCL 8.3% | CSS 2.4% | Shell 1.2% | Dockerfile 1.0% | Java 56.4% | HTML 21.7% | JavaScript 9.0% | HCL 8.3% | CSS 2.4% | Shell 1.2% | Dockerfile 1.0%
🌐
SonarSource
rules.sonarsource.com › java › type › vulnerability
Java static code analysis | Vulnerability
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your JAVA code
🌐
Spectral
spectralops.io › home › top 10 most common java vulnerabilities you need to prevent
Top 10 Most Common Java Vulnerabilities You Need to Prevent - Spectral
January 24, 2021 - Though Twitter doesn’t only use Java in its stack, the cautionary event can be applied to protecting your input forms. The easiest method is to apply input validation with output sanitizing and escaping. This means that any attempts at sending HTML code will be parsed or rejected, depending on what your application is doing. An OS command injection, or also commonly known as a shell injection, is a security vulnerability that allows attackers to execute shell commands on the server that’s running your application.
🌐
Pentesterlab
pentesterlab.com › exercises › java_07
PentesterLab: Java Snippet #07 Exercise !
The Code Review Snippet challenges present vulnerable code snippets for you to inspect and identify flaws. The Serve.java example highlights a directory traversal vulnerability due to improper path validation.
Top answer
1 of 4
5

Malicious Code injection.

Because Java (or any language using an interpreter at runtime), performs linkage at runtime, it is possible to replace the expected JARs (the equivalent of DLLs and SOs) with malicious ones at runtime.

This is a vulnerability, which is combated since the first release of Java, using various mechanisms.

  • There are protections in places in the classloaders to ensure that java.* classes cannot be loaded from outside rt.jar (the runtime jar).
  • Additionally, security policies can be put in place to ensure that classes loaded from different sources are restricted to performing only a certain set of actions - the most obvious example is that of applets. Applets are constrained by the Java security policy model from reading or writing the file system etc; signed applets can request for certain permissions.
  • JARs can also be signed, and these signatures can be verified at runtime when they're loaded.
  • Packages can also be sealed to ensure that they come from the same codesource. This prevents an attacker from placing classes into your package, but capable of performing 'malicious' operations.

If you want to know why all of this is important, imagine a JDBC driver injected into the classpath that is capable of transmitting all SQL statements and their results to a remote third party. Well, I assume you get the picture now.

2 of 4
2

After reading most of the responses I think your question has been answered in an indirect way. I just wanted to point this out directly. Java doesn't suffer from the same problems you see in C/C++ because it protects the developer from these types of memory attacks (buffer overflow, heap overflow, etc). Those things can't happen. Because there is this fundamental protection in the language security vulnerabilities have moved up the stack.

They're now occurring at a higher level. SQL injection, XSS, DOS, etc. You could figure out a way to get Java to remotely load malicious code, but to do that would mean you'd need to exploit some other vulnerability at the services layer to remotely push code into a directory then trigger Java to load through a classloader. Remote attacks are theoretically possible, but with Java it's more complicated to exploit. And often if you can exploit some other vulnerability then why not just go after and cut java out of the loop. World writable directories where java code is loaded from could be used against you. But at this point is it really Java that's the problem or your sys admin or the vendor of some other service that is exploitable?

The only vulnerabilities that pose remote code potential I've seen in Java over the years have been from native code the VM loads. The libzip vulnerability, the gif file parsing, etc. And that's only been a handful of problems. Maybe one every 2-3 years. And again the vuln is native code loaded by the JVM not in Java code.

As a language Java is very secure. Even these issues I discussed that can be theoretically attacked have hooks in the platform to prevent them. Signing code thwarts most of this. However, very few Java programs run with a Security Manager installed. Mainly because of performance, usability, but mainly because these vulns are very limited in scope at best. Remote code loading in Java hasn't risen to epidemic levels that buffer overflows did in the late 90s/2000s for C/C++.

Java isn't bullet proof as a platform, but it's harder to exploit than the other fruit on the tree. And hackers are opportunistic and go for that low hanging fruit.

🌐
GitHub
github.com › snoopysecurity › Broken-Vulnerable-Code-Snippets
GitHub - snoopysecurity/Broken-Vulnerable-Code-Snippets: A small collection of vulnerable code snippets · GitHub
A small collection of vulnerable code snippets . Contribute to snoopysecurity/Broken-Vulnerable-Code-Snippets development by creating an account on GitHub.
Starred by 794 users
Forked by 793 users
Languages   PHP 34.4% | JavaScript 16.8% | C# 14.4% | C 12.5% | Python 11.0% | Java 6.2%
🌐
ACM Digital Library
dl.acm.org › doi › abs › 10.1145 › 3524610.3527895
Example-based vulnerability detection and repair in Java code | Proceedings of the 30th IEEE/ACM International Conference on Program Comprehension
The Java libraries JCA and JSSE offer cryptographic APIs to facilitate secure coding. When developers misuse some of the APIs, their code becomes vulnerable to cyber-attacks. To eliminate such vulnerabilities, people built tools to detect security-API misuses via pattern matching. However, most tools do not (1) fix misuses or (2) allow users to extend tools' pattern sets. To overcome both limitations, we created Seader---an example...
🌐
Piazza
piazza.com › class_profile › get_resource › hbse78gzt4m3p8 › hc0xab9j1pb6b9 pdf
Vulnerable Java Code
Piazza is a free online gathering place where students can ask, answer, and explore 24/7, under the guidance of their instructors. Students as well as instructors can answer questions, fueling a healthy, collaborative discussion.
🌐
CodeSandbox
codesandbox.io › p › github › Undead34 › vulnerable-code-examples
vulnerable-code-examples
CodeSandbox is a cloud development platform that empowers developers to code, collaborate and ship projects of any size from any device in record time.
Top answer
1 of 3
7

If you are new to hunting I recommend starting out with WebGoat or Damn Vulnerable WebApp (DVWA). This is because it frames each vulnerability nicely, you just have to point and shoot. You can practice exploitation, and working with a real vulnerability. "The shooting range"

There are real applications that where intentionally written to be insecure (Like the Hacme series, which is under SASS Tools). The Dojo has a collection of these apps loaded onto a VM as well as tools to audit them. This is really the 2nd step because now you have to find where to shoot. "Hunting on the farm"

The 3rd step is going out and finding a real application. Search github/sourceforge/bitbucket/ect for web applications that are less than a year old and aren't that popular. These apps will vary, but most often then will be very insecure. "Hunting in the wild"

After that start working your way up to more popular applications, get CVE numbers, write exploit code, and explore newly developed exploitation techniques: exploit-db.com . "It gets more wild..."

2 of 3
2

Check out Stanford SecuriBench. It is a collection of open-source Java web applications that have had a variety of vulnerabilities, and which were used in some previous research papers to evaluate research tools. The collection is old (2005?) but it might still be useful for your purposes.

The benchmark includes both artificial applications that were designed to showcase some vulnerabilities (like WebGoat), as well as some realistic applications that were taken from real life and are not artificial. I think the latter is probably more useful for evaluation of tools, as they are more likely to be representative of coding patterns in real applications.

🌐
Security Boulevard
securityboulevard.com › home › cybersecurity › devops › common vulnerabilities in java and how to fix them
Common vulnerabilities in Java and how to fix them - Security Boulevard
November 30, 2021 - 30 vulnerabilities to look out for in Java applications: Arbitrary file writes, directory traversal, deserialization, and more…Photo by Cookie the Pom on UnsplashSecuring applications is not the easiest thing to do. An application has many components: server-side logic, client-side logic, ...