CVE-2023-30607 (PHP, published 2023-07-05T18:15Z)
Description: value: icingaweb2-module-jira provides integration with Atlassian Jira. Starting in version 1.3.0 and prior to version 1.3.2, template and field configuration forms perform the deletion action before user input is validated, including the cross site request forgery token. This issue is fixed in version 1.3.2. There are no known workarounds.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
Repository: https://github.com/Icinga/icingaweb2-module-jira
Files changed:
application/forms/Config/FieldConfigForm.php
application/forms/Config/TemplateConfigForm.php
Commit message: Do not perform deletion before user input is validated in `FieldConfigForm` and `TemplateConfigForm`

This fixes susceptibility to CSRF attacks.


Vulnerable code:
    /** @var bool Hack used for delete button */
    protected $callOnSuccess;

                $this->fieldId = array_search($fieldId, $this->fields);
            if ($deleteButton->hasBeenPressed()) {
                $templateFields =  $this->templateConfig->getSection($this->templateName)->toArray();

                $field = isset($templateFields[$this->fieldId]) ? $this->fieldId : $this->fields[$this->fieldId];

                unset($templateFields[$field]);
                $this->templateConfig->setSection($this->templateName, $templateFields);
                $this->templateConfig->saveIni();
                $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
                $this->callOnSuccess = false;
                return;
        if ($this->callOnSuccess === false) {
            $this->getPressedSubmitElement()->setValue($this->getElement('delete')->getLabel());
    /** @var bool Hack used for delete button */
    protected $callOnSuccess;

            $this->getElement('submit')->getWrapper()->prepend($deleteButton);
            if ($deleteButton->hasBeenPressed()) {
                $this->config->removeSection($this->templateName);
                $this->config->saveIni();
                // Stupid cheat because ipl/html is not capable of multiple submit buttons
                $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
                $this->callOnSuccess = false;
                return;
        if ($this->callOnSuccess === false) {
            $this->getSubmitButton()->setValue($this->getElement('delete')->getButtonLabel());

Fixed code:
            // obtain field key in case the fieldId is field label
                $this->fieldId = array_search($fieldId, $this->fields) ?: $fieldId;

        }
    }
    public function hasBeenSubmitted()
    {
        if ($this->getPressedSubmitElement() !== null && $this->getPressedSubmitElement()->getName() === 'delete') {
            return true;
        }
        return parent::hasBeenSubmitted();
    }
    public function isValid()
    {
        if ($this->getPressedSubmitElement()->getName() === 'delete') {
            $csrfElement = $this->getElement('CSRFToken');
            if (! $csrfElement->isValid()) {
                return false;

            return true;

        return parent::isValid();
        if ($this->getPressedSubmitElement()->getName() === 'delete') {
            $templateFields =  $this->templateConfig->getSection($this->templateName)->toArray();

            $field = isset($templateFields[$this->fieldId]) ? $this->fieldId : $this->fields[$this->fieldId];

            unset($templateFields[$field]);

            $this->templateConfig->setSection($this->templateName, $templateFields);
            $this->templateConfig->saveIni();
            $this->getElement('submit')
                ->getWrapper()
                ->prepend($deleteButton);
        }
    }
    public function hasBeenSubmitted()
    {
        if ($this->getPressedSubmitElement() !== null && $this->getPressedSubmitElement()->getName() === 'delete') {
            return true;
        }
        return parent::hasBeenSubmitted();
    }
    public function isValid()
    {
        if ($this->getPressedSubmitElement()->getName() === 'delete') {
            $csrfElement = $this->getElement('CSRFToken');

            if (! $csrfElement->isValid()) {
                return false;

            return true;

        return parent::isValid();
        if ($this->getPressedSubmitElement()->getName() === 'delete') {
            $this->config->removeSection($this->templateName);
            $this->config->saveIni();