mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
CVE-2013-4496:Revert remainder of ce895609b0
Part of this was removed when ChangePasswordUser was unimplemented, but remove the remainder of this flawed commit. Fully check the password first, as extract_pw_from_buffer() already does a partial check of the password because it needs a correct old password to correctly decrypt the length. Andrew Bartlett Bug: https://bugzilla.samba.org/show_bug.cgi?id=10245 Change-Id: Ibccc4ada400b5f89a942d79c1a269b493e0adda6 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-on: https://gerrit.samba.org/38 Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Mar 13 15:06:35 CET 2014 on sn-devel-104
This commit is contained in:
parent
9f53b61f06
commit
48ffca0aca
@ -142,6 +142,9 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
|
||||
|
||||
E_deshash(new_pass, new_lm_hash);
|
||||
E_old_pw_hash(new_lm_hash, lm_pwd->hash, lm_verifier.hash);
|
||||
if (memcmp(lm_verifier.hash, r->in.hash->hash, 16) != 0) {
|
||||
return NT_STATUS_WRONG_PASSWORD;
|
||||
}
|
||||
|
||||
/* Connect to a SAMDB with user privileges for the password change */
|
||||
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
|
||||
@ -173,11 +176,6 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
|
||||
return status;
|
||||
}
|
||||
|
||||
if (memcmp(lm_verifier.hash, r->in.hash->hash, 16) != 0) {
|
||||
ldb_transaction_cancel(sam_ctx);
|
||||
return NT_STATUS_WRONG_PASSWORD;
|
||||
}
|
||||
|
||||
/* And this confirms it in a transaction commit */
|
||||
ret = ldb_transaction_commit(sam_ctx);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
@ -267,6 +265,41 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (r->in.nt_verifier == NULL) {
|
||||
status = NT_STATUS_WRONG_PASSWORD;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* check NT verifier */
|
||||
mdfour(new_nt_hash, new_password.data, new_password.length);
|
||||
|
||||
E_old_pw_hash(new_nt_hash, nt_pwd->hash, nt_verifier.hash);
|
||||
if (memcmp(nt_verifier.hash, r->in.nt_verifier->hash, 16) != 0) {
|
||||
status = NT_STATUS_WRONG_PASSWORD;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* check LM verifier (really not needed as we just checked the
|
||||
* much stronger NT hash, but the RPC-SAMR test checks for
|
||||
* this) */
|
||||
if (lm_pwd && r->in.lm_verifier != NULL) {
|
||||
char *new_pass;
|
||||
size_t converted_size = 0;
|
||||
|
||||
if (!convert_string_talloc_handle(mem_ctx, lpcfg_iconv_handle(dce_call->conn->dce_ctx->lp_ctx),
|
||||
CH_UTF16, CH_UNIX,
|
||||
(const char *)new_password.data,
|
||||
new_password.length,
|
||||
(void **)&new_pass, &converted_size)) {
|
||||
E_deshash(new_pass, new_lm_hash);
|
||||
E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash);
|
||||
if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) {
|
||||
status = NT_STATUS_WRONG_PASSWORD;
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Connect to a SAMDB with user privileges for the password change */
|
||||
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
|
||||
dce_call->conn->dce_ctx->lp_ctx,
|
||||
@ -297,38 +330,6 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* check NT verifier */
|
||||
mdfour(new_nt_hash, new_password.data, new_password.length);
|
||||
|
||||
E_old_pw_hash(new_nt_hash, nt_pwd->hash, nt_verifier.hash);
|
||||
if (memcmp(nt_verifier.hash, r->in.nt_verifier->hash, 16) != 0) {
|
||||
ldb_transaction_cancel(sam_ctx);
|
||||
status = NT_STATUS_WRONG_PASSWORD;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* check LM verifier (really not needed as we just checked the
|
||||
* much stronger NT hash, but the RPC-SAMR test checks for
|
||||
* this) */
|
||||
if (lm_pwd && r->in.lm_verifier != NULL) {
|
||||
char *new_pass;
|
||||
size_t converted_size = 0;
|
||||
|
||||
if (!convert_string_talloc_handle(mem_ctx, lpcfg_iconv_handle(dce_call->conn->dce_ctx->lp_ctx),
|
||||
CH_UTF16, CH_UNIX,
|
||||
(const char *)new_password.data,
|
||||
new_password.length,
|
||||
(void **)&new_pass, &converted_size)) {
|
||||
E_deshash(new_pass, new_lm_hash);
|
||||
E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash);
|
||||
if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) {
|
||||
ldb_transaction_cancel(sam_ctx);
|
||||
status = NT_STATUS_WRONG_PASSWORD;
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* And this confirms it in a transaction commit */
|
||||
ret = ldb_transaction_commit(sam_ctx);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user