Skip to content

feat: add opt-in Guard Core application layer protection, off by default - #808

Open
rennf93 wants to merge 5 commits into
kekingcn:masterfrom
rennf93:feat/guard-core-security
Open

rennf93 wants to merge 5 commits into
kekingcn:masterfrom
rennf93:feat/guard-core-security

Conversation

@rennf93

@rennf93 rennf93 commented Oct 17, 2026

Copy link
Copy Markdown

This adds optional application-layer protection with spring-boot-guard 1.3.0 (MIT). It is off by default: with guard.enabled unset or false, no guard bean, filter or property binding exists and nothing changes.

When enabled (KK_GUARD_ENABLED=true) it adds:

  • per-client request budgets on the expensive routes such as /onlinePreview, /getCorsFile, /addTask and /fileUpload
  • attack screening of path, query, headers and form fields, with an automatic ban for clients that keep probing
  • upload limits, and an optional IP allowlist and API key on the state-changing endpoints
  • a passive (log-only) mode to try it first

It is a second layer on the routes from the recent advisories (GHSA-xmfr-w3f5-hmr2, GHSA-mw74-3vmw-q3hg, GHSA-p2q6-8h6g-r47q and others), not a replacement for the code fixes. Every setting and limit is documented in SECURITY_CONFIG.md.

Notes:

  • The jar grows by about 12.4 MB, and Kotlin is on the classpath even when the guard is off.
  • /fileUpload keeps body scanning off, so the html, sql and shell files kkFileView previews are not refused.
  • 54 new tests. mvn -B -pl server test shows the same 2 failures as master on macOS arm64 (a missing test resource and the SevenZipJBinding native library).

Disclosure: I maintain spring-boot-guard and guard-core.

Guard Core (spring-boot-guard 1.2.0) adds per-client request budgets, attack
screening with auto-ban, upload limits, access control on the state-changing
endpoints and behavior rules. It is off unless guard.enabled=true: the
auto-configuration is filtered out before it is imported, so nothing is
registered and behavior is unchanged by default.

The Kotlin and coroutines BOMs are imported before the Spring Boot BOM because
Spring Boot 3.5 manages Kotlin 1.9 and coroutines 1.8, while the guard needs
Kotlin 2 and coroutines 1.11.
Runs the real application with the guard off and on: no component registered
and unchanged responses by default; budgets give 429; traversal, XSS and
scanner probes are rejected and repeated probing is banned; upload content
type and size; admin allowlist and key; intranet previews are not blocked; a
spoofed X-Forwarded-For does not reset a budget; large downloads stream.
… property

Bump spring-boot-guard to 1.3.0 and drop GuardAutoConfigurationGate and its spring.factories entry: the library now honors guard.enabled itself. Its default is true, so ServerMain repeats guard.enabled=false as the lowest-precedence default, which keeps the guard off for operators whose own application.properties copy predates it.
…ning

spring-boot-guard 1.3.0 keeps the multipart parts, but it scans file part payloads along with form fields, and kkFileView stores and previews html, sql and shell sources. Keep scanBody=false on /fileUpload, say why, and test that an upload is stored intact and a script-bearing html file is not refused.
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