Menu

Java Security Code Review: Sinks and Pitfalls
📰

Java Security Code Review: Sinks and Pitfalls

DEV Community: java·Stefan·6 days ago
#Xg4irIIn
#devtojava#devto#dev#java#code
Long article (1076 words) — no AI summary yet.
Reading 0:00
15s threshold

When you review Java code, the most dangerous bugs rarely look broken. They look like clean, standard object-oriented code, normal configuration classes, or convenient framework helpers.

Finding these flaws means following data from an untrusted source, past type boundaries, straight into runtime sinks. A sink is an API method that performs a sensitive operation, such as parsing an archive, executing a command, or running a database query.

Here is how to spot and fix the most common high-risk Java sinks during a pull request review.

The Default Parser Trap: XML and XXE

Java's standard XML parsing APIs date back decades. By default, parsers such as DocumentBuilderFactory enable Document Type Definitions (DTDs) and external entity resolution.

When an attacker supplies XML containing an external entity, the parser tries to resolve it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.