Skip to content

Warnings can appear from CSRF Magic library due to multiple token values being found #3317

@ddb4github

Description

@ddb4github

Describe the bug
Sometimes, CSRF report error as below.

2020/03/04 04:04:12 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins.php[25]:include(), /include/auth.php[28]:unknown(), /include/global.php[496]:include_once(), /include/csrf.php[31]:include_once(), /include/vendor/csrf/csrf-magic.php[580]:csrf_check(), /include/vendor/csrf/csrf-magic.php[88]:CactiErrorHandler()) 
2020/03/04 04:04:12 - ERROR PHP NOTICE: Array to string conversion in file: /var/www/html/cacti/include/vendor/csrf/csrf-magic.php on line: 88 

To Reproduce
Not sure how to reproduce, before/after error i access several page, and uninstall/install syslog plugin

Possible Diff

--- csrf-magic.php    2020-03-04 04:13:32.712019835 +0000
+++ csrf-magic.php    2020-03-04 04:27:08.960811931 +0000
@@ -85,9 +85,6 @@
                        // schemes are volatile.
                        $tokens = $_POST[$name];
                        $result = csrf_check_tokens($tokens);
+                       if (is_array($tokens)){
+                               $tokens = implode(';', $tokens);
+                       }
                        csrf_log(__FUNCTION__,"check_tokens($name, $tokens) returned $result");
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions