Inconistent csrf issues

Your software
My Mautic version is: 5.1.1
My PHP version is: 8.1
My Database type and version is: mysql

Your problem
Inconsistent CSRF issues.
Anyone is having troubles saving data - like adding contacts. where it would save sometimes but sometimes not saying csrf is ivalid?

OK, if any of you are running into a weird inconsistent CSRF problems with mautic after fresh installation.

Where sometimes mautic works, but in like 70% of cases it reports “The CSRF token is invalid. Please try to resubmit the form.” and doesn’t save on ajax/fetch calls…

Problem was as it turned out - In my docker setup - I intentionally have ipv6 enabled.
Also my docker networks have IPv6 configured.
So my mautic containers get both IPv6 and IPv4 - Docker will then use either one interchangeably and I think defaults to IPv6 now. So it would try IPv6 first, it wouldnt work, so it would return back 302 and page would reload. I observed it sometimes would reload the same page 3-6 times on IPv6, and then would try IPV4. But csrf token would be no longer valid because of those previous 302s would have I think used it up.

So you have to make sure to whitelist IPv6 range in trusted_proxies as well (not only IPv4).
Do something like this (obviously more precise ips/ranges are recommended):

        'trusted_proxies' => array(
                '0' => '0.0.0.0/0',
                '1' => '::/0'
        ),

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.