Skip to content

Commit d91509c

Browse files
jared mauchjared mauch
authored andcommitted
Remove MD5 and crypt() password downgrade support, only support SHA1 upgrade
- Remove MD5 fallback authentication in SecurityManager - Remove crypt() fallback authentication in SecurityManager - Only support PBKDF2 and SHA1 formats (with SHA1 auto-upgrade to PBKDF2) - Add stamp files to prevent duplicate UTF-8 conversions during build - Update .gitignore to exclude conversion stamp files
1 parent d4787c2 commit d91509c

4 files changed

Lines changed: 20 additions & 40 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ src/roster
7979
src/subscribe
8080
src/vsnprintf.o
8181
templates/Makefile
82+
templates/.converted.stamp
8283
tests/Makefile
8384
tests/bounces/Makefile
8485
tests/msgs/Makefile
86+
messages/.converted.stamp

Mailman/SecurityManager.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,12 @@
5858
import urllib.request, urllib.parse, urllib.error
5959
from urllib.parse import urlparse
6060

61-
try:
62-
import crypt
63-
except ImportError:
64-
crypt = None
6561

6662
from Mailman import mm_cfg
6763
from Mailman import Utils
6864
from Mailman import Errors
6965
from Mailman.Logging.Syslog import syslog
70-
from Mailman.Utils import md5_new, sha_new, hash_password, verify_password
66+
from Mailman.Utils import sha_new, hash_password, verify_password
7167

7268

7369
class SecurityManager(object):
@@ -152,47 +148,20 @@ def Authenticate(self, authcontexts, response, user=None):
152148
if ok:
153149
return mm_cfg.AuthSiteAdmin
154150
elif ac == mm_cfg.AuthListAdmin:
155-
def cryptmatchp(response, secret):
156-
try:
157-
salt = secret[:2]
158-
if crypt and crypt.crypt(response, salt) == secret:
159-
return True
160-
return False
161-
except TypeError:
162-
# BAW: Hard to say why we can get a TypeError here.
163-
# SF bug report #585776 says crypt.crypt() can raise
164-
# this if salt contains null bytes, although I don't
165-
# know how that can happen (perhaps if a MM2.0 list
166-
# with USE_CRYPT = 0 has been updated? Doubtful.
167-
return False
168151
# The password for the list admin is stored as a hash.
169152
# We support multiple formats for backwards compatibility:
170153
# - New format: PBKDF2-SHA256 with $pbkdf2$ prefix
171-
# - Old format: SHA1 hexdigest (40 hex chars)
172-
# - Legacy: MD5 or crypt() (auto-upgrade to PBKDF2)
154+
# - Old format: SHA1 hexdigest (40 hex chars, auto-upgrade to PBKDF2)
173155
key, secret = self.AuthContextInfo(ac)
174156
if secret is None:
175157
continue
176158
if isinstance(response, str):
177159
response = response.encode('utf-8')
178160

179-
# Try new PBKDF2 or old SHA1 format first
161+
# Try new PBKDF2 or old SHA1 format (verify_password handles both)
180162
ok, needs_upgrade = verify_password(response, secret)
181163
upgrade = needs_upgrade
182164

183-
# If that didn't work, try legacy MD5 and crypt() formats
184-
if not ok:
185-
sharesponse = sha_new(response).hexdigest()
186-
if sharesponse == secret:
187-
ok = True
188-
upgrade = True
189-
elif md5_new(response).digest() == secret:
190-
ok = True
191-
upgrade = True
192-
elif cryptmatchp(response, secret):
193-
ok = True
194-
upgrade = True
195-
196165
# Upgrade to new PBKDF2 format if needed
197166
if upgrade and ok:
198167
save_and_unlock = False

messages/Makefile.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ check:
8888

8989
install: doinstall
9090

91-
doinstall: mofiles
91+
doinstall: .converted.stamp mofiles
9292
@for d in $(LANGDIRS); \
9393
do \
9494
dir=$(DESTDIR)$(prefix)/$$d; \
@@ -114,15 +114,19 @@ doinstall: mofiles
114114
$(INSTALL) -m $(FILEMODE) $$mo $$dir; \
115115
done
116116

117-
convertpofiles: $(wildcard */LC_MESSAGES/*.po)
117+
# Use a stamp file to track conversion, so it only happens once
118+
.converted.stamp: $(wildcard */LC_MESSAGES/*.po)
118119
../scripts/convert_to_utf8 -d .
120+
touch .converted.stamp
121+
122+
convertpofiles: .converted.stamp
119123

120124
mofiles: $(MOFILES)
121125

122126
finish:
123127

124128
clean:
125-
-rm -f */LC_MESSAGES/mailman.mo
129+
-rm -f */LC_MESSAGES/mailman.mo .converted.stamp
126130

127131
fileclean:
128132
-rm -f marked.files docstring.files

templates/Makefile.in

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ INSTALL_PROGRAM=$(INSTALL) -m $(EXEMODE)
5959

6060
all: converttemplates
6161

62-
converttemplates: $(wildcard */LC_MESSAGES/*.po) $(wildcard */*.html) $(wildcard */*.txt)
62+
# Use a stamp file to track conversion, so it only happens once
63+
.converted.stamp: $(wildcard */LC_MESSAGES/*.po) $(wildcard */*.html) $(wildcard */*.txt)
6364
../scripts/convert_to_utf8 -d .
65+
touch .converted.stamp
6466

65-
install: all
67+
converttemplates: .converted.stamp
68+
69+
install: .converted.stamp
6670
for d in $(LANGUAGES); \
6771
do \
6872
$(srcdir)/../mkinstalldirs $(DESTDIR)$(TEMPLATEDIR)/$$d; \
@@ -75,6 +79,7 @@ install: all
7579
finish:
7680

7781
clean:
82+
-rm -f .converted.stamp
7883

79-
distclean:
84+
distclean: clean
8085
-rm -f Makefile

0 commit comments

Comments
 (0)