Skip to content

Add default configurable Grails security response headers - #15967

Merged
jdaugherty merged 14 commits into
8.0.xfrom
feat/default-security-headers
Sep 24, 2026
Merged

jdaugherty merged 14 commits into
8.0.xfrom
feat/default-security-headers

Conversation

@jamesfredley

@jamesfredley jamesfredley commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Grails servlet applications did not send common browser-hardening response headers by default. This adds a filter that sends a baseline set on every response, with per-header opt-out and overrides.

Behaviour

Area Behaviour
Defaults X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy: strict-origin-when-cross-origin, X-XSS-Protection: 0
HSTS Off by default. When enabled, sent on secure requests, including behind a TLS-terminating proxy that forwards the scheme in Forwarded, X-Forwarded-Proto or X-Forwarded-Ssl (read the way Spring's ForwardedHeaderFilter reads them)
CSP Off by default; enabled and set through configuration
Precedence Headers are written when the response commits, and only if still absent, so a controller, interceptor, filter or Spring Security header writer inside the Grails filter wins
Commit paths sendRedirect, sendError, flushBuffer, writer and stream flush/close, a declared Content-Length being reached (including through println), and the response buffer filling (writer output counted in encoded bytes). A reset() re-arms the headers for the replacement response
Ordering Registered at GrailsFilters.FIRST, the outermost Grails filter, so responses that other Grails filters serve without continuing the chain (asset-pipeline assets) are covered too
Reverse proxies grails.security.headers.defaults: always (default); auto withholds the built-in defaults on requests detected as proxied (forwarded request headers, server.forward-headers-strategy, or an active cloud platform) while still sending explicitly configured headers; never sends only explicitly configured headers
Configuration grails.security.headers.enabled, grails.security.headers.defaults, and enabled/value for each header
Back-off The auto-configuration backs off for an application-defined GrailsSecurityHeadersFilter bean, a bean named grailsSecurityHeadersFilter, or a FilterRegistrationBean<GrailsSecurityHeadersFilter>

The filter stays active when Spring Security is on the classpath. The Grails Spring Security plugin does not register a HeaderWriterFilter, so these are the only security headers its users get by default.

Tests

  • GrailsSecurityHeadersAutoConfigurationSpec: auto-configuration and back-off conditions, defaults and overrides, every commit path, Spring Security's HeaderWriterFilter on both sides of the filter, forwarded-scheme HSTS, and the defaults modes.
  • GrailsSecurityHeadersFilterTomcatSpec: runs the filter on embedded Tomcat, because the Spring mocks accept header writes after the response has committed. Covers buffer-full commits (output stream, writer, and multi-byte writer output), Content-Length reached through println, redirects, sendError, reset, and a filter that serves the response without continuing the chain.

Documentation

  • Security guide: new HTTP Security Headers section covering defaults, configuration, ordering relative to Spring Security, HSTS behind a proxy, and the defaults modes.
  • Upgrade guide: section 73, Default Security Response Headers.
  • What's New entry.

Out of scope

  • CSP policy templates
  • Permissions-Policy defaults

Contributor Checklist

Issue and Scope

  • Background explains the security-headers gap.
  • Scoped to default response headers only.
  • Single focused feature seed.
  • Targets 8.0.x.

Code Quality

  • Tests cover enable/disable and defaults.
  • Focused controllers tests intended for CI.
  • No mass reformatting.
  • AI starting point labeled.

Licensing and Attribution

  • Apache License 2.0.
  • Contributor rights confirmed.
  • ai-generated-starting-point label applied.

Documentation

  • User-facing docs updated.
  • PR description explains what changed and why.

Assisted-by: Sisyphus:xai/grok-4.5 [gpt-coding]

Register a OncePerRequestFilter for X-Content-Type-Options,
X-Frame-Options, Referrer-Policy, optional HSTS on secure requests,
and optional CSP. Configurable via grails.security.headers.* with
opt-out and ConditionalOnMissingBean.

Assisted-by: Sisyphus:xai/grok-4.5 [gpt-coding]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a default, configurable servlet filter in grails-controllers that applies baseline browser-hardening response headers for Grails 8 servlet web applications, along with auto-configuration, configuration metadata, tests, and documentation updates in the user guide and upgrade notes.

Changes:

  • Added GrailsSecurityHeadersFilter plus GrailsSecurityHeadersProperties and a servlet-only Boot auto-configuration to register it by default (with opt-out via grails.security.headers.*).
  • Added configuration metadata for IDE/property hinting and documented the defaults + customization in the Security guide and Grails 8 upgrade notes.
  • Added a Spock spec verifying auto-config behavior, default headers, per-header disablement, overrides, and secure-request HSTS behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
grails-doc/src/en/guide/upgrading/upgrading80x.adoc Adds Grails 8 upgrade note about the new default security headers filter and how to disable/configure it.
grails-doc/src/en/guide/security.adoc Documents default headers, rationale for HSTS/CSP being opt-in, and example application.yml configuration.
grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/GrailsSecurityHeadersAutoConfigurationSpec.groovy Adds test coverage for auto-configuration and header application behavior.
grails-controllers/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports Registers the new auto-configuration class for Spring Boot discovery.
grails-controllers/src/main/resources/META-INF/additional-spring-configuration-metadata.json Adds Spring configuration metadata entries for grails.security.headers.* properties.
grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/GrailsSecurityHeadersProperties.java Introduces bindable configuration properties and defaults for each supported header.
grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/GrailsSecurityHeadersFilter.java Implements the OncePerRequestFilter that applies headers conditionally based on configuration and existing response headers.
grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/GrailsSecurityHeadersAutoConfiguration.java Adds servlet-only auto-config with conditional registration and a FilterRegistrationBean for ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bito-code-review

Copy link
Copy Markdown

The proposed change to move header application into a finally block is technically sound for ensuring that downstream components have the first opportunity to set headers. By applying defaults only if the headers are missing after the filter chain completes, you prevent the filter from prematurely setting values that might conflict with or override specific requirements set by controllers or other filters. This approach effectively balances providing sensible defaults with allowing granular overrides.

grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/GrailsSecurityHeadersFilter.java

@Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
            throws ServletException, IOException {
        try {
            filterChain.doFilter(request, response);
        } finally {
            applyHeader(response, "X-Content-Type-Options", properties.getContentTypeOptions());
            // ... apply other headers
        }
    }

@codecov

codecov Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.6152%. Comparing base (7ea4cb9) to head (63aaf3d).
⚠️ Report is 38 commits behind head on 8.0.x.

Files with missing lines Patch % Lines
...eb/controllers/SecurityHeadersResponseWrapper.java 84.3750% 18 Missing and 7 partials ⚠️
...b/controllers/GrailsSecurityHeadersProperties.java 84.6154% 8 Missing ⚠️
...s/web/controllers/GrailsSecurityHeadersFilter.java 95.4546% 1 Missing and 2 partials ⚠️
...ollers/GrailsSecurityHeadersAutoConfiguration.java 92.3077% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #15967        +/-   ##
==================================================
+ Coverage     57.4441%   57.6152%   +0.1710%     
- Complexity      22558      22700       +142     
==================================================
  Files            2129       2133         +4     
  Lines          103840     104226       +386     
  Branches        18646      18692        +46     
==================================================
+ Hits            59650      60050       +400     
+ Misses          35929      35888        -41     
- Partials         8261       8288        +27     
Files with missing lines Coverage Δ
...ollers/GrailsSecurityHeadersAutoConfiguration.java 92.3077% <92.3077%> (ø)
...s/web/controllers/GrailsSecurityHeadersFilter.java 95.4546% <95.4546%> (ø)
...b/controllers/GrailsSecurityHeadersProperties.java 84.6154% <84.6154%> (ø)
...eb/controllers/SecurityHeadersResponseWrapper.java 84.3750% <84.3750%> (ø)

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The Copilot suggestion to apply the headers in a post-chain finally
block would skip every security header on responses that commit during
the chain (sendRedirect, sendError, flushBuffer, streaming), which is
exactly where the headers are needed. Keep applying the headers eagerly
before the filter chain (values already present still win, explicit
downstream setHeader still replaces) and add a regression test proving
the headers are present on a redirect-committed response.

Assisted-by: Sisyphus:openai/gpt-5.6-terra [gpt-coding]
OncePerRequestFilter.shouldNotFilterErrorDispatch() defaults to true, so
the filter was skipped on ERROR redispatches even though the ERROR
dispatcher type is registered, leaving error responses without the
security headers. Override it to return false and cover the behavior
with a DispatcherType.ERROR test.

Assisted-by: Sisyphus:openai/gpt-5.6-terra [gpt-coding]
@jamesfredley

Copy link
Copy Markdown
Contributor Author

Review feedback addressed

Merged the latest 8.0.x and pushed follow-up commits.

Copilot review comment - apply headers in a finally block after the chain: evaluated and intentionally not adopted, because for security headers it regresses committed responses. If a downstream sendRedirect / sendError / flushBuffer / streaming write commits the response during the chain, isCommitted() is already true on return and a post-chain block would skip all hardening headers on exactly the redirect/error/streaming responses that need them. Instead the filter keeps applying the defaults eagerly before the chain with a containsHeader gap-fill (so a value set earlier wins, and an explicit downstream setHeader still replaces it), and I added:

  • a regression test that a redirect-committed response still carries the default headers, and
  • an override of shouldNotFilterErrorDispatch() to false plus a DispatcherType.ERROR test, so container ERROR redispatches (which reset the response) also get the headers.

Follow-up (documented, not changed here): when the optional Spring Security plugin is installed, its header writers skip headers already present, so eagerly-set Grails defaults can win over a Spring-Security-configured policy. The robust fix is an on-commit response wrapper that fills only-missing headers after downstream writers run; that is a larger change and Spring Security is an optional plugin, so I left it as a follow-up rather than expand this starter filter's scope.

Local verification: :grails-controllers:test --tests GrailsSecurityHeadersAutoConfigurationSpec (9 features) passes.

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look at this with reverse-proxy deployments (nginx/haproxy) in mind, since that's how most production Grails apps run. A few concerns inline — the common thread is that the containsHeader guard only protects against headers set inside the servlet container, but in real deployments these headers are frequently owned by the edge proxy or by Spring Security, and in both cases the current behavior is surprising.

@jdaugherty

Copy link
Copy Markdown
Contributor

The reverse proxy scenarios are real regressions that need addressed.

@jamesfredley jamesfredley moved this to Todo in Apache Grails Jul 24, 2026
… gaps

Addresses jdaugherty's 3 unresolved review findings, all confirmed
against the current code before fixing:

- Spring Security precedence (verified inverted doc claim): this filter
  registers at GrailsFilters.LAST (order -110), before Spring Security's
  chain (-100), and applied its defaults eagerly - so Spring Security's
  header writers (which skip a header that's already present) never got
  a chance to win, contrary to what the upgrade notes claimed. Fixed by
  adding @ConditionalOnMissingClass("...HeaderWriterFilter") to
  GrailsSecurityHeadersAutoConfiguration so the whole auto-configuration
  backs off when Spring Security's header-writing infrastructure is on
  the classpath, per jdaugherty's suggested option - Spring Security
  already ships its own configurable header defaults. Added a
  spring-security-web test-only dependency and a
  FilteredClassLoader-based helper so the existing "Spring Security
  absent" tests keep exercising that path explicitly, plus a new test
  confirming the back-off.
- HSTS silently never sent behind a TLS-terminating reverse proxy
  (request.isSecure() is false unless server.forward-headers-strategy
  is configured): this isn't a code bug - request.isSecure() is the
  correct check, and Spring Boot's forward-headers-strategy is the
  standard way to make it proxy-aware - so documented the proxy case
  and the mitigation in the security guide instead of changing behavior.
- Reverse-proxy header duplication (nginx add_header appends rather than
  replaces, so the client can receive a header twice once the app also
  sends it): also not something a code change here can generally detect
  or fix, since the proxy operates entirely outside the request
  pipeline. Documented the risk (with the concrete Chrome/CSP/
  Referrer-Policy duplicate-header failure modes jdaugherty identified)
  and the mitigation (disable the affected header(s) at the app and let
  the proxy own them, or strip the app's copy at the proxy).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@borinquenkid borinquenkid added this to the grails:8.0.0-RC1 milestone Jul 27, 2026

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the latest push. The three reverse-proxy / Spring Security findings from the previous round are still open: two of them were addressed with documentation only, and the one code change (backing off on HeaderWriterFilter class presence) removes headers from the largest group of users this feature is meant to protect. Details inline. The short version of what I think the fix needs to be:

  1. Write the headers at commit time via a response wrapper (the same pattern Spring Security's HeaderWriterFilter uses) instead of eagerly before the chain, and drop the @ConditionalOnMissingClass back-off. That lets any later writer win and still covers redirects, sendError, and streaming responses.
  2. Make HSTS forwarded-proto aware when request.isSecure() is false.
  3. Detect that a request arrived through a reverse proxy and, by default, apply only explicitly configured headers in that case, so proxy-managed deployments do not double-send on upgrade.

Documentation alone is not a fix for on-by-default behavior that changes what existing deployments send to browsers.

@jdaugherty

Copy link
Copy Markdown
Contributor

I'm going to make pass at fixing this PR

Backing the auto-configuration off whenever Spring Security's
HeaderWriterFilter was on the classpath removed the default headers for
every Grails Spring Security user: the plugin never registers a header
writer (it only reserves SecurityFilterPosition.HEADERS_FILTER) yet
exposes spring-security-web as an api dependency, so those applications
ended up with no security headers from either side. The condition also
sat on the whole auto-configuration, so explicitly configured values
were silently ignored in the same situation.

Replace the eager, before-chain header writes with a response wrapper
that fills still-missing headers immediately before the response
commits (redirect, error, buffer flush, writer or stream flush/close,
declared Content-Length reached) or when the chain returns. Anything
set downstream - a controller, an interceptor, another filter, or
Spring Security's writers - now wins regardless of filter order, so the
classpath back-off is removed.

Honor the forwarded scheme for HSTS when the container saw plain HTTP
behind a TLS-terminating proxy: X-Forwarded-Proto and the RFC 7239
Forwarded proto parameter are consulted as a fallback. This is safe
without a trust configuration because user agents ignore
Strict-Transport-Security received over a non-secure transport
(RFC 6797 section 8.1).

Detect requests relayed through a reverse proxy and, by default, send
only explicitly configured headers for them so proxy-managed
deployments do not start double-sending headers on upgrade (nginx
add_header appends rather than replaces). Detection uses the Forwarded,
X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host, Via and X-Real-IP
request headers, a configured server.forward-headers-strategy (the
forwarding filter or valve strips those request headers before this
filter sees them), or an active Spring Boot CloudPlatform. The new
grails.security.headers.defaults setting (auto, always, never) controls
this; explicitly configured headers are always applied, and a single
INFO log line explains when defaults are withheld.

Tests cover downstream and Spring Security precedence, every commit
path, forwarded-scheme HSTS, each proxy signal, the defaults modes,
configuration binding of explicit headers, and the environment-driven
proxy detection in the auto-configuration. The security guide and 8.0
upgrade notes describe the behavior and the new setting.
@jdaugherty

Copy link
Copy Markdown
Contributor

@jamesfredley I've adjusted this PR so it supports reverse proxies the way Spring does. Can you please take a look so I know if we can merge?

@codeconsole
codeconsole self-requested a review September 24, 2026 02:47

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the commit-time wrapper against a real container (the filter in front of a servlet on embedded Tomcat 11.0.26). Two commit paths still drop the headers, and at its current order the filter never sees asset-pipeline responses. Details inline; the two wrapper suggestions were verified in that run.

Two things outside the diff:

  • grails-doc/src/en/guide/introduction/whatsNew.adoc needs an entry. This changes the headers every servlet app sends by default, so it should appear there as well as in the upgrade notes.
  • The new public classes (GrailsSecurityHeadersFilter, GrailsSecurityHeadersProperties, GrailsSecurityHeadersAutoConfiguration) need @since 8.0 in their class Javadoc, as GrailsHiddenHttpMethodFilterAutoConfiguration has.

…rst, default to always

Running the filter against embedded Tomcat showed two commit paths the
response wrapper missed. With no Content-Length and no explicit flush
the container commits as soon as the body outgrows getBufferSize()
(8 KB by default), so large JSON responses, downloads and any page not
buffered by SiteMesh went out without the headers. And
PrintWriter.println() writes the line separator to the underlying
writer through its private newLine(), bypassing the write overrides,
so a declared Content-Length reached through println was never seen.
The wrapper now fires when the count reaches the buffer size as well
as the declared length, checks a declared length at once in case the
body was written first, counts println's separator, and tracks a
Content-Length declared through setIntHeader/addIntHeader.

Register the filter at GrailsFilters.FIRST instead of LAST. Commit-time
writers nest and the innermost fires first, so only the outermost one
is the gap filler: at LAST (-110) the Grails wrapper wrote SAMEORIGIN
before an XFrameOptionsHeaderWriter placed ahead of it
(spring.security.filter.order below -110) could run, and the
asset-pipeline filter at -190, which streams assets and flushes without
continuing the chain, never reached the filter at all, so /assets/**
carried no nosniff.

Default grails.security.headers.defaults to always. Every load
balancer, ingress and platform router adds X-Forwarded-For, and every
Kubernetes pod is detected as a cloud platform, so with auto the
defaults were sent only to direct requests, which in practice meant
local development. Duplicates of the four default headers are benign
or stricter (nosniff twice is nosniff, conflicting X-Frame-Options
blocks framing, Referrer-Policy resolves to the proxy's appended
token, no browser implements X-XSS-Protection), and CSP, where
duplicates do hurt, is never sent unless configured. auto remains the
opt-in for proxies that own these headers.

Add GrailsSecurityHeadersFilterTomcatSpec, which runs the filter on
embedded Tomcat and asserts the headers on the wire for bodies that
outgrow the buffer through the output stream and the writer, a
Content-Length reached by println, a redirect, sendError, and a
response served by an inner filter that never continues the chain.
The Spring mocks accept header writes after commit, so they cannot
catch these; mock-based tests still cover each commit path, the
registration order, Spring Security ordered ahead of the filter, and
the three defaults modes.

Document the entry in whatsNew, reword the upgrade note and security
guide for the new default and ordering, and add @SInCE 8.0 to the
public classes.
@jdaugherty
jdaugherty requested a review from matrei September 24, 2026 13:32
…cument Spring Security ordering

The response wrapper now re-arms its commit callback on reset() and restarts
its content tracking on resetBuffer(), so a response replaced by an error
handler after the headers were written still receives them. The buffer size
is read once and refreshed only by setBufferSize(), reset() or resetBuffer().

The auto-configuration also backs off when the application declares a
FilterRegistrationBean<GrailsSecurityHeadersFilter> under any bean name, for
both the raw filter bean and the Grails registration, so a user registration
is never duplicated at GrailsFilters.FIRST on /*.

The filter honors grails.security.headers.enabled when constructed directly,
warns once when an enabled header has a blank value, reads the forwarded
scheme through Spring's ForwardedHeaderUtils, and only resolves the scheme
when HSTS is enabled.

The docs and javadoc no longer claim that Spring Security's header writers
win wherever the chain is ordered, or that the filter runs first in the
servlet chain. They describe the default-order behavior, the case where the
Security chain is ordered ahead of GrailsFilters.FIRST, and the Boot filters
that run outside the Grails filter.
@matrei

matrei commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Reviewed at head 5c8fc21206 (base 8.0.x, merge-base 7ea4cb9d8e; merges cleanly into current 8.0.x at a441334507).

What I ran locally:

  • :grails-controllers:cleanTest :grails-controllers:test --no-build-cache: 182 tests, 0 failures (84 in GrailsSecurityHeadersAutoConfigurationSpec, 9 in GrailsSecurityHeadersFilterTomcatSpec).
  • :grails-controllers:codeStyle: clean.
  • Throwaway specs (not committed) that put the filter in front of servlets on the embedded Tomcat from the test classpath, to try commit paths and request shapes the PR's specs don't cover. Results are below.

The commit-time wrapper, the move to GrailsFilters.FIRST and the always default fix the reverse-proxy, Spring Security precedence and asset-pipeline problems raised in the earlier reviews by @jdaugherty and @codeconsole. The latest commit adds re-arming on reset(), the typed-registration back-off and the blank-value warning, which all look right. Three things are left before merge: the switch to ForwardedHeaderUtils turns some requests into 500s when HSTS is enabled, one commit path still drops the headers, and the PR description is stale. The rest are small.

1. With HSTS enabled, URLs Tomcat accepts but java.net.URI rejects now fail with 500

GrailsSecurityHeadersFilter.java:185-191: isSecure now builds a ServletServerHttpRequest and calls getURI() so it can hand the request to ForwardedHeaderUtils. getURI() throws IllegalStateException ("Could not resolve HttpServletRequest as URI") when the request URL isn't a valid java.net.URI, and only IllegalArgumentException is caught. Tomcat lets such paths through when relaxedPathChars is configured (server.tomcat.relaxed-path-chars), which apps set for legacy links containing |, {} or []. I ran it on Tomcat with relaxedPathChars='|{}[]^'andhsts.enabled: true`:

request                                      status   nosniff   HSTS
GET /plain                                   200      sent      -
GET /p|x                                     500      -         -
GET /p{x}                                    500      -         -
GET /plain?a=|b                              200      sent      -     (getURI re-encodes a bad query)
GET /p|x         X-Forwarded-Proto: https    500      -         -
GET /plain       X-Forwarded-Proto: https    200      sent      sent

With HSTS disabled (the default), isSecure isn't called and these requests return 200, so the failure only shows up after someone turns HSTS on. The previous hand-written parser didn't touch the URI. Only the scheme is needed here, so it can be resolved without the request URL at all, for example:

HttpHeaders headers = new ServletServerHttpRequest(request).getHeaders();
String scheme = ForwardedHeaderUtils.adaptFromForwardedHeaders(URI.create("http://localhost"), headers)
        .build().getScheme();

Catching IllegalStateException as well would also stop the 500s, but it would silently skip HSTS on those requests. A spec row with a relaxed path char and HSTS enabled would cover it.

2. Multi-byte text written through the writer can commit before the wrapper fires

SecurityHeadersResponseWrapper.java:229: the writer counts characters, but the buffer it is compared against (getBufferSize()) is in bytes. On Tomcat the default 8 KB char buffer usually hides this. Once the response buffer is larger than that, UTF-8 text with 3-byte characters fills the byte buffer, and commits, at about a third of the character count the wrapper is waiting for:

servlet                                                       nosniff / X-Frame-Options
setBufferSize(32768), 400 × write('日' * 50)   (60 KB)        <missing> / <missing>   (every run, at both heads)
setBufferSize(32768), 400 × write('ж' * 50)    (40 KB)        sent
setBufferSize(32768), 1000 × write('a' * 50)   (50 KB)        sent
default buffer,       400 × write('日' * 50)                  sent (4 of 4 runs)

It also leaked from one request to the next. In my first run, a plain default-buffer /cjk-chunks request lost its headers because it came right after a request on the same keep-alive connection that had called setBufferSize(32768). Tomcat had kept the enlarged buffer on the recycled response. It happened again at 5c8fc21206. So an app doesn't have to call setBufferSize on the affected request itself.

The class Javadoc (SecurityHeadersResponseWrapper.java:43-47) says a multi-byte encoding reaches the buffer "a little before the count does" and that "the callback still runs no later than the chain returning". It does run then, but the response has already committed, so the setHeader calls are dropped without any error. The comment describes this as safe when it isn't.

Spring Security's OnCommittedResponseWrapper makes the same approximation, so this isn't a regression compared with Spring Security. Still, CJK sites are exactly the users who would hit it. Options:

  • Count writer output conservatively as chars * charsetEncoder.maxBytesPerChar() for the response's character encoding. This fires early rather than late. The trade-off is that an inner skip-if-present writer that counts characters (Spring Security's HeaderWriterFilter) may fire after this one on large multi-byte bodies and lose precedence. Given the choice, sending the default is better than sending nothing.
  • At minimum, correct the Javadoc and document the limitation in security.adoc next to the "body large enough to fill the container's response buffer" sentence.

The latest commit caches the buffer size and refreshes it on setBufferSize/reset/resetBuffer, which doesn't change this: the count is still in characters.

Either way, a Tomcat spec case with setBufferSize(32768) and chunked 3-byte characters would pin it down.

3. The PR description no longer matches the code

The squash commit will most likely be built from the description, and it currently says:

  • "Kept eager before-chain application with containsHeader gap-fill" / Copilot finally suggestion "Declined". The filter now writes at commit time.
  • "Spring Security ordering (… needs on-commit wrapper) — Follow-up". That is done in this PR.
  • "GrailsSecurityHeadersAutoConfiguration with @ConditionalOnMissingBean". There is now also a custom condition that backs off on a typed FilterRegistrationBean<GrailsSecurityHeadersFilter>.
  • Nothing about grails.security.headers.defaults (always/auto/never), forwarded-scheme HSTS, GrailsFilters.FIRST, or the Tomcat spec.
  • References to "Google Doc 2.1" and a "Status map", which readers of the public PR can't see.

Please rewrite it to describe the final behaviour before merging.

4. The upgrade note is under the wrong heading

upgrading80x.adoc:500: the note is a paragraph inside "13. Spring Security Filter Ordering". This change alters the response headers of every servlet application, not just Spring Security users, so someone skipping the Spring Security section will miss it. It should be its own numbered section (for example "14. Default Security Response Headers", renumbering the ones after it).

5. The "explicitly configured is always sent" wording is too broad

security.adoc:97: "Any header you configure explicitly (setting either its enabled or its value key) is always sent". That isn't true for:

  • content-security-policy.value or hsts.value set on its own. Both keep enabled: false, so nothing is sent.
  • <header>.enabled: false, which also counts as explicit.

Suggest wording along the lines of "Explicitly configured headers are not affected by defaults: a header you have enabled and given a value is sent whether or not a proxy is detected." It would also help to say directly that CSP and HSTS need enabled: true as well as a value. (The latest commit's blank-value warning covers the enabled: true without a value case, and the new sentence in security.adoc explains it. The "always sent" sentence itself is unchanged.)

6. Minor

  • The new ordering paragraph says Spring Boot's "character-encoding" filter runs outside the Grails filter (security.adoc:65, upgrading80x.adoc:503, GrailsSecurityHeadersAutoConfiguration.java:61). In a Grails app it doesn't: ControllersAutoConfiguration registers its own CharacterEncodingFilter at GrailsFilters.CHARACTER_ENCODING_FILTER (-180), which is inside FIRST, and Boot's HttpEncodingAutoConfiguration backs off. Boot's ErrorPageFilter is only registered for WAR deployments, which is worth saying too. Only the forwarded-header filter is outside in a default Grails app.

  • GrailsSecurityHeadersFilter.java:71: REVERSE_PROXY_REQUEST_HEADERS is public static final, which adds to the public API a list that only the filter and the spec's where: block use. Package-private would do, and it avoids having to keep the list stable.

  • GrailsSecurityHeadersFilterTomcatSpec.groovy:72,75: the two temp directories are never deleted. Spock's @TempDir on a @Shared field would clean them up.

  • Optional: GrailsSecurityHeadersFilterTomcatSpec could implement HttpClientSupport from grails-testing-support-http-client instead of its own get() helper and firstValue(...).present checks. assertHeaders(..., status) would then check all four default values and the status in one call; today only two of the four values are checked. This needs testImplementation project(':grails-testing-support-http-client'), which doesn't create a cycle (grails-gsp already uses the testing-support modules in its tests). There's no Spring context to inject local.server.port, so the spec overrides getHttpBaseUrl(). The shared client follows redirects, so the /redirect row needs a client that doesn't, passed through http(path, client). I tried this locally on the previous head (37b983c60c): all 8 features pass and codeStyle is clean. The /reset row added since then carries over with the same referrerPolicy default. The unused DEFAULT_HEADER_NAMES and the get() helper go away, and the java.net.http.HttpRequest/HttpResponse imports are no longer needed:

    class GrailsSecurityHeadersFilterTomcatSpec extends Specification implements HttpClientSupport {
    
        @Shared
        HttpClient noRedirects = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NEVER).build()
    
        @Override
        String getHttpBaseUrl() {
            "http://localhost:${port}"
        }
    
        @Unroll
        void 'headers are on the wire for #path (#description)'() {
            when:
            def response = http(path, noRedirects)
    
            then:
            response.assertHeaders([
                    'X-Content-Type-Options': 'nosniff',
                    'X-Frame-Options'       : 'SAMEORIGIN',
                    'Referrer-Policy'       : referrerPolicy,
                    'X-XSS-Protection'      : '0'
            ], status)
            bodyLength == null || response.body().length() == bodyLength
    
            where:
            path            | description                                                | status | bodyLength                | referrerPolicy
            '/small-stream' | 'body below the response buffer'                           | 200    | 100                       | 'strict-origin-when-cross-origin'
            '/large-stream' | 'output stream body outgrowing the buffer, no flush'       | 200    | 50 * 1024                 | 'strict-origin-when-cross-origin'
            '/large-writer' | 'writer body outgrowing the buffer, no flush'              | 200    | 50 * 1024                 | 'strict-origin-when-cross-origin'
            '/println'      | 'Content-Length reached by println'                        | 200    | 2 + LINE_SEPARATOR_LENGTH | 'no-referrer'
            '/redirect'     | 'redirect committed inside the chain'                      | 302    | null                      | 'strict-origin-when-cross-origin'
            '/error'        | 'sendError committed inside the chain'                     | 404    | null                      | 'strict-origin-when-cross-origin'
            '/reset'        | 'reset after the buffer filled but before it flushed'      | 500    | 5                         | 'strict-origin-when-cross-origin'
            '/assets/a.js'  | 'served by an inner filter that never continues the chain' | 200    | 14                        | 'strict-origin-when-cross-origin'
        }
    
        void 'a header set by the servlet wins over the Grails default'() {
            expect:
            http('/println').hasHeaderValue('Referrer-Policy', 'no-referrer')
        }

    The referrerPolicy column is needed because the exact-value check catches something the current present check misses: the /println servlet sets Referrer-Policy: no-referrer itself, so that row can't expect the default. body() returns a String, so its length only equals the byte count for ASCII bodies. A multi-byte case for item 2 would need to compare byte length.

Verified as correct

  • Commit-time writing: the wrapper intercepts sendError/sendRedirect (all four overloads), flushBuffer, writer and stream flush/close, declared Content-Length (including via setHeader/addHeader/setIntHeader/addIntHeader and when declared after the body), buffer-full, and the println line separator. The Tomcat spec shows each of these on the wire.
  • The Servlet 6.1 ServletOutputStream.write(ByteBuffer) default goes through the wrapper's write(byte[]), so it is counted. Checked on Tomcat for a 100 B and a 50 KB ByteBuffer: headers sent in both cases.
  • println is not double-counted. PrintWriter.print/append/format all funnel through the overridden write methods, and only newLine() bypasses them.
  • Ordering: at FIRST (-200) the filter is outside the asset-pipeline filter (-190), the character encoding filter, SiteMesh, and Spring Security at its default -100. Innermost-first firing means every one of them wins over the Grails defaults, and the spec covers Spring Security's HeaderWriterFilter on both sides.
  • The @ConditionalOnMissingClass back-off is gone. With spring-security-web on the classpath the filter stays active, which fixes the problem that the Grails Spring Security plugin never registers a HeaderWriterFilter.
  • HSTS behind a TLS-terminating proxy: apart from item 1, reading the scheme through ForwardedHeaderUtils matches ForwardedHeaderFilter (first Forwarded element, X-Forwarded-Proto, X-Forwarded-Ssl). A forwarded host with a space doesn't break it, and the scheme is only resolved when HSTS is enabled. ForwardedHeaderFilter and RemoteIpValve run earlier, so they compose with it.
  • The new Spring Security ordering docs are right about X-Frame-Options: in spring-security-web 7.1.1, XFrameOptionsHeaderWriter in DENY/SAMEORIGIN mode calls setHeader unconditionally, while the Referrer-Policy, HSTS and static writers (including X-Content-Type-Options) skip a header that is already present.
  • reset() re-arms the callback and resetBuffer() restarts the count, and the Tomcat /reset row shows the replacement response gets the headers. super.reset() throws on a committed response before any state is cleared.
  • The custom OnMissingSecurityHeadersFilterRegistration condition matches only on the declared generic type without eager init, and the specs cover another name, a registration that builds the filter itself, and registrations for other filters.
  • defaults: always is the default, and auto/never behave as documented, including the config-level signals (server.forward-headers-strategy, active CloudPlatform) and the log line emitted once.
  • explicit tracking works through Boot binding: nested Header instances are bound in place through the getters, so only keys that are actually set flip the flag.
  • ERROR dispatches are filtered (shouldNotFilterErrorDispatch() == false). Spring Boot always registers an error page, so an exception that resets the response still gets headers on the error dispatch.
  • The whatsNew.adoc entry and @since 8.0 on the three public classes that @codeconsole asked for are in. There are no @author tags, Apache headers are present, and the Spring Security and Tomcat test dependencies are test-only and BOM-managed.
  • CI was still running at the time of review (24 passed, 50 pending). The one failure, "Update Release Draft", is the release-drafter job and doesn't run the PR's code.

… the request URL

The response wrapper compared writer output, counted in characters, against
the container's buffer and Content-Length, which are both in bytes. Three-byte
UTF-8 text therefore filled and committed an enlarged buffer before the
callback fired, and the headers were dropped. Tomcat keeps an enlarged buffer
on the recycled processor, so later requests were affected even on new
connections. Writer output is now counted as its encoded length: exactly for
UTF-8 and single-byte encodings, and at the encoding's maximum bytes per
character otherwise.

HSTS resolved the forwarded scheme through ServletServerHttpRequest.getURI(),
which throws for request paths that java.net.URI rejects but Tomcat accepts
through relaxedPathChars, turning those requests into 500s. The forwarded
headers are now applied to the request's scheme alone.

The upgrade note moves to its own section, the explicit-configuration wording
in the security guide matches the behavior, and the docs no longer place the
Grails character-encoding filter outside the security headers filter.
REVERSE_PROXY_REQUEST_HEADERS is no longer public API. The Tomcat spec checks
every default header value, covers multi-byte writer output, and uses @tempdir.
@jdaugherty
jdaugherty dismissed stale reviews from themself September 24, 2026 14:49

Addressed: headers are written at commit time from GrailsFilters.FIRST, so Spring Security header writers at the default filter order win; HSTS honors the forwarded scheme behind a TLS-terminating proxy; and grails.security.headers.defaults (auto/never) covers proxy-managed deployments.

@jdaugherty

Copy link
Copy Markdown
Contributor

@matrei thanks, both behaviour findings reproduced on embedded Tomcat and are fixed in 8da7b05.

  1. isSecure no longer touches the request URL. It applies the forwarded headers to the request's scheme alone, so /p|x with relaxedPathChars and HSTS enabled returns 200 with HSTS (when forwarded as https) instead of 500. Added a spec over |, {}, [], ^ and ` paths, plus one pinning that a container scheme of https still counts when isSecure() is false.
  2. Writer output is now counted in encoded bytes: exactly for UTF-8 and single-byte encodings, and at maxBytesPerChar for any other. The Tomcat spec has a setBufferSize(32768) + 400 × '日' * 50 row, and unit specs cover 2-, 3- and 4-byte UTF-8 through write(String), write(char[]) and write(int), Shift_JIS, and a multi-byte body reaching Content-Length. The enlarged buffer also carried over to a request on a new connection in my run, not only the same keep-alive one, since Tomcat recycles the processor along with its buffer. Byte counting covers that too, because the wrapper reads the real buffer size. The Javadoc now describes the trade-off you pointed out: for a large multi-byte body, Grails can fire before Spring Security's character-counting wrapper. The Spring Security ordering section of security.adoc says so as well.
  3. The PR description still needs rewriting; that is not part of this push.
  4. The upgrade note is now its own section, 73 (appended rather than renumbered, because the guide cross-references sections by number, e.g. "section 53").
  5. Reworded: defaults doesn't apply to explicitly configured headers; an explicit header is sent if it is enabled and has a value; enabled: false is never sent; CSP and HSTS need enabled: true as well as a value.
  6. Character-encoding claim corrected in all three places (Grails' own filter at -180 runs inside; only the forwarded-header filter, and ErrorPageFilter in a WAR, are outside). REVERSE_PROXY_REQUEST_HEADERS is package-private and the spec lists the headers literally. The Tomcat spec uses @TempDir and now checks the exact value of all four headers, with a referrerPolicy column for the /println row. I kept its own client rather than HttpClientSupport for now, because the new multi-byte row compares the raw byte length.

@matrei

matrei commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Re-reviewed at head 8da7b05c58 (base 8.0.x, merge-base 7ea4cb9d8e; merges cleanly into current 8.0.x at a441334507). This round only looks at what changed since 5c8fc21206.

What I ran locally:

  • :grails-controllers:cleanTest :grails-controllers:test --no-build-cache: 199 tests, 0 failures (100 in GrailsSecurityHeadersAutoConfigurationSpec, 10 in GrailsSecurityHeadersFilterTomcatSpec).
  • :grails-controllers:codeStyle: clean.
  • My throwaway Tomcat specs from the last round, re-run at the new head with more cases added (results below).

Everything from the last round is addressed, and I have nothing blocking. Both behaviour problems are fixed on the wire. The PR description now matches the code. One optional nit is below.

Re-run of the previous findings

Relaxed path chars (relaxedPathChars='|{}[]^') with hsts.enabled: true`:

request                                                  status   nosniff   HSTS
GET /p|x                                                 200      sent      -       (was 500)
GET /p{x}                                                200      sent      -       (was 500)
GET /p|x      X-Forwarded-Proto: https                   200      sent      sent    (was 500)
GET /p|x      X-Forwarded-Proto: http                    200      sent      -
GET /plain    X-Forwarded-Host: [::1, Proto: https       200      sent      -       (malformed host: IAE caught, HSTS skipped)
GET /plain    X-Forwarded-Port: abc, Proto: https        200      sent      -
GET /plain    X-Forwarded-Proto: https:x / "ht tps"      200      sent      -
GET /plain    Content-Type: text/plain;charset=bogus     200      sent      sent

Writer output with setBufferSize(32768), every row showing nosniff / X-Frame-Options on the wire (all were checked at least once; the two CJK rows twice each, interleaved so the enlarged buffer is recycled into a default-buffer request):

400 × write('日' * 50)               UTF-8        60 000 B    sent   (was <missing>)
400 × write('日' * 50), default buf  UTF-8        60 000 B    sent   (was <missing> after a 32 KB request)
400 × write('ж' * 50)                UTF-8        40 000 B    sent
400 × write('😀' * 25)               UTF-8        40 000 B    sent   (surrogate pairs)
20000 × write((int) '日')            UTF-8        60 000 B    sent
400 × printf('%s', '日' * 50)        UTF-8        60 000 B    sent
400 × write('日' * 50)               Shift_JIS    40 000 B    sent
400 × write('日' * 50)               UTF-16       40 002 B    sent
1000 × write('é' * 50)               ISO-8859-1   50 000 B    sent

Nit (optional)

GrailsSecurityHeadersFilter.java:196-197: the catch comment says "A forwarded port that is not a number", but it also catches ForwardedHeaderUtils rejecting a malformed forwarded host ("Invalid IPv4 address", the [::1 row above) and URI.create rejecting the scheme. "Malformed forwarded headers: no trustworthy scheme to go on" would cover all three.

Verified as correct

  • isSecure builds the base URI from request.getScheme() alone, so the request path and query never reach java.net.URI. URI.create is inside the try, and a container scheme of https on a connection that isn't marked secure still counts. This is covered by the new spec.
  • Writer byte counting: utf8Length counts 1, 2 or 3 bytes, and 2 for each half of a surrogate pair, so 4 for the pair. Any other encoding counts ceil(maxBytesPerChar) per character, which can only over-count, so the callback fires early rather than late. The charset is read after super.getWriter(), once the servlet API has locked the encoding. An unknown or decode-only charset falls back to UTF-8, and the container fails that writer anyway. Once the callback has fired, the counting loop is skipped. CharBuffer.wrap(buf) with off as an absolute index is right. print, append, printf/format and println all go through the counted methods, and the printf and write(int) rows confirm it on Tomcat.
  • The new Tomcat /multi-byte-writer row fails at 5c8fc21206 (headers missing in every run last round) and passes now, so it pins the fix.
  • The Spring Security ordering paragraph in security.adoc describes the trade-off accurately. At Tomcat's default buffer, UTF-8 text from about 8 KB of encoded bytes now gets the Grails defaults before Spring Security's character-counting wrapper fires. With Spring Security's default headers this changes nothing: X-Frame-Options is written unconditionally, the nosniff and X-XSS-Protection: 0 values are the same, and Grails HSTS is off by default. Only a non-default Spring Security value for a skip-if-present header (for example Referrer-Policy) is affected, and the paragraph says how to hand that header over.
  • The docs changes: the character-encoding claim is corrected in all three places. The "explicitly configured" wording now matches the explicit/enabled/value logic, including enabled: false and the CSP/HSTS enabled: true requirement. Appending the upgrade note as section 73 instead of renumbering is reasonable, given the numbered cross-references such as "section 53".
  • REVERSE_PROXY_REQUEST_HEADERS is package-private. The Tomcat spec cleans up with @Shared @TempDir and now checks the exact values of all four headers. Keeping its own client instead of HttpClientSupport makes sense, because the new multi-byte row compares the raw byte length.
  • CI was still running at the time of review (5 passed, 66 pending, 0 failed).

@jdaugherty

Copy link
Copy Markdown
Contributor

Once @codeconsole approves, we can merge this.

@codeconsole codeconsole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-ran my Tomcat probes at 8da7b05c58. Everything I raised is fixed on the wire:

case                                                   ee6be46      8da7b05
50 KB body, OutputStream, no Content-Length            <missing>    sent
50 KB body, getWriter(), no Content-Length             <missing>    sent
setContentLength(3) + println('hi')                    <missing>    sent
direct request, KUBERNETES_SERVICE_HOST/PORT set       <missing>    sent
request with X-Forwarded-For                           <missing>    sent

I also read through the byte counting, the reset() re-arming, the typed-registration condition and the ForwardedHeaderUtils scheme resolution, and found nothing blocking. Two optional nits inline.

The one failing check, the Groovy snapshot canary, failed to download Gradle 8.14.4 (HTTP 500 from GitHub) and doesn't run this PR's code.

…warded header catch

The response wrapper now hands back the same writer and output stream on
every call, as the container does, instead of building a new wrapper (and
resolving the charset again) each time. reset() drops the cached writer,
since the character encoding can change after a reset.

The HSTS scheme resolution catch covers any malformed forwarded header,
not only a non-numeric port; the comment and the test now say so.
@testlens-app

testlens-app Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🚨 All tests passed but jobs failed 🚨

Failed Jobs without Test Failures

❌ CI / Build Grails-Core (Windows JDK 25 shard 1)

🏷️ Commit: 63aaf3d
▶️ Tests: 557 executed
🟡 Checks: 14/82 completed

Rerun Controls

Click the checkbox to trigger a rerun:

🔲 Rerun jobs


Learn more about TestLens at testlens.app/docs.

@jdaugherty
jdaugherty merged commit 4f1a5c8 into 8.0.x Sep 24, 2026
81 of 82 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Apache Grails Sep 24, 2026
@jdaugherty
jdaugherty deleted the feat/default-security-headers branch September 24, 2026 20:09
antobinary added a commit to antobinary/bigbluebutton that referenced this pull request Oct 2, 2026
Apache Grails tagged 8.0.0-RC2 on 2026-09-29. RC1 has since been
promoted to Maven Central, but RC2 is again in the ASF staging group
only while its release vote runs, so the TEMP staging-repository entries
in build.gradle stay and their comments are retargeted at RC2. RC2's BOM
keeps Spring Boot 4.1.1 and Groovy 5.1.3; the cloud.wondrify
asset-pipeline plugin follows the BOM to 5.2.0-RC3 (on Maven Central).

RC2 itself is built on Gradle 9.8.0, the current release, so the wrapper
moves from 9.7.1 to 9.8.0 to stay on the combination Grails tests. This
is alignment rather than a requirement: RC2 still assembles on 9.7.1.

.gitlab-ci.yml moves to bbb-build:grails-8--2026-10-02-140644, rebuilt
today with the Grails 8.0.0-RC2 CLI. It also picks up the toolchain the
current v4.0.x-release image has (Go 1.27.0, Node 22.23.2), which the
previous grails-8 image predated.

Behavior change that comes with RC2 (apache/grails-core#15967): Grails
now sends browser-hardening headers on every response by default, so
every bbb-web response gains
  X-Content-Type-Options: nosniff
  X-Frame-Options: SAMEORIGIN
  Referrer-Policy: strict-origin-when-cross-origin
  X-XSS-Protection: 0
The defaults are left in place. Joining through a cross-origin iframe
keeps working: the join call answers with a redirect, and the framed
document is the client served by nginx, which carries no such header.
What changes is that a document rendered by bbb-web itself (for example
the XML of /bigbluebutton/api) is no longer displayed inside a
cross-origin frame. A deployment that needs that can opt out per header
in /etc/bigbluebutton/bbb-web.properties, e.g.
grails.security.headers.frame-options.enabled=false.

Checked, nothing to do: the RC2 JSON date/time rendering change
(apache/grails-core#16411) concerns grails.converters.JSON and JSON
views, while bbb-web builds its JSON with groovy.json.JsonBuilder and
ships no gson views; the link-resolution change
(apache/grails-core#16272) has nothing to act on, bbb-web's only
generated link is one redirect(action:).

Verified together with the Tomcat pin in the next commit.
antobinary added a commit to antobinary/bigbluebutton that referenced this pull request Oct 8, 2026
Add bbbWebSecurityHeaders (@ci). It requests three kinds of bbb-web
response - a document (GET /api), the join redirect, and an error (404
for an unmapped URL) - and expects each to carry
  X-Frame-Options: SAMEORIGIN
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  X-XSS-Protection: 0

Since 8.0.0-RC2 Grails adds these browser-hardening headers to every
response by default (apache/grails-core#15967); bbb-web on Grails 7 sent
none of them. We keep the Grails defaults, and this test pins that
decision: a later change in Grails, in bbb-web's packaged configuration
or a site opt-out leaking into the defaults shows up in CI instead of
going unnoticed.

On a 4.0.0-rc.5 server the test fails against the stock Grails 7 bbb-web
(no headers) and against this branch with
grails.security.headers.frame-options.enabled=false (no
X-Frame-Options), and passes against this branch as it is.
antobinary added a commit to bigbluebutton/bigbluebutton that referenced this pull request Oct 15, 2026
…rails 8

Two defaults change with the Grails 8 / Spring Boot 4.1 stack; 3.0 keeps
the behaviour it has on Grails 7:

- grails.security.headers.enabled=false. Grails 8 adds X-Frame-Options:
  SAMEORIGIN, X-Content-Type-Options: nosniff, Referrer-Policy:
  strict-origin-when-cross-origin and X-XSS-Protection: 0 to every
  response (apache/grails-core#15967). The visible effect is that pages
  bbb-web renders itself can no longer be shown in a frame on another
  origin; joining through an LMS frame is not affected. A site can turn
  them on with grails.security.headers.enabled=true in
  /etc/bigbluebutton/bbb-web.properties (checked).
- server.tomcat.max-parameter-count=10000. Spring Boot 4.1 lowered the
  default to 1000, and Tomcat 11 answers a request with more parameters
  (query string plus form body) with HTTP 500 instead of dropping the
  extras. With the setting, 1200 form parameters work as before.

On a 3.0 -> 4.0 forward merge, the headers line stays out of 4.0, which
keeps the Grails defaults (4.0's bbbWebSecurityHeaders test would fail
otherwise). 4.0 gets the same parameter limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants