Missing Cross-Site Request Forgery (CSRF) configuration

Description

Your application is vulnerable when Cross-Site Request Forgery (CSRF) protection is disabled. This weakness can allow attackers to deceive users into executing actions they did not intend, potentially compromising security or data integrity.

Remediations

  • Do ensure that CSRF proteection is enabled in your web application's configuration settings. This prevents attackers from exploiting your web application by making unauthorized requests on behalf of the user.
    use Symfony\Config\FrameworkConfig;

    return static function (FrameworkConfig $framework): void {
    $framework->csrfProtection()
    ->enabled(true)
    ;
    };

References

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=php_symfony_csrf_protection_disabled

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=php_symfony_csrf_protection_disabled