Skip to content

fix: explicit cbcsrf module settings win over the cbsecurity csrf key - #75

Merged
lmajano merged 2 commits into
developmentfrom
claude/funny-mendel-eeim2l
Oct 9, 2026
Merged

lmajano merged 2 commits into
developmentfrom
claude/funny-mendel-eeim2l

Conversation

@lmajano

@lmajano lmajano commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

cbcsrf is a module with its own settings, and cbsecurity also has a csrf key that configures it. At startup cbsecurity copied its whole csrf block, defaults included, over the cbcsrf module settings. So anything set on cbcsrf itself was silently lost, even when cbsecurity.csrf was never set. A client hit this: they configured cbcsrf and cbsecurity overrode it again.

The precedence is now, per setting, highest first:

  1. A value explicitly set in the cbcsrf module settings (moduleSettings.cbcsrf, or config/modules/cbcsrf.cfc).
  2. A value explicitly set in cbsecurity.csrf.
  3. The default, which is the same in both modules.

cbsecurity.csrf now shows the values that are in effect.

How it works: onDIComplete() records what the user set in cbsecurity.csrf before the defaults are merged, and resolveCsrfSettings() merges it with the cbcsrf settings. A cbcsrf key counts as user set when it is in the app's moduleSettings.cbcsrf, or when its value differs from the default (which covers config/modules/cbcsrf.cfc, since ColdBox merges that into the module settings). The one gap: a cbcsrf value explicitly set to the default, while cbsecurity.csrf sets something different, lets cbsecurity win.

Behavior change

Anyone who set the same key on both modules and relied on cbsecurity.csrf winning now gets the cbcsrf value.

Issues

No issue is linked yet, please link or create one.

Type of change

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Testing

BoxLang 1.18, TestBox 7.1. 8 new unit specs (CsrfSettingsSpec), all 37 unit specs pass. The integration run shows the same 1 failure and 15 errors as before this change, all JWT database specs with no datasource in my sandbox.

I also ran the real app with five configurations and read the effective cbcsrf settings:

Configuration rotationTimeout in effect
Neither 30
Only cbcsrf = 99 99 (was 30 before this fix)
Only cbsecurity.csrf = 77 77
Both, 99 and 77 99
cbcsrf timeout 99, cbsecurity.csrf enableEndpoint true 99 with the endpoint on

I could not run Adobe, Lucee or ColdBox 7 locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY


Generated by Claude Code

cbsecurity copied its csrf settings, defaults included, over the cbcsrf module
settings, so settings set on cbcsrf itself were silently lost. The precedence is
now explicit cbcsrf settings, then explicit cbsecurity.csrf, then the defaults.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

lucee@5 ColdBox ^8.0.0 Test Results

  1 files  ±0   10 suites  +1   12s ⏱️ -4s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

lucee@6 ColdBox ^7.0.0 Test Results

  1 files  ±0   10 suites  +1   10s ⏱️ -1s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

lucee@5 ColdBox ^7.0.0 Test Results

  1 files  ±0   10 suites  +1   12s ⏱️ ±0s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

lucee@6 ColdBox be Test Results

234 tests  +6   234 ✅ +6   14s ⏱️ ±0s
 10 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

boxlang-cfml@1 ColdBox 8 Test Results

  1 files  ±0   10 suites  +1   9s ⏱️ -3s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

boxlang-cfml@1 ColdBox ^8.0.0 Test Results

  1 files  ±0   10 suites  +1   12s ⏱️ -1s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

lucee@6 ColdBox ^8.0.0 Test Results

  1 files  ±0   10 suites  +1   8s ⏱️ -1s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

boxlang-cfml@1 ColdBox be Test Results

236 tests  +8   236 ✅ +8   14s ⏱️ ±0s
 10 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

boxlang-cfml@1 ColdBox ^7.0.0 Test Results

  1 files  ±0   10 suites  +1   10s ⏱️ -1s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

boxlang-cfml@be ColdBox 8 Test Results

  1 files  ±0   10 suites  +1   10s ⏱️ -1s
183 tests +6  183 ✅ +6   0 💤 ±0  0 ❌ ±0 
234 runs  +6  183 ✅ +6  51 💤 ±0  0 ❌ ±0 

Results for commit d3802de. ± Comparison against base commit 1c237ce.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

adobe@2023 ColdBox ^8.0.0 Test Results

  1 files  ±0   10 suites  +1   11s ⏱️ -1s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

adobe@2023 ColdBox ^7.0.0 Test Results

  1 files  ±0   10 suites  +1   11s ⏱️ +2s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

adobe@2025 ColdBox ^8.0.0 Test Results

  1 files  ±0   10 suites  +1   9s ⏱️ -1s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

adobe@2025 ColdBox ^7.0.0 Test Results

  1 files  ±0   10 suites  +1   11s ⏱️ +2s
185 tests +8  185 ✅ +8   0 💤 ±0  0 ❌ ±0 
236 runs  +8  185 ✅ +8  51 💤 ±0  0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

adobe@2023 ColdBox be Test Results

236 tests  +8   236 ✅ +8   15s ⏱️ +2s
 10 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit aa522df. ± Comparison against base commit 1c237ce.

Only keys the user set in cbsecurity.csrf are applied on top of the cbcsrf
module settings. Everything else keeps the cbcsrf value, so cbsecurity
defaults never overwrite a cbcsrf override.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
@lmajano
lmajano merged commit 7121a9e into development Oct 9, 2026
41 checks passed
lmajano pushed a commit to ortus-docs/cbsecurity-docs that referenced this pull request Oct 9, 2026
Matches coldbox-modules/cbsecurity#75. Only keys set in cbsecurity.csrf are
applied, other keys keep the cbcsrf value.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E8yy4oK5vnaVucmYLg4UtY
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.

2 participants