Skip to content

security: replace md5() with sha256 for email dedup key (GHSA-gf2h-84m3-q6m3) - #809

Open
bmfmancini wants to merge 3 commits into
developfrom
advisory-fix-md5
Open

security: replace md5() with sha256 for email dedup key (GHSA-gf2h-84m3-q6m3)#809
bmfmancini wants to merge 3 commits into
developfrom
advisory-fix-md5

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

Security Fix — GHSA-gf2h-84m3-q6m3

Fixes GHSA-gf2h-84m3-q6m3

Summary

The thold_notification_queue_process() function in thold_functions.php used PHP's md5() function (line 7311) to generate a cache key for deduplicating queued email notifications by recipient list.

Vulnerability Details

  • Rule: php:S4790 (SonarQube)
  • CWE: CWE-1240 (Use of a Risky Cryptographic Primitive)
  • OWASP: A02:2021 - Cryptographic Failures
  • Severity: Critical
  • Location: thold_functions.php, line 7311

Changes

Replaced md5() with hash('sha256', ...) which uses a modern, collision-resistant hash algorithm.

- $id = md5(json_encode([$from, $to, $cc, $bcc, $replyto]));
+ $id = hash('sha256', json_encode([$from, $to, $cc, $bcc, $replyto]));

Testing

  • PHP syntax check passes (php -l thold_functions.php)
  • No functional change — the hash is used as an associative array key for email deduplication, SHA-256 produces a string suitable for this purpose

Copilot AI lite review requested due to automatic review settings August 17, 2026 20:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

TheWitness
TheWitness previously approved these changes Aug 17, 2026

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PHP change is safe for an in-process deduplication key, but this PR does not yet meet the repository's changed-line gate: the Pest job reports 0/1 changed lines covered, and every integration check is red. Please rebase onto the Cacti-Composer/Pest workflow from #776, add a focused Pest case that exercises recipient grouping/deduplication, and add the CHANGELOG entry. Also describe this accurately as static-analysis hardening: this value is not a cryptographic trust boundary.

@bmfmancini

Copy link
Copy Markdown
Member Author

I will add the changelogs but the tests I will be reorganizing like in 1.2.x branch so I don't want to push them until that pr is merged

Replace md5() with hash('sha256', ...) for the email grouping
deduplication key. While this usage is not security-sensitive (it's
a cache key for grouping emails by recipient list, not password
hashing or integrity verification), using a modern hash algorithm
eliminates the weak hashing finding (CWE-1240).

Addresses SonarQube finding: php:S4790 at thold_functions.php:7311
@somethingwithproof

Copy link
Copy Markdown
Member

The latest revision now has a focused test, CHANGELOG entry, and green CI. The code change itself is safe, but this value is only an in-process array deduplication key, not a cryptographic trust boundary, so please keep the description framed as static-analysis hardening. Before merge, split out the unrelated shared workflow changes; they are duplicated across #806-#809 and remove the advisory develop compatibility job from every patch.

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.

4 participants