Skip to content
javahacks.dev
Security

Java Security Checklist Before Release for Web Services

A Java security checklist to run before release: dependencies, secrets, authentication, input handling, transport, logging and containers.

5 min read
Summarize in AI
Flat illustration of a shield with a lock, a key and a password field, with the OpenJDK, Spring Security, Keycloak and OWASP logos.

This is a pre-release checklist for a Java web service, ordered by where problems tend to hide. It does not replace a threat model, but it catches the mistakes that cause most incidents, and every line names a way to check, since a checklist item that cannot be verified is an opinion. The background is in Java security basics and the OWASP Top Ten for Java developers.

Dependencies

Most vulnerabilities in a typical service arrive through a library you did not write. Treat the dependency scan as a gate and not as a report.

CheckHow to verify
A dependency scan runs in CI and critical findings fail the buildThe pipeline file contains the step, and a deliberately old library makes it fail
Direct dependencies are current and maintainedA report of outdated dependencies, reviewed for abandoned projects
The base image is recent and scannedtrivy image your-service:release shows no critical findings
An SBOM is generated for the artifactThe CycloneDX plugin output is stored with the build
Shell
mvn org.owasp:dependency-check-maven:check -DfailBuildOnCVSS=9

The threshold is a policy choice. Failing at 9 blocks only the worst findings and keeps the gate usable on day one, and you can lower it as the backlog clears.

Secrets

CheckHow to verify
No credentials, keys or tokens in the repository or its historygitleaks detect --source . finds nothing
Secrets come from the environment or a secret managerThe deployment manifest references a secret, never a literal
The image holds no .env file or private keydocker run --rm your-service ls -la /app shows a clean tree
Any secret that was ever committed has been rotatedRemoving it from history is not enough, because clones and caches keep it

The last row is the one teams skip. A secret in git history is compromised from the moment it was pushed, and the only fix is a new secret.

Authentication and authorization

Authentication asks who the caller is, and authorization asks what they may do. Most serious bugs in business applications are the second kind: a logged-in user reading another user's record by changing an id in the URL.

CheckHow to verify
Every endpoint requires authentication unless deliberately publicList the routes and mark each public one with a reason
Authorization is checked on the server, per resourceAn integration test where user A requests user B's record and expects 403 or 404
Passwords use a slow hash such as Argon2 or bcryptRead the encoder bean, see hashing passwords
Sessions and tokens expire, and logout invalidates themTest that a token is rejected after logout and after its expiry
Login and expensive endpoints are rate limitedSend 100 failed logins and expect throttling

Input and output

Every place that builds a query, a page, a file path or a request out of user input needs its own defence. The relevant guides are SQL injection, preventing XSS, path traversal, XXE, insecure deserialization and SSRF.

CheckHow to verify
Input is validated at the boundary with Bean ValidationControllers use @Valid, and a test posts a bad payload
All SQL uses parametersSearch for string concatenation near createQuery and Statement
Output is encoded for its contextTemplates use the escaping syntax, and no raw HTML from users is written
Uploads check type, size and the stored pathUpload a file named with ../ and expect it to be refused
XML parsers disable external entitiesThe factory sets the secure processing feature
Outbound requests to user-supplied URLs are restrictedA request for an internal address is refused

Transport and headers

Shell
curl -sI https://staging.example.test/ | grep -iE 'strict-transport|content-security|x-content-type|set-cookie'

That one command shows most of this section. Look for HSTS, a content security policy and nosniff. Cookies should carry Secure, HttpOnly and SameSite. CSRF protection is required for state-changing requests authenticated by cookie, and not for pure token APIs. CORS should list specific origins; a wildcard combined with credentials is a bug.

Configuration and operations

Production should have no debug endpoints, no H2 console and no Actuator details exposed without authentication. Error responses must not carry stack traces. No JDWP debug port should be open, which a port scan from outside the network confirms. Logs must exclude passwords, tokens and personal data, and security events such as login failures and access denials should be logged and watched.

Container

CheckHow to verify
The process runs as a non-root userdocker run --rm your-service id does not print uid=0
The image has no tools it does not needReview the final stage of the Dockerfile
The filesystem is read-only where possible, with resource limitsThe manifest sets readOnlyRootFilesystem and limits

Making the checklist a habit

A checklist on a wiki page decays. Put it where the release happens: a pull request template with the manual items as checkboxes, and the automated ones as required status checks so the merge button stays grey until they pass. Assign the review to a person by name each release, rotating, so more than one engineer learns what the gates are for. After an incident, ask which line would have caught it, and if none, add one. After a release where nothing on the list failed for months, ask whether a check has become automatic enough to remove from the manual part. Short lists get used, and a list of eighty items is ticked without being read.

The most valuable single item for most teams is the authorization test, the one where user A asks for user B's record. It takes an hour to write the first time, fails often in real codebases, and finds the bug class that scanners cannot, since a scanner does not know which records belong to whom.

Using the list

Turn every item you can automate into a pipeline check and keep the rest as a template on the release pull request. Add a line whenever an incident teaches you one. A list that only grows is fine; a list that nobody ticks is not, so put an owner against the review. Regulated systems have their own control lists that take precedence over this one. The standard to grow it toward is the OWASP Application Security Verification Standard, and the Spring Security reference covers the framework settings.

Taggedlisting
Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.