Skip to content

feat: add 5 ssrf-guard demos for v3.0.0 multi-module release#6

Merged
jlc488 merged 2 commits into
mainfrom
ssrf-guard-demos
May 23, 2026
Merged

feat: add 5 ssrf-guard demos for v3.0.0 multi-module release#6
jlc488 merged 2 commits into
mainfrom
ssrf-guard-demos

Conversation

@jlc488
Copy link
Copy Markdown
Contributor

@jlc488 jlc488 commented May 23, 2026

Summary

Adds five runnable demos — one per significant module from the ssrf-guard v3.0.0 release. Each demo is a standalone Spring Boot app with curl-ready endpoints and smoke tests.

Demos

Demo What's shown
ssrf-guard-demo RestClient + RestTemplate + WebClient all wired through one UrlPolicy. /attacks endpoint catalogues 15 SSRF bypass patterns with pre-built curls. Includes Micrometer + actuator.
ssrf-guard-springai-demo LLM-agent SSRF defense. FakeLlmService simulates a real ChatClient driving a fetch_url tool. The auto-wrap on every ToolCallback bean blocks URL-shaped attacker arguments before the tool runs — and returns a structured JSON error the LLM can interpret.
ssrf-guard-feign-demo Spring Cloud OpenFeign. Two @FeignClient interfaces (one whitelisted, one not) show the block path through the RequestInterceptor.
ssrf-guard-jdkhttp-demo java.net.http.HttpClient wrapper — three-line wiring with no Spring dependency on the library itself.
ssrf-guard-okhttp-demo OkHttp Interceptor + Dns — three-line OkHttpClient.Builder setup.

Highlights

  • Real-world attack URLs as test inputs: AWS metadata (169.254.169.254), decimal-encoded loopback (2130706433), IPv4-mapped IPv6 ([::ffff:10.0.0.5]), userinfo bypass (user:pass@evil.com), redirect-to-private (httpbin.org/redirect-to?url=169.254...).
  • Spring AI offline — no LLM API key needed. The fake driver shows the security story without depending on OpenAI/Anthropic/etc. Swap FakeLlmService for a ChatClient and the wrap behaviour is identical.
  • Catalog endpoint in ssrf-guard-demo and ssrf-guard-springai-demoGET /attacks / GET /agent/attacks returns every blocked pattern with a copy-paste curl per entry.

Test plan

  • Every demo: ./gradlew build green
  • Every demo: smoke tests assert correct BlockReason for attack URLs
  • All artifacts resolve from Maven Central (ssrf-guard:3.0.0 propagation confirmed)
  • CI matrix builds all 5 demos on this PR

Notes for review

  • io.micrometer:micrometer-core is added explicitly to -feign, -jdkhttp, -okhttp demos. ssrf-guard v3.0.0's auto-config references MeterRegistry by type even when no metrics bean is registered, so consumers without Actuator hit a ClassNotFoundException. Tracked as a v3.0.1 follow-up — once fixed, these declarations can come out.
  • Spring Cloud 2025.0.2 for the feign demo. 2024.0.x doesn't support Spring Boot 3.5.
  • Attack URLs are cross-referenced with JoyChou93/java-sec-code for credibility.

One demo per significant module — every demo is standalone, self-
contained, and runnable with `./gradlew bootRun`. Each comes with:

  - A focused README with curl examples (allowed + blocked paths)
  - Spring Boot integration (so curl works out of the box)
  - Smoke tests proving the guard blocks the canonical attacks
  - Attack-pattern matrix where relevant

Demos:

  ssrf-guard-demo
    Three Spring HTTP clients (RestClient, RestTemplate, WebClient) wired
    through the same UrlPolicy. /attacks catalogues 15 SSRF bypass patterns
    with pre-built curls — copy-paste any one to see the block decision.
    Includes Micrometer + actuator so /actuator/prometheus shows
    ssrf_guard_blocked_total counters.

  ssrf-guard-springai-demo  ⭐
    The differentiating story for ssrf-guard. A FakeLlmService stands in
    for a real ChatClient (so the demo runs offline, no API key) and
    drives a fetch_url ToolCallback. ssrf-guard-springai's
    BeanPostProcessor auto-wraps the tool — URL-shaped arguments are
    validated before the tool runs, with attacker-controlled URLs
    returning a structured JSON error the LLM can interpret.

  ssrf-guard-feign-demo
    Spring Cloud OpenFeign integration. Two @FeignClient interfaces —
    one whitelisted (httpbin.org), one not (evil.com) — show the
    RequestInterceptor block path. Pinned to Spring Cloud 2025.0.x for
    Spring Boot 3.5 compatibility.

  ssrf-guard-jdkhttp-demo
    java.net.http.HttpClient wrapper — the library has no Spring
    dependency itself, the demo uses Spring Boot only to expose a curl
    endpoint. Three-line wiring in main() shows the non-Spring usage.

  ssrf-guard-okhttp-demo
    OkHttp Interceptor + Dns integration — same non-Spring story.
    Three-line OkHttpClient.Builder configuration.

All demos depend on freshly-published `kr.devslab:ssrf-guard-*:3.0.0`
artifacts from Maven Central. CI auto-detects them via the existing
top-level matrix workflow.

Notes:

  - The feign / jdkhttp / okhttp demos work around a v3.0.0 autoconfig
    bug by explicitly pulling in `io.micrometer:micrometer-core`. v3.0.1
    will gate the metrics bean by class-presence to remove this
    requirement.
  - Spring Cloud 2024.0.x is NOT compatible with Spring Boot 3.5; the
    feign demo uses 2025.0.2 instead.
@jlc488 jlc488 merged commit 4ec3478 into main May 23, 2026
6 checks passed
@jlc488 jlc488 deleted the ssrf-guard-demos branch May 23, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant