-
Notifications
You must be signed in to change notification settings - Fork 20
Description
What are the steps to reproduce this issue?
- In your config/modules/cbsecurity.cfc put these settings in for csrf
csrf: {
enableAutoVerifier: true,
verifyExcludes : [
'test.1', 'test.2'
],
rotationTimeout : 30,
enableEndpoint : true,
cacheStorage : 'CacheStorage@cbstorages',
enableAuthTokenRotator: true
}
- Attempt to get a csrf token by calling
/cbcsrf/generate- you will see a response 'Page Not Found' - You can attempt to access an endpoint (non-get) without a csrf token and you will not get a 'token not found exception'
What happens?
Looks like the settings from cbsecurity.csrf are not properly being set/propagated to the cbcsrf dependency.
Did a little digging and Line 167 in models/CBSecurity.cfc looked off
variables.moduleSettings.cbcsrf.settings.append( variables.settings.csrf, false );
Since all the values are defined in the default struct and with the overwrite flag being false, the module config will never override them.
Setting this to true will enable the /cbcsrf/generate endpoint but the interceptor to check the csrf token is still not being registered even though this is true enableAutoVerifier: true
Not sure how Coldbox handles module loading order, but the cbcsrf onLoad() appears to be called before the cbsecurity module gets set up
function onLoad(){
binder.map( "CacheStorage@cbcsrf" ).toDSL( settings.cacheStorage );
// Auto load verifier?
if ( settings.enableAutoVerifier ) { ***<- this is not reading the true set in cbsecurity config***
controller
.getInterceptorService()
.registerInterceptor(
interceptorClass = "cbcsrf.interceptors.VerifyCsrf",
interceptorName = "VerifyCsfr@cbcsrf"
);
}
// Auth Rotator
if ( settings.enableAuthTokenRotator ) {
controller
.getInterceptorService()
.registerInterceptor(
interceptorClass = "cbcsrf.interceptors.AuthRotator",
interceptorName = "AuthRotator@cbcsrf"
);
}
}
Not sure if there's a way to specify the order and say cbcsrf should be loaded after cbsecurity, but I'm not really too sure how to fix this one.
What versions are you using?
Operating System: Windows 11 x64
Package Version: Lucee 7, CBSecure 3.6