New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New check for SQL logins with blank or Login as password #413

Open
PsPsam opened this Issue Mar 23, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@PsPsam
Copy link
Contributor

PsPsam commented Mar 23, 2018

New Check

This is a new check/question
Idea taken from SQL Assessment in azure
I would like a test for logins with no password and password same as username

What would you like to check?

The test should return the count of the result. So if all is good 0 would be returned.

---Detect SQL Logins with weak passwords

SELECT count(name)
FROM master.sys.sql_logins
WHERE PWDCOMPARE(name,password_hash)=1
GO

and

---Detect SQL Logins with blank passwords

SELECT count(name)
FROM master.sys.sql_logins
WHERE PWDCOMPARE('',password_hash)=1
GO

What should be configurable for the results of the check ?

If the test should run or not

What should be able to be excluded from being tested ?

Nothing

Additional information

I took a quick look at dbatools but saw no command that does this. So maybe it a command should be created there first for this?

@SQLDBAWithABeard

This comment has been minimized.

Copy link
Collaborator

SQLDBAWithABeard commented Mar 25, 2018

I like this test, do you know if this T-SQL will work on all versions of SQL Server?

@PsPsam

This comment has been minimized.

Copy link
Contributor

PsPsam commented Mar 25, 2018

Its from sql 2008 and up

https://docs.microsoft.com/en-us/sql/t-sql/functions/pwdcompare-transact-sql

I changed the t-sql to better align with pester test, but you can get more information. So im not sure if this should be a dbatool test function that we than can test agains in dbachecks

The origial t-sql is

---Detect SQL Logins with weak passwords 
SELECT SERVERPROPERTY('machinename') 
AS 'Server Name', 
ISNULL(SERVERPROPERTY ('instancename'), 
SERVERPROPERTY ('machinename')) AS 'Instance Name', 
name AS 'Login With Password Equal to Login Name' 
FROM master.sys.sql_logins 
WHERE PWDCOMPARE(name,password_hash)=1 
ORDER BY name 
GO

From azure

@SQLDBAWithABeard

This comment has been minimized.

Copy link
Collaborator

SQLDBAWithABeard commented Mar 26, 2018

I agree in principle that this can be added, we would need some logic to skip the test if the version is below 2008

@michalporeba

This comment has been minimized.

Copy link
Collaborator

michalporeba commented Apr 7, 2018

I was just wondering what is the value of including this function in dbatools rather than implementing it in dbachecks? especially the proposed implementation simply executes an t-sql code? Does it introduce unnecessary coupling? Would the Test-DbaLoginPassword ever get executed from dbatools directly?

@SQLDBAWithABeard

This comment has been minimized.

Copy link
Collaborator

SQLDBAWithABeard commented Apr 7, 2018

Yes it undoubtedly would and doing so will bring more capabilities than just checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment