Postponed
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Feb 2026 at 10:04 UTC
Updated:
26 Mar 2026 at 20:15 UTC
Jump to comment: Most recent
#3573259: Prevent new expects($this->any()) in tests introduced spaze/phpstan-disallowed-calls as a dev dependency.
We can now leverage on the extension to disallow usage of uniqid(), md5(), sha1().
do it
decide if we want to do this
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mondrakeComment #3
mondrakeParent was committed, this is now actionable.
Comment #6
mondrakeIs this worth doing?
Comment #7
smustgrave commentedDo we have existing instances that need replaced? How often do they appear if it warrants a rule?
Comment #8
mondrake#7 the raw output of the PHPStan job tells where the functions are used. The error could be baselined in the MR, and this would then prevent more usage once committed.
Comment #9
mondrakeReference for md5 and sha1 ban: https://www.drupal.org/docs/7/security/writing-secure-code-0/use-of-hash...
Comment #10
sivaji_ganesh_jojodae commentedThe pipeline has failed due to a PHP linting error.
Comment #11
smustgrave commentedIf you read the comments it was being discussed not for code review
Comment #12
mondrakeYes please, let’s first discuss if this is ok to do.
Comment #13
longwaveI think this is a good idea for md5 and sha1, we should point users to sha256 or xxhash instead I guess? Not sure what to do about uniqid().
Comment #14
mondrake#13 one of these maybe? #2972100-24: Remove usage of uniqid
There was some consensus on
crypt::randomBytesBase64(16)afaicsComment #15
idebr commented#3307718: Implement xxHash for non-cryptographic use-cases suggests replacing md5/sha1 with xxHash alternatives
Comment #16
mondrakeReflected latest comments in the MR - it now redirects sha1() and md5() to use sha256() or hash() with xxHash algo, and uniqid() to use Crypt:: randomBytesBase64().
Rabased and now added errors to the baseline.
Comment #17
smustgrave commentedAwesome to see this one come together. Replacements make sense and probably could spin up follow ups to do the replacements.
Comment #18
godotislateNW for merge conflict in phpstan baseline.
Comment #19
mondrakeMerged with main and resolved a conflict.
Comment #20
poker10 commentedThanks for working on this. Added a comment to the MR, as I think it is not a good idea to link to the Drupal 7 documentation. Also think we should add a CR for this (a similar from the past https://www.drupal.org/node/2833433). Moving to NW for this.
Comment #21
mondrakeAdded draft CR https://www.drupal.org/node/3581605
Comment #22
mondrakeComment #23
mondrakeAddressed @poker10 review, added a draft CR, added more disallows based on what I read. Thanks!
Comment #24
smustgrave commentedFeedback and CR look good
Comment #25
catchcrc32 shouldn't use Crypt::hashBase64(), it should be replaced with
xxHash, the other exclusions in the MR say this.The errorTip links to the change record, but then the change record links back to the errorTip.
I am not sure we should duplicate documentation on e.g. https://xxhash.com/ but I think we probably need to say at least something like:
'Use a cryptographic hashing algorithm when appropriate. Use a fast, low collision, non-cryptographic algorithm when approprate (usually one of the xxHash variants), don't use weak cryptographic algorithms.'
Also while this will stop further cases being added to core, I'm a little bit concerned about committing it with the core usages not converted yet, because when we (hopefully) set a good example in core that's an easy place to follow and refer to.
Comment #26
catchComment #27
mondrakeMaybe we can do #3581442: Replace usage of uniqid() in the Database system first, then.