You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting in 4.0.5 there is more Cookie Samesite support. We need to fine tune these settings and potentially remove any previous efforts at CSRF if it's conflicting with the built-in CI4 implementation. We need to make any appropriate changes in the links below.
good to hear they have support built in now. The session class was customized for this in CI3, we can probably get rid of this and rely on CI4 instead.
I noticed we are manually writing the csrf headers in the partial/header_js.php. I think I read in the documentation that it automatically inserts CSRF tokens with the form helper when form_open is used. I'm less familiar how to do CSRF properly, so if anyone else wants this, I don't think it will be too involved. Probably mostly stripping out what we did for CI3, making sure it's properly enabled for CI4 and adding in anything lacking in the CI4 implementation. We might want to look into turning on CI4's token randomization feature as well to prevent against BREACH or similar attacks.
The form open isnt usable in case we are using Ajax calls, so thats why we need a js hook as well. We Can disable csrf temporarily and Ill try to look into it
@objecttothis I have re-enabled the CSRF now after a bug report by a security researcher. WIll merge once I get confirmation that it's working as it should
Activity
jekkos commentedon Jan 30, 2023
good to hear they have support built in now. The session class was customized for this in CI3, we can probably get rid of this and rely on CI4 instead.
objecttothis commentedon Jan 30, 2023
I noticed we are manually writing the csrf headers in the partial/header_js.php. I think I read in the documentation that it automatically inserts CSRF tokens with the form helper when form_open is used. I'm less familiar how to do CSRF properly, so if anyone else wants this, I don't think it will be too involved. Probably mostly stripping out what we did for CI3, making sure it's properly enabled for CI4 and adding in anything lacking in the CI4 implementation. We might want to look into turning on CI4's token randomization feature as well to prevent against BREACH or similar attacks.
jekkos commentedon Jan 31, 2023
The form open isnt usable in case we are using Ajax calls, so thats why we need a js hook as well. We Can disable csrf temporarily and Ill try to look into it
objecttothis commentedon Oct 22, 2024
@jekkos, while not CSRF, I did copy over the CSP directives we have in the /public/.htaccess, but I'm unable to set $CSPEnabled to true in /Config/App.php because as of now CI 4 does not yet have CSP level 3 support. Enabling without that support throws errors related to script-src-elem, style-src-attr and style-src-elem. https://forum.codeigniter.com/showthread.php?tid=88753
Do you want to push this issue out to a milestone after 3.4.0 or should we not release until this is done?
Enable CSRF using session token (#3632)
jekkos commentedon Dec 15, 2025
@objecttothis I have re-enabled the CSRF now after a bug report by a security researcher. WIll merge once I get confirmation that it's working as it should
Escape return_policy in receipt + invoice (#4349)
jekkos commentedon Dec 17, 2025
Should be fixed now in master.