Skip to content

push to jira: check for existing jira issue inside celery task #12508

Merged
valentijnscholten merged 1 commit into
DefectDojo:bugfixfrom
valentijnscholten:jira-duplicate-issue-fix
May 28, 2025
Merged

push to jira: check for existing jira issue inside celery task #12508
valentijnscholten merged 1 commit into
DefectDojo:bugfixfrom
valentijnscholten:jira-duplicate-issue-fix

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented May 26, 2025

Copy link
Copy Markdown
Member

Probably Fixes #12158

The JIRA helper was checking whether a new JIRA issue needed to be created or an existing needed to be updated.
This check happened before the task was submitted to Celery for background processing. This check was too early as by the time the add_jira_issue task was picked up by Celery there could have been another add_jira_issue task before that which had already created an issue. This could happen in certain scenario's with a slow celery worker, slow JIRA and/or fast import-reimport touching the same findings.

This PR now moves the check for an existing JIRA issue inside the celery task itself to avoid this scenario.

In theory duplicates could still happen when running multiple workers in parallel. To avoid that we would some kind of locking to ensure only one push to jira task can be submitted for a specific finding. Since that is non-trivial and this PR already provides a huge reduction on the chance of duplicates occurring, I suggest we wait to see if that complication is really needed.
There are alterntiave more lightweight improvements such as:

  • catch the exception when we hit a duplicate jira_issue instance and close the finding in JIRA.
  • add a label defectdojo-finding-id-12345 to each created finding and perform an "exist" check in JIRA before creating a new JIRA issue.

@dryrunsecurity

Copy link
Copy Markdown

DryRun Security

This pull request contains potential security risks related to indirect object references and sensitive information logging, which could expose system internals and create vulnerabilities if proper access controls and logging practices are not implemented.

💭 Unconfirmed Findings (2)
Vulnerability Potential Indirect Object Reference (IDOR) Risk
Description Decorators @dojo_model_to_id and @dojo_model_from_id could be exploited if access controls are not properly implemented. The risk stems from converting between model instances and IDs without robust security checks.
Vulnerability Logging of Sensitive Object Information
Description Error logging reveals object details including name, ID, and type. This could lead to potential information disclosure that leaks internal system structure and provides attackers insights into system internals.

All finding details can be found in the DryRun Security Dashboard.

@valentijnscholten valentijnscholten changed the title push to jira: check for existing issue inside celery task push to jira: check for existing jira issue inside celery task May 26, 2025
@valentijnscholten valentijnscholten added this to the 2.47.0 milestone May 26, 2025
@Maffooch Maffooch requested review from dogboat and hblankenship May 27, 2025 14:25

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@valentijnscholten valentijnscholten merged commit 1f04a4f into DefectDojo:bugfix May 28, 2025
76 checks passed
xansec pushed a commit to xansec/django-DefectDojo that referenced this pull request Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants