Ticket #6293 (closed defect (bug): fixed)

Opened 4 years ago

Last modified 4 years ago

phpass should use uniqid(), not getmypid()

Reported by: tellyworth Owned by: anonymous
Priority: normal Milestone: 2.5
Component: General Version: 2.5
Severity: blocker Keywords: has-patch
Cc: westi

Description

class-phpass.php uses this code to generate a random string:

$this->random_state = microtime() . getmypid();

It shouldn't, because (a) it reinvents the uniqid() wheel, and (b) getmypid() is evidently disabled on some locked-down PHP installs:

 http://wordpress.org/support/topic/162121?replies=2

The patch changes it to call uniqid() instead.

Attachments

phpass-uniqid-r7392.patch Download (444 bytes) - added by tellyworth 4 years ago.

Change History

  • Version set to 2.5
  • Severity changed from normal to blocker

phpass is a 3rd party class and I believe the developers prefer not to modify them in most cases.

This may be a special case though as it's a blocker.

Oh, also:

Warning

Process IDs are not unique, thus they are a weak entropy source. We recommend against relying on pids in security-dependent contexts.

comment:3   DD324 years ago

phpass is a 3rd party class and I believe the developers prefer not to modify them in most cases.

Cases where its a Security issue or It doesnt work properly can be classified as bugs, AFAIK, Its ok to fix bugs in the version WordPress uses, and submit the patches up stream for consideration, or a better fix.

Yeah, I know. :)

comment:5   ryan4 years ago

Solar Designer, author of phpass, is investigating.

comment:7   ryan4 years ago

Solar Designer sent me a detailed reply, which I'll try to summarize here. In general, getmypid() is sufficient for this fallback code path even if disabled, but if we want to address the warning we can use this:

$this->random_state = microtime() . (function_exists("getmypid") ? getmypid() : "") . uniqid(rand(), TRUE);

This won't go into upstream phpass for awhile due to it's PHP3 dependency, but we can add it if we like.

  • Cc westi added

comment:9   ryan4 years ago

  • Status changed from new to closed
  • Resolution set to fixed

(In [7421]) Use uniqid if getmypid is disabled. Props Solar Designer. fixes #6293

Note: See TracTickets for help on using tickets.