DEV Community

Avinash Lonkar
Avinash Lonkar

Posted on

How I Reduced CVEs in a Java Project by Cleaning Up Maven POMs

In one of my recent Java projects, I noticed that the dependency setup had become messy over time. The project had double-digit CVEs, repeated version declarations, and several unwanted libraries spread across child POM files.
This created two problems. First, the security risk was higher because vulnerable dependencies were still part of the build. Second, the project was harder to maintain because dependency versions and library declarations were not managed in a clean way.

What was wrong

The main issues were simple but important:

  • Version values were repeated in multiple child POMs.
  • Some dependencies were no longer needed but were still present.
  • The overall dependency tree had grown over time without enough cleanup.
  • The number of known CVEs had reached double digits.
  • This is a common problem in long-running Java projects. Teams keep adding features and fixes, but old libraries and duplicate declarations stay behind.

What I changed
I started by improving the Maven structure.

First, I defined dependency versions in the parent POM only. This made the build more consistent because the version was managed in one place instead of being copied into many child modules.

Next, I reviewed the child POMs and removed unwanted libraries. Some dependencies were added for older requirements, but they were no longer needed. Removing them reduced clutter and made the module files easier to read.

After that, I checked the vulnerable dependencies and applied the required fixes. In some cases, that meant upgrading a library. In other cases, it meant removing a dependency completely because it was not needed anymore.

Result

The result was a clear improvement.

  • CVEs were reduced from double digits to single digits.
  • The parent POM became the single source of truth for versions.
  • Child POMs became cleaner and shorter.
  • The project became easier to maintain for future changes. This was a good reminder that security work and build cleanup often go together. A cleaner dependency structure can reduce risk and make the codebase easier to manage at the same time.

What I learned
A few lessons stood out from this work:

  • Centralizing version management reduces duplication.
  • Removing unused libraries can improve both security and maintainability.
  • CVE reduction is not only about upgrades; it is also about removing unnecessary dependencies.
  • Small build changes can create real engineering impact.

In many projects, dependency cleanup is ignored because it does not look as exciting as feature development. But it can have a strong effect on the health of the codebase.

Final thought
This experience showed me that practical engineering improvements matter. By cleaning up the Maven POM structure and reducing unwanted dependencies, I was able to lower the security exposure and make the project easier to support.

Sometimes the most valuable work is not adding new code. Sometimes it is making the existing codebase safer, cleaner, and simpler.

Top comments (0)