Project

General

Profile

Actions

Feature #14915

closed

Deprecate String#crypt

Added by jeremyevans0 (Jeremy Evans) almost 3 years ago. Updated over 1 year ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:87959]

Description

This method is system and implementation dependent, and the
portable usage mentioned in the documentation is not truly
portable (doesn't work on OpenBSD) and insecure as it uses DES.
For systems that lack a crypt(3) implementation, Ruby will
happily substitute a version that only supports DES. It's 2018,
using DES should be avoided if at all possible.

The only internal usage of String#crypt in Ruby is in Webrick,
where it uses DES for basic authentication with an htpasswd file.
That could and should be changed to use a more secure hash by
default (bcrypt since that's the most secure htpasswd format),
or at least allow the user to customize Webrick's authentication.
I expect there are few if any users actively using Webrick's
htpasswd support.

This moves the String#crypt implementation to the string/crypt
extension, but leaves the String#crypt core method. The core
method prints a deprecation warning, then loads the string/crypt
extension. The string/crypt extension undefines the String#crypt
core method, then defines the previous implementation.

Because extensions use extconf.rb instead of configure for their
configuration, this ports the related configure.ac code to
extconf.rb. I'm not sure that is done correctly and works on
all platforms, it will need testing.

For systems that lack a crypt(3) implementation, this modifies the
fallback code to only define crypt_r, since that is the only
function that String#crypt will call in that case.

While the patch just deprecates String#crypt, I think
we should plan to remove support from ruby:

2.6: core method deprecated
2.7: core method removed, string/crypt extension ships with ruby
2.8: string/crypt extension moves to external gem, not shipped


Files

0001-Deprecate-String-crypt-move-implementation-to-string.patch (20.5 KB) 0001-Deprecate-String-crypt-move-implementation-to-string.patch jeremyevans0 (Jeremy Evans), 07/16/2018 05:47 PM
0001-Deprecate-String-crypt.patch (7.48 KB) 0001-Deprecate-String-crypt.patch jeremyevans0 (Jeremy Evans), 07/26/2018 07:42 PM
0001-Deprecate-String-crypt.patch (7.35 KB) 0001-Deprecate-String-crypt.patch jeremyevans0 (Jeremy Evans), 11/29/2018 08:27 AM
0001-Deprecate-String-crypt.patch (7.43 KB) 0001-Deprecate-String-crypt.patch jeremyevans0 (Jeremy Evans), 11/29/2018 03:20 PM
deprecate-string-crypt.patch (6.7 KB) deprecate-string-crypt.patch jeremyevans0 (Jeremy Evans), 05/18/2019 03:06 PM

Related issues

Related to Ruby master - Feature #14940: Support bcrypt password hashing in webrickClosednormalperson (Eric Wong)Actions
Actions

Also available in: Atom PDF