Lock Down SQL Server 2005

The hard part about offering live exploitable holes is to block privilege escalation for malicious users. In my case I needed a locked down database where arbitrary SQL can't do any damage. And thus was born Lock Down SQL Server 2005, which teaches you a variety of techniques for hardening your whole MSSQL installation plus specific databases. It also has a world-accessible SQL Shell where you can experiment with a hardened database and attempt white-hat escalation.

Interestingly, we face a similar challenge in real-world production systems (as opposed to websites with kids' pictures :P ), where we must run bastard applications guaranteed to have security problems. Hardening our systems against them to achieve a secure whole despite the weak links is what Defense in Depth is all about.

I have posted some code along with the article, I hope the stuff is useful to other people. Try it out!

Comments

7 Responses to “Lock Down SQL Server 2005”

  1. Jeremy on April 4th, 2008 12:16 pm

    You can also get an full report on all your vulnerabilities and a report on all user permissions across all your servers by downloading this tool for free. http://www.idera.com/Products/SQLsecure/default.aspx

  2. Mehrdad on September 1st, 2008 7:27 am

    If you use sp_Executesql in your application or some extended stored procedure, after apply the “Restrict permissions on extended stored procedures” you should grant execute permission of them otherwise you will be get “execute permission denied” error…

  3. Harm on June 8th, 2009 5:59 am

    Hi, can LockDownSqlServer2005.sql be applied to MSSQL2008 aswell?

  4. Gustavo Duarte on June 8th, 2009 9:34 am

    Harm: I’m not sure yet, I haven’t worked much with 2008, though I hope to start soon.

  5. Howard Dinkins on October 2nd, 2009 6:56 am

    Can the changes made in the SQL Lockdown Script be removed and the old settings restored. If so what is the quickest way of acconplishing this? Thnaks.

  6. Brian on July 27th, 2010 7:27 am

    The link to “Lockdown SQL Server 2005″ is broken.

  7. Andreas Kuhn on April 29th, 2011 8:16 am

    The link to “Lockdown SQL Server 2005″ is still broken.

Leave a Reply