[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Tue Sep 13 00:09:02 UTC 2022
The branch, master has been updated
via 8ae0c38d54f CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR AES password change
via 1d869a2a666 CVE-2021-20251 s3:rpc_server: Split change_oem_password() call out of samr_set_password_aes()
via 7981cba87e3 CVE-2021-20251 dsdb/common: Remove transaction logic from samdb_set_password()
via fcabcb326d3 CVE-2021-20251 s4-rpc_server: Extend scope of transaction for ChangePasswordUser3
via f74f92aea16 CVE-2021-20251 s4-rpc_server: Use user privileges for SAMR password change
via fabbea25310 CVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user
via 1258746ba85 s3:rpc_server: Use BURN_STR() to zero password
via 6edf88f5c40 libcli:auth: Keep passwords from convert_string_talloc() secret
via 03a50d8f7d8 lib:util: Check memset_s() error code in talloc_keep_secret_destructor()
via 65c473d4a53 CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR password change
via 8587734bf98 CVE-2021-20251 s3: ensure bad password count atomic updates
via 268ea7bef5a CVE-2021-20251 s4:auth_winbind: Check return status of authsam_logon_success_accounting()
via a268a1a0e30 CVE-2021-20251 s4-rpc_server: Check badPwdCount update return status
via bdfc9d96f8f CVE-2021-20251 s4:kdc: Check badPwdCount update return status
via b1e740896eb CVE-2021-20251 s4:kdc: Check return status of authsam_logon_success_accounting()
via 2b593c34c4f CVE-2021-20251 s4:kdc: Move logon success accounting code into existing branch
via 96479747bdb CVE-2021-20251 s4:dsdb: Make badPwdCount update atomic
via a65147a9e98 CVE-2021-20251 s4:dsdb: Update bad password count inside transaction
via d8a862cb811 CVE-2021-20251 s4-auth: Pass through error code from badPwdCount update
via b5f78b7b895 CVE-2021-20251 auth4: Avoid reading the database twice by precaculating some variables
via 712181032a4 CVE-2021-20251 auth4: Inline samdb_result_effective_badPwdCount() in authsam_logon_success_accounting()
via 55147335aec CVE-2021-20251 auth4: Split authsam_calculate_lastlogon_sync_interval() out
via b954acfde25 CVE-2021-20251 auth4: Return only the result message and free the surrounding result
via 4a9e0fdccfa CVE-2021-20251 auth4: Add missing newline to debug message on PSO read failure
via de4cc0a3dae CVE-2021-20251 s4 auth: make bad password count increment atomic
via 336e303cf19 CVE-2021-20251 auth4: Detect ACCOUNT_LOCKED_OUT error for password change
via d6cf245b96f CVE-2021-20251 s4 auth test: Unit tests for source4/auth/sam.c
via 7b8e32efc33 CVE-2021-20251 auth4: Reread the user record if a bad password is noticed.
via 408717242aa CVE-2021-20251 s4 auth: Prepare to make bad password count increment atomic
via 2087b0cd986 CVE-2021-20251 auth4: split samdb_result_msds_LockoutObservationWindow() out
via 439f96a2cfe CVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user
via 91e2e5616cc CVE-2021-20251 tests/krb5: Add tests for password lockout race
via 4bb9d85fed8 CVE-2021-20251 lib:crypto: Add Python functions for AES SAMR password change
via 17b8d164f69 CVE-2021-20251 lib:crypto: Add md4_hash_blob() for hashing data with MD4
via b27a67af021 CVE-2021-20251 lib:crypto: Add des_crypt_blob_16() for encrypting data with DES
via 121e439e24a lib:crypto: Use constant time memory comparison to check HMAC
via cec59b82f70 lib:crypto: Check for overflow before filling pauth_tag array
via 03f0e4d55be s4:torture: Zero samr_UserInfo union in password set test
via f9850c776f8 lib:crypto: Zero auth_tag array in encryption test
via 6932ccf3ccf s3:rpc_server: Fix typo in error message
from c9a71e07ad1 s3: smbtorture: In run_smb1_dfs_paths() ensure we're actually reading and testing crtimes from the filesystem.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 8ae0c38d54f065915e927bbfe1b656400a79eb13
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:43:19 2022 +1200
CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR AES password change
The bad password count is supposed to limit the number of failed login
attempt a user can make before being temporarily locked out, but race
conditions between processes have allowed determined attackers to make
many more than the specified number of attempts. This is especially
bad on constrained or overcommitted hardware.
To fix this, once a bad password is detected, we reload the sam account
information under a user-specific mutex, ensuring we have an up to
date bad password count.
We also update the bad password count if the password is wrong, which we
did not previously do.
Derived from a similar patch to source3/auth/check_samsec.c by
Jeremy Allison <jra at samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Tue Sep 13 00:08:07 UTC 2022 on sn-devel-184
commit 1d869a2a666cfada1495d891021de6c2b8567a96
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:43:09 2022 +1200
CVE-2021-20251 s3:rpc_server: Split change_oem_password() call out of samr_set_password_aes()
Now samr_set_password_aes() just returns the new password in a similar
manner to check_oem_password(). This simplifies the logic for the
following change to recheck whether the account is locked out, and to
update the bad password count.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 7981cba87e3a7256b12bfc5fdd89b136c12979ff
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:40:01 2022 +1200
CVE-2021-20251 dsdb/common: Remove transaction logic from samdb_set_password()
All of its callers, where necessary, take out a transaction covering the
entire password set or change operation, so a transaction is no longer
needed here.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit fcabcb326d385c1e1daaa8dae9820e33a3868f56
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:39:43 2022 +1200
CVE-2021-20251 s4-rpc_server: Extend scope of transaction for ChangePasswordUser3
Now the initial account search is performed under the transaction,
ensuring the overall password change is atomic. We set DSDB_SESSION_INFO
to drop our privileges to those of the user before we perform the actual
password change, and restore them afterwards if we need to update the
bad password count.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit f74f92aea164af40d9177b332778a76d7ecabcbd
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:39:06 2022 +1200
CVE-2021-20251 s4-rpc_server: Use user privileges for SAMR password change
We don't (and shouldn't) need system prvileges to perform the password
change, so drop to the privileges of the user by setting
DSDB_SESSION_INFO. We need to reuse the same sam_ctx: creating a new one
with only user privileges would not work, because any database
modifications would be blocked by the transaction taken out on the
original context.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit fabbea25310a31c0409b1c11eaced39bd8cde8dd
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:37:52 2022 +1200
CVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user
This helps the bad password and audit log handling code as it
allows assumptions to be made about the attributes found in
the variable "msg", such as that DSDB_SEARCH_SHOW_EXTENDED_DN
was used.
This ensures we can re-search on the DN via the embedded GUID,
which in in turn rename-proof.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 1258746ba85b8702628f95a19aba9afea96eab8b
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Sep 6 14:54:08 2022 +1200
s3:rpc_server: Use BURN_STR() to zero password
This ensures these calls are not optimised away.
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 6edf88f5c40421b9881666a2e78038ea9c547c24
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:35:50 2022 +1200
libcli:auth: Keep passwords from convert_string_talloc() secret
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 03a50d8f7d872b6ef701d1207061c88b73d171bb
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:35:33 2022 +1200
lib:util: Check memset_s() error code in talloc_keep_secret_destructor()
Panic if memset_s() fails.
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 65c473d4a53fc8a22a0d531aff45203ea3a4d99b
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Jul 5 20:17:33 2022 +1200
CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR password change
The bad password count is supposed to limit the number of failed login
attempt a user can make before being temporarily locked out, but race
conditions between processes have allowed determined attackers to make
many more than the specified number of attempts. This is especially
bad on constrained or overcommitted hardware.
To fix this, once a bad password is detected, we reload the sam account
information under a user-specific mutex, ensuring we have an up to
date bad password count.
Derived from a similar patch to source3/auth/check_samsec.c by
Jeremy Allison <jra at samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 8587734bf989aeaafa9d09d78d0f381caf52d285
Author: Jeremy Allison <jra at samba.org>
Date: Mon Jan 11 12:11:35 2021 -0800
CVE-2021-20251 s3: ensure bad password count atomic updates
The bad password count is supposed to limit the number of failed login
attempt a user can make before being temporarily locked out, but race
conditions between processes have allowed determined attackers to make
many more than the specified number of attempts. This is especially
bad on constrained or overcommitted hardware.
To fix this, once a bad password is detected, we reload the sam account
information under a user-specific mutex, ensuring we have an up to
date bad password count.
Discovered by Nathaniel W. Turner.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 268ea7bef5af4b9c8a02f4f5856113ff0664d9e8
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Mon Jul 4 20:51:38 2022 +1200
CVE-2021-20251 s4:auth_winbind: Check return status of authsam_logon_success_accounting()
This may return an error if we find the account is locked out.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit a268a1a0e304d0702469e4ac146d8af5e7384c39
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Sat Jul 9 15:55:02 2022 +1200
CVE-2021-20251 s4-rpc_server: Check badPwdCount update return status
If the account has been locked out in the meantime (indicated by
NT_STATUS_ACCOUNT_LOCKED_OUT), we should return the appropriate error
code.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit bdfc9d96f8fe5070ab8a189bbf42ccb7e77afb73
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Sat Jul 9 15:54:52 2022 +1200
CVE-2021-20251 s4:kdc: Check badPwdCount update return status
If the account has been locked out in the meantime (indicated by
NT_STATUS_ACCOUNT_LOCKED_OUT), we should return the appropriate error
code.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit b1e740896ebae14ba64250da2f718e1d707e9eed
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Fri Jul 1 15:04:41 2022 +1200
CVE-2021-20251 s4:kdc: Check return status of authsam_logon_success_accounting()
If we find that the user has been locked out sometime during the request
(due to a race), we will now return an error code.
Note that we cannot avoid the MIT KDC aspect of the issue by checking
the return status of mit_samba_zero_bad_password_count(), because
kdb_vftabl::audit_as_req() returning void means we cannot pass on the
result.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 2b593c34c4f5cb82440b940766e53626c1cbec5b
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Wed Jul 6 11:11:43 2022 +1200
CVE-2021-20251 s4:kdc: Move logon success accounting code into existing branch
This simplifies the code for the following commit.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 96479747bdb5bc5f33d903085f5f69793f369e3a
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Sat Jul 9 15:54:12 2022 +1200
CVE-2021-20251 s4:dsdb: Make badPwdCount update atomic
We reread the account details inside the transaction in case the account
has been locked out in the meantime. If it has, we return the
appropriate error code.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit a65147a9e98ead70869cdfa20ffcc9c167dbf535
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Sat Jul 9 15:44:21 2022 +1200
CVE-2021-20251 s4:dsdb: Update bad password count inside transaction
Previously, there was a gap between calling dsdb_update_bad_pwd_count()
and dsdb_module_modify() where no transaction was in effect. Another
process could slip in and modify badPwdCount, only for our update to
immediately overwrite it. Doing the update inside the transaction will
help for the following commit when we make it atomic.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit d8a862cb811489abb67d4cf3a7fbd83d05c7e5cb
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Sat Jul 9 15:53:51 2022 +1200
CVE-2021-20251 s4-auth: Pass through error code from badPwdCount update
The error code may be NT_STATUS_ACCOUNT_LOCKED_OUT, which we use in
preference to NT_STATUS_WRONG_PASSWORD.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit b5f78b7b895a6b92cfdc9221b18d67ab18bc2a24
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 30 16:48:31 2021 +1300
CVE-2021-20251 auth4: Avoid reading the database twice by precaculating some variables
These variables are not important to protect against a race with
and a double-read can easily be avoided by moving them up the file
a little.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 712181032a47318576ef35f6a6cf0f958aa538fb
Author: Andrew Bartlett <abartlet at samba.org>
Date: Thu Mar 25 15:33:08 2021 +1300
CVE-2021-20251 auth4: Inline samdb_result_effective_badPwdCount() in authsam_logon_success_accounting()
By bringing this function inline it can then be split out in a
subsequent commit.
Based on work by Gary Lockyer <gary at catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 55147335aec8194b6439169b040556a96db22e95
Author: Andrew Bartlett <abartlet at samba.org>
Date: Thu Mar 25 14:42:39 2021 +1300
CVE-2021-20251 auth4: Split authsam_calculate_lastlogon_sync_interval() out
authsam_calculate_lastlogon_sync_interval() is split out of authsam_update_lastlogon_timestamp()
Based on work by Gary Lockyer <gary at catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit b954acfde258a1909ed60c1c3e1015701582719f
Author: Gary Lockyer <gary at catalyst.net.nz>
Date: Thu Mar 25 11:30:59 2021 +1300
CVE-2021-20251 auth4: Return only the result message and free the surrounding result
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 4a9e0fdccfa218fbb2c3eb87e1a955ade0364b98
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 30 16:35:44 2021 +1300
CVE-2021-20251 auth4: Add missing newline to debug message on PSO read failure
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit de4cc0a3dae89f3e51a099282615cf80c8539e11
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 30 18:01:39 2021 +1300
CVE-2021-20251 s4 auth: make bad password count increment atomic
Ensure that the bad password count is incremented atomically,
and that the successful logon accounting data is updated atomically.
Use bad password indicator (in a distinct TDB) to determine if to open a transaction
We open a transaction when we have seen the hint that this user
has recorded a bad password. This allows us to avoid always
needing one, while not missing a possible lockout.
We also go back and get a transation if we did not take out
one out but we chose to do a write (eg for lastLogonTimestamp)
Based on patches by Gary Lockyer <gary at catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 336e303cf1962b56b64c0d9d2b05ac15d00e8692
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Jul 5 20:17:49 2022 +1200
CVE-2021-20251 auth4: Detect ACCOUNT_LOCKED_OUT error for password change
This is more specific than NT_STATUS_UNSUCCESSFUL, and for the SAMR
password change, matches the result the call to samdb_result_passwords()
would give.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit d6cf245b96fb02edb3bcc52733d040d5f03fb918
Author: Gary Lockyer <gary at catalyst.net.nz>
Date: Tue Feb 9 11:59:05 2021 +1300
CVE-2021-20251 s4 auth test: Unit tests for source4/auth/sam.c
cmocka unit tests for the authsam_reread_user_logon_data in
source4/auth/sam.c
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 7b8e32efc336fb728e0c7e3dd6fbe2ed54122124
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 30 17:57:10 2021 +1300
CVE-2021-20251 auth4: Reread the user record if a bad password is noticed.
As is, this is pointless, as we need a transaction to make this
any less of a race, but this provides the steps towards that goal.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 408717242aad8adf4551f2394eee2d80a06c7e63
Author: Gary Lockyer <gary at catalyst.net.nz>
Date: Wed Jan 27 14:24:58 2021 +1300
CVE-2021-20251 s4 auth: Prepare to make bad password count increment atomic
To ensure that the bad password count is incremented atomically,
and that the successful logon accounting data is updated atomically,
without always opening a transaction, we will need to make a note
of all bad and successful passwords in a side-DB outside the
transaction lock.
This provides the functions needed for that and hooks them in
(future commits will handle errors and use the results).
Based on patches by Gary Lockyer <gary at catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 2087b0cd986b8959b2a402b9a1891472e47ca0b0
Author: Gary Lockyer <gary at catalyst.net.nz>
Date: Tue Mar 16 10:52:58 2021 +1300
CVE-2021-20251 auth4: split samdb_result_msds_LockoutObservationWindow() out
samdb_result_msds_LockoutObservationWindow() is split out of
samdb_result_effective_badPwdCount()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 439f96a2cfe77f6cbf331d965a387512c2db91c6
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 30 10:51:26 2021 +1300
CVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user
This helps the bad password and audit log handling code as it
allows assumptions to be made about the attributes found in
the variable "msg", such as that DSDB_SEARCH_SHOW_EXTENDED_DN
was used.
This ensures we can re-search on the DN via the embedded GUID,
which in in turn rename-proof.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 91e2e5616ccd507fcaf097533c5fc25974119c1e
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Mon Jul 4 20:48:48 2022 +1200
CVE-2021-20251 tests/krb5: Add tests for password lockout race
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 4bb9d85fed8498566bdb87baa71a3147806baafc
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:35:19 2022 +1200
CVE-2021-20251 lib:crypto: Add Python functions for AES SAMR password change
These functions allow us to perform key derivation and AES256 encryption
in Python. They will be used in a following commit.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 17b8d164f69a5ed79d9b7b7fc2f3f84f8ea534c8
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Wed Jul 13 14:20:59 2022 +1200
CVE-2021-20251 lib:crypto: Add md4_hash_blob() for hashing data with MD4
This lets us access MD4, which might not be available in hashlib, from
Python. This function is used in a following commit for hashing a
password to obtain the verifier for a SAMR password change.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit b27a67af0216811d330d8a4c52390cf4fc04b5fd
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Wed Jul 6 15:36:26 2022 +1200
CVE-2021-20251 lib:crypto: Add des_crypt_blob_16() for encrypting data with DES
This lets us access single-DES from Python. This function is used in a
following commit for encrypting an NT hash to obtain the verifier for a
SAMR password change.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14611
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 121e439e24a9c03ae900ffca1ae1dda8e059008c
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:34:55 2022 +1200
lib:crypto: Use constant time memory comparison to check HMAC
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit cec59b82f7041a305c228091a84257c28e0818d5
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:34:26 2022 +1200
lib:crypto: Check for overflow before filling pauth_tag array
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 03f0e4d55be80a1a6dcc0dba8e6ed74d9da63dc3
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 15:21:43 2022 +1200
s4:torture: Zero samr_UserInfo union in password set test
If init_samr_CryptPasswordAES() does not fill the
u.info31.password.auth_data array completely, we may be comparing
uninitialised bytes.
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit f9850c776f81d596ffbd2761c85fe7a72d369bae
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 15:19:02 2022 +1200
lib:crypto: Zero auth_tag array in encryption test
If samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt() does not fill the
array completely, we may be comparing uninitialised bytes.
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 6932ccf3ccffbd9ab1907c4fb39b46c971e88d49
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date: Tue Aug 2 14:01:59 2022 +1200
s3:rpc_server: Fix typo in error message
Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/crypto/gnutls_aead_aes_256_cbc_hmac_sha512.c | 14 +-
lib/crypto/py_crypto.c | 321 +++
.../test_gnutls_aead_aes_256_cbc_hmac_sha512.c | 2 +-
lib/crypto/wscript | 2 +-
lib/util/talloc_keep_secret.c | 15 +-
libcli/auth/smbencrypt.c | 2 +
python/samba/tests/krb5/lockout_tests.py | 1088 ++++++++
python/samba/tests/krb5/raw_testcase.py | 10 +-
python/samba/tests/krb5/rfc4120_constants.py | 1 +
python/samba/tests/usage.py | 1 +
selftest/knownfail_mit_kdc | 10 +
selftest/tests.py | 2 +
source3/auth/check_samsec.c | 77 +
source3/rpc_server/samr/srv_samr_chgpasswd.c | 119 +-
source3/rpc_server/samr/srv_samr_nt.c | 149 +-
source3/rpc_server/samr/srv_samr_util.h | 8 +-
source4/auth/ntlm/auth_sam.c | 6 +-
source4/auth/ntlm/auth_winbind.c | 5 +-
source4/auth/sam.c | 707 ++++-
source4/auth/tests/sam.c | 2746 ++++++++++++++++++++
source4/auth/wscript_build | 11 +
source4/dsdb/common/util.c | 57 +-
source4/dsdb/samdb/ldb_modules/password_hash.c | 62 +-
source4/kdc/hdb-samba4.c | 51 +-
source4/rpc_server/samr/dcesrv_samr.c | 9 +-
source4/rpc_server/samr/samr_password.c | 159 +-
source4/selftest/tests.py | 7 +
source4/torture/rpc/samr.c | 2 +
28 files changed, 5368 insertions(+), 275 deletions(-)
create mode 100755 python/samba/tests/krb5/lockout_tests.py
create mode 100644 source4/auth/tests/sam.c
Changeset truncated at 500 lines:
diff --git a/lib/crypto/gnutls_aead_aes_256_cbc_hmac_sha512.c b/lib/crypto/gnutls_aead_aes_256_cbc_hmac_sha512.c
index a05aa8a323c..e0877a03f52 100644
--- a/lib/crypto/gnutls_aead_aes_256_cbc_hmac_sha512.c
+++ b/lib/crypto/gnutls_aead_aes_256_cbc_hmac_sha512.c
@@ -124,6 +124,14 @@ samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt(TALLOC_CTX *mem_ctx,
* TODO: Use gnutls_cipher_encrypt3()
*/
+ if (hmac_size > 64) {
+ /*
+ * We don't want to overflow 'pauth_tag', which is 64 bytes in
+ * size.
+ */
+ return NT_STATUS_INVALID_BUFFER_SIZE;
+ }
+
if (plaintext->length + aes_block_size < plaintext->length) {
return NT_STATUS_INVALID_BUFFER_SIZE;
}
@@ -274,7 +282,7 @@ samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt(TALLOC_CTX *mem_ctx,
uint8_t padding;
size_t i;
NTSTATUS status;
- int cmp;
+ bool equal;
int rc;
if (cdk->length == 0 || ciphertext->length == 0 ||
@@ -325,8 +333,8 @@ samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt(TALLOC_CTX *mem_ctx,
}
gnutls_hmac_deinit(hmac_hnd, auth_data);
- cmp = memcmp(auth_data, auth_tag, sizeof(auth_data));
- if (cmp != 0) {
+ equal = mem_equal_const_time(auth_data, auth_tag, sizeof(auth_data));
+ if (!equal) {
return NT_STATUS_DECRYPTION_FAILED;
}
diff --git a/lib/crypto/py_crypto.c b/lib/crypto/py_crypto.c
index ad18d3ada0f..11659556884 100644
--- a/lib/crypto/py_crypto.c
+++ b/lib/crypto/py_crypto.c
@@ -25,6 +25,53 @@
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include "lib/crypto/gnutls_helpers.h"
+#include "lib/crypto/md4.h"
+#include "libcli/auth/libcli_auth.h"
+#include "libcli/util/pyerrors.h"
+
+#ifdef HAVE_GNUTLS_PBKDF2
+static bool samba_gnutls_datum_from_PyObject(PyObject *py_obj,
+ gnutls_datum_t *datum)
+{
+ uint8_t *data = NULL;
+ Py_ssize_t size;
+
+ int ret;
+
+ ret = PyBytes_AsStringAndSize(py_obj,
+ (char **)&data,
+ &size);
+ if (ret != 0) {
+ return false;
+ }
+
+ datum->data = data;
+ datum->size = size;
+
+ return true;
+}
+#endif /* HAVE_GNUTLS_PBKDF2 */
+
+static bool samba_DATA_BLOB_from_PyObject(PyObject *py_obj,
+ DATA_BLOB *blob)
+{
+ uint8_t *data = NULL;
+ Py_ssize_t size;
+
+ int ret;
+
+ ret = PyBytes_AsStringAndSize(py_obj,
+ (char **)&data,
+ &size);
+ if (ret != 0) {
+ return false;
+ }
+
+ blob->data = data;
+ blob->length = size;
+
+ return true;
+}
static PyObject *py_crypto_arcfour_crypt_blob(PyObject *module, PyObject *args)
{
@@ -100,13 +147,287 @@ static PyObject *py_crypto_set_strict_mode(PyObject *module)
Py_RETURN_NONE;
}
+static PyObject *py_crypto_des_crypt_blob_16(PyObject *self, PyObject *args)
+{
+ PyObject *py_data = NULL;
+ uint8_t *data = NULL;
+ Py_ssize_t data_size;
+
+ PyObject *py_key = NULL;
+ uint8_t *key = NULL;
+ Py_ssize_t key_size;
+
+ uint8_t result[16];
+
+ bool ok;
+ int ret;
+
+ ok = PyArg_ParseTuple(args, "SS",
+ &py_data, &py_key);
+ if (!ok) {
+ return NULL;
+ }
+
+ ret = PyBytes_AsStringAndSize(py_data,
+ (char **)&data,
+ &data_size);
+ if (ret != 0) {
+ return NULL;
+ }
+
+ ret = PyBytes_AsStringAndSize(py_key,
+ (char **)&key,
+ &key_size);
+ if (ret != 0) {
+ return NULL;
+ }
+
+ if (data_size != 16) {
+ return PyErr_Format(PyExc_ValueError,
+ "Expected data size of 16 bytes; got %zd",
+ data_size);
+ }
+
+ if (key_size != 14) {
+ return PyErr_Format(PyExc_ValueError,
+ "Expected key size of 14 bytes; got %zd",
+ key_size);
+ }
+
+ ret = des_crypt112_16(result, data, key,
+ SAMBA_GNUTLS_ENCRYPT);
+ if (ret != 0) {
+ return PyErr_Format(PyExc_RuntimeError,
+ "des_crypt112_16() failed: %d",
+ ret);
+ }
+
+ return PyBytes_FromStringAndSize((const char *)result,
+ sizeof(result));
+}
+
+static PyObject *py_crypto_md4_hash_blob(PyObject *self, PyObject *args)
+{
+ PyObject *py_data = NULL;
+ uint8_t *data = NULL;
+ Py_ssize_t data_size;
+
+ uint8_t result[16];
+
+ bool ok;
+ int ret;
+
+ ok = PyArg_ParseTuple(args, "S",
+ &py_data);
+ if (!ok) {
+ return NULL;
+ }
+
+ ret = PyBytes_AsStringAndSize(py_data,
+ (char **)&data,
+ &data_size);
+ if (ret != 0) {
+ return NULL;
+ }
+
+ mdfour(result, data, data_size);
+
+ return PyBytes_FromStringAndSize((const char *)result,
+ sizeof(result));
+}
+
+static PyObject *py_crypto_sha512_pbkdf2(PyObject *self, PyObject *args)
+{
+#ifdef HAVE_GNUTLS_PBKDF2
+ PyObject *py_key = NULL;
+ uint8_t *key = NULL;
+ gnutls_datum_t key_datum = {0};
+
+ PyObject *py_salt = NULL;
+ gnutls_datum_t salt_datum = {0};
+
+ uint8_t result[16];
+
+ unsigned iterations = 0;
+
+ bool ok;
+ int ret;
+ NTSTATUS status;
+
+ ok = PyArg_ParseTuple(args, "SSI",
+ &py_key, &py_salt, &iterations);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_gnutls_datum_from_PyObject(py_key, &key_datum);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_gnutls_datum_from_PyObject(py_salt, &salt_datum);
+ if (!ok) {
+ return NULL;
+ }
+
+ ret = gnutls_pbkdf2(GNUTLS_MAC_SHA512,
+ &key_datum,
+ &salt_datum,
+ iterations,
+ result,
+ sizeof(result));
+ BURN_DATA(key);
+ if (ret < 0) {
+ status = gnutls_error_to_ntstatus(ret, NT_STATUS_CRYPTO_SYSTEM_INVALID);
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ return PyBytes_FromStringAndSize((const char *)result,
+ sizeof(result));
+#else /* HAVE_GNUTLS_PBKDF2 */
+ PyErr_SetString(PyExc_NotImplementedError, "gnutls_pbkdf2() is not available");
+ return NULL;
+#endif /* HAVE_GNUTLS_PBKDF2 */
+}
+
+static PyObject *py_crypto_aead_aes_256_cbc_hmac_sha512_blob(PyObject *self, PyObject *args)
+{
+ TALLOC_CTX *ctx = NULL;
+
+ PyObject *py_ciphertext = NULL;
+ DATA_BLOB ciphertext_blob = {0};
+
+ PyObject *py_auth_data = NULL;
+ PyObject *py_result = NULL;
+
+ PyObject *py_plaintext = NULL;
+ DATA_BLOB plaintext_blob = {0};
+ PyObject *py_cek = NULL;
+ DATA_BLOB cek_blob = {0};
+ PyObject *py_key_salt = NULL;
+ DATA_BLOB key_salt_blob = {0};
+ PyObject *py_mac_salt = NULL;
+ DATA_BLOB mac_salt_blob = {0};
+ PyObject *py_iv = NULL;
+ DATA_BLOB iv_blob = {0};
+
+ uint8_t auth_data[64];
+
+ bool ok;
+ NTSTATUS status;
+
+ ok = PyArg_ParseTuple(args, "SSSSS",
+ &py_plaintext,
+ &py_cek,
+ &py_key_salt,
+ &py_mac_salt,
+ &py_iv);
+ if (!ok) {
+ return NULL;
+ }
+
+ /* Create data blobs from the contents of the function parameters. */
+
+ ok = samba_DATA_BLOB_from_PyObject(py_plaintext, &plaintext_blob);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_DATA_BLOB_from_PyObject(py_cek, &cek_blob);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_DATA_BLOB_from_PyObject(py_key_salt, &key_salt_blob);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_DATA_BLOB_from_PyObject(py_mac_salt, &mac_salt_blob);
+ if (!ok) {
+ return NULL;
+ }
+
+ ok = samba_DATA_BLOB_from_PyObject(py_iv, &iv_blob);
+ if (!ok) {
+ return NULL;
+ }
+
+ ctx = talloc_new(NULL);
+ if (ctx == NULL) {
+ return PyErr_NoMemory();
+ }
+
+ /* Encrypt the plaintext. */
+ status = samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt(ctx,
+ &plaintext_blob,
+ &cek_blob,
+ &key_salt_blob,
+ &mac_salt_blob,
+ &iv_blob,
+ &ciphertext_blob,
+ auth_data);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetNTSTATUS(status);
+ talloc_free(ctx);
+ return NULL;
+ }
+
+ /* Convert the output into Python 'bytes' objects. */
+ py_ciphertext = PyBytes_FromStringAndSize((const char *)ciphertext_blob.data,
+ ciphertext_blob.length);
+ talloc_free(ctx);
+ if (py_ciphertext == NULL) {
+ return NULL;
+ }
+ py_auth_data = PyBytes_FromStringAndSize((const char *)auth_data,
+ sizeof(auth_data));
+ if (py_auth_data == NULL) {
+ return NULL;
+ }
+
+ /* Steal ciphertext and auth_data into a new tuple. */
+ py_result = Py_BuildValue("(NN)", py_ciphertext, py_auth_data);
+
+ return py_result;
+}
+
+
+
static const char py_crypto_arcfour_crypt_blob_doc[] = "arcfour_crypt_blob(data, key)\n"
"Encrypt the data with RC4 algorithm using the key";
+static const char py_crypto_des_crypt_blob_16_doc[] = "des_crypt_blob_16(data, key) -> bytes\n"
+ "Encrypt the 16-byte data with DES using "
+ "the 14-byte key";
+
+static const char py_crypto_md4_hash_blob_doc[] = "md4_hash_blob(data) -> bytes\n"
+ "Hash the data with MD4 algorithm";
+
+static const char py_crypto_sha512_pbkdf2_doc[] = "sha512_pbkdf2(key, salt, iterations) -> bytes\n"
+ "Derive a key from an existing one with SHA512 "
+ "algorithm";
+
+static const char py_crypto_aead_aes_256_cbc_hmac_sha512_blob_doc[] =
+ "aead_aes_256_cbc_hmac_sha512_blob(plaintext, cek, key_salt, "
+ "mac_salt, iv) -> ciphertext, auth_data\n"
+ "Encrypt the plaintext with AES256 as specified in "
+ "[MS-SAMR] 3.2.2.4 AES Cipher Usage";
+
static PyMethodDef py_crypto_methods[] = {
{ "arcfour_crypt_blob", (PyCFunction)py_crypto_arcfour_crypt_blob, METH_VARARGS, py_crypto_arcfour_crypt_blob_doc },
{ "set_relax_mode", (PyCFunction)py_crypto_set_relax_mode, METH_NOARGS, "Set fips to relax mode" },
{ "set_strict_mode", (PyCFunction)py_crypto_set_strict_mode, METH_NOARGS, "Set fips to strict mode" },
+ { "des_crypt_blob_16", (PyCFunction)py_crypto_des_crypt_blob_16, METH_VARARGS, py_crypto_des_crypt_blob_16_doc },
+ { "md4_hash_blob", (PyCFunction)py_crypto_md4_hash_blob, METH_VARARGS, py_crypto_md4_hash_blob_doc },
+ { "sha512_pbkdf2", (PyCFunction)py_crypto_sha512_pbkdf2, METH_VARARGS, py_crypto_sha512_pbkdf2_doc },
+ {
+ "aead_aes_256_cbc_hmac_sha512_blob",
+ (PyCFunction)py_crypto_aead_aes_256_cbc_hmac_sha512_blob,
+ METH_VARARGS,
+ py_crypto_aead_aes_256_cbc_hmac_sha512_blob_doc
+ },
{0},
};
diff --git a/lib/crypto/tests/test_gnutls_aead_aes_256_cbc_hmac_sha512.c b/lib/crypto/tests/test_gnutls_aead_aes_256_cbc_hmac_sha512.c
index 51f125f42d6..bc6a191cd90 100644
--- a/lib/crypto/tests/test_gnutls_aead_aes_256_cbc_hmac_sha512.c
+++ b/lib/crypto/tests/test_gnutls_aead_aes_256_cbc_hmac_sha512.c
@@ -187,7 +187,7 @@ static void torture_encrypt(void **state)
.length = sizeof(salt_data),
};
DATA_BLOB ctext;
- uint8_t auth_tag[64];
+ uint8_t auth_tag[64] = {0};
assert_int_equal(iv.length, 16);
diff --git a/lib/crypto/wscript b/lib/crypto/wscript
index 78927437e37..acf5cb8e731 100644
--- a/lib/crypto/wscript
+++ b/lib/crypto/wscript
@@ -81,7 +81,7 @@ def build(bld):
bld.SAMBA_PYTHON('python_crypto',
source='py_crypto.c',
- deps='gnutls talloc',
+ deps='gnutls talloc LIBCLI_AUTH',
realname='samba/crypto.so')
bld.SAMBA_BINARY('test_gnutls_aead_aes_256_cbc_hmac_sha512',
diff --git a/lib/util/talloc_keep_secret.c b/lib/util/talloc_keep_secret.c
index 70d449b5f12..21048659e5d 100644
--- a/lib/util/talloc_keep_secret.c
+++ b/lib/util/talloc_keep_secret.c
@@ -22,13 +22,26 @@
static int talloc_keep_secret_destructor(void *ptr)
{
+ int ret;
size_t size = talloc_get_size(ptr);
if (unlikely(size == 0)) {
return 0;
}
- memset_s(ptr, size, 0, size);
+ ret = memset_s(ptr, size, 0, size);
+ if (unlikely(ret != 0)) {
+ char *msg = NULL;
+ int ret2;
+ ret2 = asprintf(&msg,
+ "talloc_keep_secret_destructor: memset_s() failed: %s",
+ strerror(ret));
+ if (ret2 != -1) {
+ smb_panic(msg);
+ } else {
+ smb_panic("talloc_keep_secret_destructor: memset_s() failed");
+ }
+ }
return 0;
}
diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c
index 7abf6613d80..8492202ea93 100644
--- a/libcli/auth/smbencrypt.c
+++ b/libcli/auth/smbencrypt.c
@@ -975,6 +975,7 @@ bool decode_pw_buffer(TALLOC_CTX *ctx,
DBG_ERR("Failed to convert incoming password\n");
return false;
}
+ talloc_keep_secret(*pp_new_pwrd);
#ifdef DEBUG_PASSWORD
DEBUG(100,("decode_pw_buffer: new_pwrd: "));
@@ -1067,6 +1068,7 @@ bool decode_pwd_string_from_buffer514(TALLOC_CTX *mem_ctx,
if (!ok) {
return false;
}
+ talloc_keep_secret(decoded_password->data);
return true;
}
diff --git a/python/samba/tests/krb5/lockout_tests.py b/python/samba/tests/krb5/lockout_tests.py
new file mode 100755
index 00000000000..e49e82a4bd5
--- /dev/null
+++ b/python/samba/tests/krb5/lockout_tests.py
@@ -0,0 +1,1088 @@
+#!/usr/bin/env python3
+# Unix SMB/CIFS implementation.
+# Copyright (C) Stefan Metzmacher 2020
+# Copyright (C) Catalyst.Net Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from concurrent import futures
+from enum import Enum
+from functools import partial
+from multiprocessing import Pipe
+import os
+import sys
+import time
+
+from cryptography.hazmat.backends import default_backend
+from cryptography.hazmat.primitives.ciphers.base import Cipher
+from cryptography.hazmat.primitives.ciphers import algorithms
+
--
Samba Shared Repository
More information about the samba-cvs
mailing list