summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2020-05-12 12:07:16 -0400
committerEli Collins <elic@assurancetechnologies.com>2020-05-12 12:07:16 -0400
commitcfdce7ee2911d90c2b4204d67e741ad9dd6b4e69 (patch)
treec03ec003982293c95f5dc96be72200a08792821a
parentbc91df7f02c9b2977d86d8398dd1a1af37d0c591 (diff)
downloadpasslib-cfdce7ee2911d90c2b4204d67e741ad9dd6b4e69.tar.gz
bcrypt: silenced "2a wraparound bug" detection warning for os_crypt backend;
since it's expected to be present (e.g. on OpenBSD) for backward compatibility.
-rw-r--r--passlib/handlers/bcrypt.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/passlib/handlers/bcrypt.py b/passlib/handlers/bcrypt.py
index 0f6ecc2..5e5838a 100644
--- a/passlib/handlers/bcrypt.py
+++ b/passlib/handlers/bcrypt.py
@@ -416,11 +416,19 @@ class _BcryptCommon(uh.SubclassBackendMixin, uh.TruncateMixin, uh.HasManyIdents,
else:
assert_lacks_8bit_bug(IDENT_2A)
if detect_wrap_bug(IDENT_2A):
- warn("passlib.hash.bcrypt: Your installation of the %r backend is vulnerable to "
- "the bsd wraparound bug, "
- "and should be upgraded or replaced with another backend "
- "(enabling workaround for now)." % backend,
- uh.exc.PasslibSecurityWarning)
+ if backend == "os_crypt":
+ # don't make this a warning for os crypt (e.g. openbsd);
+ # they'll have proper 2b implementation which will be used for new hashes.
+ # so even if we didn't have a workaround, this bug wouldn't be a concern.
+ log.debug("%r backend has $2a$ bsd wraparound bug, enabling workaround", backend)
+ else:
+ # installed library has the bug -- want to let users know,
+ # so they can upgrade it to something better (e.g. bcrypt cffi library)
+ warn("passlib.hash.bcrypt: Your installation of the %r backend is vulnerable to "
+ "the bsd wraparound bug, "
+ "and should be upgraded or replaced with another backend "
+ "(enabling workaround for now)." % backend,
+ uh.exc.PasslibSecurityWarning)
mixin_cls._has_2a_wraparound_bug = True
#----------------------------------------------------------------