Archives for: "March 2014"

DISABLE and DENY LOGIN, DENY USER & Effect on Impersonation and Permissions

DISABLE und DENY LOGIN, DENY USER & Effekt auf Impersonierung und Berechtigungen

(de)
Ein kurzer Artikel zu den Effekten – oder fehlenden Effekten – in Bezug auf das Deaktivieren & Verbieten von Connect für Logins und Users auf Impersonierung und Berechtigungen.

(en)
A short article on the effects - or missing effects - regarding the disabling & denying connect of Logins & Users on impersonation and permission.

Immer mal wieder kann man beobachten, dass Logins oder Usern die Connect-Berechtigung verboten bekommen wurde, oder ein Login deaktiviert wurde.

Die richtige Erwartung und Verständnis kann daher kritisch sein.

Sehen wir uns also eine einfache Demo an:
Wir werden das eingebaute sa-Konto, welches von vielen unter anderem als Datenbankbesitzer (mehr dazu bald in einem anderen Artikel – zwischenzeitlich lade ich Sie dazu ein, noch Daten zu der Umfrage zu diesem Thema einzusenden), ein weiteres frisch angelegtes Konto und eine Datenbank, genannt ImpersonateLogin mit dem entsprechenden User + einem weiteren User ohne Login: SQLUser.

Every once in a while one can observe that Logins or Users have been denied the Connect permission or a Login has been disabled.

Therefore a correct expectation and understanding can be critical.

So let’s see a simple demo:
We will use the built-in sa-Account, which is used by many as database owner among other (more on that soon in another article - meanwhile I do invite you to still send in data for the survey on that topic), another freshly created Account DeniedLogin and a database called ImpersonateLogin with the according User + another User without Login: SQLUser.

 DisabledPrincipals_Script

Ich deaktiviere also das sa-Konto ebenso wie das „DeniedLogin“-Konto – letzterem verbiete ich außerdem die Connect-Berechtigung (Erinnern wir uns daran: „Berechtigungen können nicht für sa, dbo, Entitäts-Besitzer, information_schema, sys oder für den Benutzer selbst erteilt, verweigert oder aufgehoben werden.“)

Der Datenbank-User „SQLUser“ bekommt die Connect-Berechtigung auf die Datenbank verboten.
In der GUI sieht das Ergebnis so aus:

So I am disabling the sa-account as well as the “DeniedLogin”-Account – the latter I also Deny the Connect permission (Remember we “Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.”)

The Database-User “SQLUser” gets denied the Connect permission on the database.

In the GUI the result looks like this:

 DisabledPrincipals_Setup_Disabled_Login

DisabledPrincipals_Setup_Disabled_sa

Nun führen wir 4 Tests durch:

Now let’s run 4 tests.

 DisabledPrincipals_Test1

Was diese Abfragen im Wesentlichen machen, ist, zu versuchen, den entsprechenden Login oder User zu impersonieren – und den Erfolg dadurch belegen, dass sie die dann jeweils aktiven Rollen-Mitgliedschaften zurückgeben.
Ergebnisse:

So essentially what those queries do, is trying to impersonate the respective Login or User – and proofing success by returning the then respective active role-memberships.

Results:

 DisabledPrincipals_Result

DeniedLogin: Impersonierung funktioniert + kein Verlust an Berechtigungen.
In other words: Denying Connect to a Login does not disallow Impersonation.
Impersonation is actually another permission which one can use and is not affected even by Disabling the Login!

DeniedLogin: Impersonation works + No loss of permissions.
In other words: Denying Connect to a Login does not disallow Impersonation.
Impersonation is actually another permission which one can use and is not affected even by Disabling the Login!

 DisabledPrincipals_Result

Dasselbe gilt für den sa: Impersonierung funktioniert + kein Verlust a Berechtigungen.

Im Folgenden ein Test für den User, dem die Connect-Berechtigung auf die Datenbank entzogen worden ist – und nicht als Login verwendet werden kann.

Same applies for sa: Impersonation works + No loss of permissions.

In the following test for the User which has been denied the Connect-permission onto the database – and cannot be used as a Login.

 DisabledPrincipals_Test2

Ergebnisse:

Msg 15517, Level 16, State 1, Line 3

Die Ausführung als Datenbankprinzipal ist nicht möglich, weil der Prinzipal 'DeniedLogin' nicht vorhanden ist,
für diesen Typ von Prinzipal kein Identitätswechsel möglich ist, oder Sie nicht die erforderliche Berechtigung haben.

 

Msg 916, Level 14, State 1, Line 3

Der Serverprinzipal 'S-1-9-3-4049223906-1289824279-1154161590-488313048.'
kann unter dem aktuellen Sicherheitskontext nicht auf die ImpersonateLogin-Datenbank zugreifen.

Results:

Msg 15517, Level 16, State 1, Line 3

Cannot execute as the database principal because the principal "DeniedLogin" does not exist,
this type of principal cannot be impersonated, or you do not have permission.

 

Msg 916, Level 14, State 1, Line 3

The server principal "S-1-9-3-4049223906-1289824279-1154161590-488313048."
is not able to access the database "ImpersonateLogin" under the current security context.

 

Das Ergebnis ist für beide Datenbank-User effektiv das gleiche.

Die GUID repräsentiert keinen reellen Server-Prinzipal, denn der User SQLUser hat keinen entsprechenden Login.
Daher sagt es uns, dass die User nicht innerhalb der Datenbank impersoniert werden können.

Der Unterschied für den 2. User ist, dass dieser User nur innerhalb der Datenbank existiert, aber zugleich expliziert verboten wurde, sich mit ihr zu verbinden Das hat im Endeffekt dasselbe Resultat, wie ihn zu deaktivieren – genau wie der Guest-User es ist.

The GUID does not represent a real server-principal, because the User SQLUser does not have a matching Login.
So it tells us, that the users cannot be impersonated inside the database.

The difference for the second user is, that this user only exists inside the database but at the same time has been explicitly denied to connect to it. This has essentially the same result as “disabling” it – just as the guest-user is.

 

Damit wäre gezeigt, dass das Deaktivieren von Logins keinerlei Sicherheit gegenüber Angriffen von Innen gibt. Und sogenannte Privilegien Erweiterung findet in aller Regel z.B. von innen heraus statt.

Auch der alte „Trick“, die Standard-Datenbank des Logins zu löschen, ist da keine Hilfe.

Für Datenbank-User hat es durchaus Effekt und verhindert das Anmelden an der jeweiligen Datenbank – auch „von Innen heraus“.

 

Thereby it is shown, that disabling of Logins does not give any security against attacks from inside. And so-called privilege elevation (/-escalation) usually takes part from internal.

Also the old “trick”, to drop the default-database of a Login, is of little help.

For database-users is indeed does have an effect and prevents logon/connect to the respective database – also “from inside”.

 

Konsequenterweise bleiben alle Berechtigungen (natürlich abgesehen von dem jeweiligen Deny) der jeweiligen Logins und User absolut unbeeinflusst von einer Deaktivierung jeglicher Weise.

Das gilt auch im Zusammenhang mit „External Access“-Berechtigung für Logins basierend auf asymmetrischen Schlüsseln.
(Hier ein Forum-Thread, in dem die Frage auftauchte: “SQL Login "disabled" flag does not work with asymmetric key??”)

ALTER LOGIN ist auch hier in BOL erklärt: technet.microsoft.com/en-us/library/ms189828.aspx

 

Ich hoffe, diese Dinge erklären einiges und speziell Empfehlungen in Sicherheits-Aspekten.

Consequentially all permissions (besides the one denied of course) of the respective Login and User stay totally unaffected by and method of deactivation.

This is also true in the context of “external access”-permission for Logins based on asymmetric keys.
(Here a forum-thread where the question appeared: “SQL Login "disabled" flag does not work with asymmetric key??”)

ALTER LOGIN is also explained in BOL here: technet.microsoft.com/en-us/library/ms189828.aspx

 

I hope those things clarified some things and especially recommendations in security-matters

 

Happy securing

Andreas

Upcoming Conferences: SQLSaturdays in Denmark and Portugal. – Presenting In-Memory OLTP Deep-Dive for Administrators

 

(de)
Im März und April finden 2 europäischen SQLSaturdays statt, die Potential zu einem Geheimtipp haben:

Am 29. März in Kopenhagen, Dänemark
ind am 12. April in Lissabon, Portugal.

Da ich auch letztes Jahr bereits in Kopenhagen als Sprecher dabei war, kann ich aus erster Hand für die exzellente Organisation und Sprecherauswahl verbürgen.

Und für Portugal verbürgt mein sehr geschätzter Kollege Niko Neugebauer (Blog, Twitter:@NikoNeugebauer) – nach allem, was bisher „geleaked“ ist, wird es wieder ein Kongeniales Event. Würdig der ersten SQLSaturday-Location in Europa überhaupt.

(en)
In March and April, 2 European SQLSaturdays take place, which have the potential for a real insiders’ tip:

On March 29th in Copenhagen, Denmark
and April 12th in Lisbon, Portugal.

Since I already participated as a speaker in Copenhagen last year, I can avouch from “insider information” for the excellent organization and speaker choice.

And my much valued collegue Niko Neugebauer (Blog, Twitter:@NikoNeugebauer) vouches for Portugal – after all what has “leaked” in th emeantine, it will be another congenial event. Condign to the first SQLSaturday-Location in Europe ever.

SQLSaturday275_Denmark

Ich möchte zumindest einige, mir persönlich bekannte Sprecher namentlich erwähnen, aber gleich betonen, dass auch alle anderen Sessions definitiv einen Blick Wert sind(!):

In Dänemark sind dabei:

Die vollständige Agenda befindet sich hier: www.sqlsaturday.com/275/schedule.aspx

I would like to at least name some speakers, which I personally know, by name, but I would also like to stress immediately, that also all other sessions are definitely worth looking at just as well:

In Denmark there will be:

I am excited to see all of you again soon!

The complete Agenda can be found here: www.sqlsaturday.com/275/schedule.aspx

I am excited to see all of you again soon in Copenhagen!

SQLSaturday267_Portugal

In Portugal sind dabei:

Die vollständige Agenda befindet sich hier:

www.sqlsaturday.com/267/schedule.aspx

In Portugal there will be:

The complete Agenda can be found here: www.sqlsaturday.com/267/schedule.aspx

I am excited to see all of you again soon in Lisbon!

Und meine Wenigkeit, was präsentiere ich?
Nachdem ich mich nun seit November 2013, wo ich die neue Technologie in Deutschland erstmalig öffentlich präsentierte, eingehend mit eXtreme Transactional Processing, der neuen, integrierten, In-Memory Engine des SQL Server beschäftige, gibt es nun den Deep-Dive für Administratoren:

And my humble self, what am I presenting?
After I have been engaged deeply with eXtreme Transactional Processing, the new, integrated, In-Memory Engine of SQL Server, since November 2013, where I presented this new technology for the first time publically in Germany, I will now give a Deep-Dive for Administrators:

 

SQL Server 2014 In-Memory OLTP / XTP Management Deep Dive
@SQLSaturday Denmark & Portugal

You have heard about Hekaton, respectively the new acronym XTP (eXtreme Transactional Processing) and you want to know how it works under the cover? In this session we will take a closer look at the architecture, where the performance benefits come from and how it works in detail. What kind of files is SQL Server using for transactional consistency, what happens when you delete data inside the log and inside the data files. We will see the Merge-Process and the Garbage Collector in action, see how memory management works for XTP enabled databases, and thereby get an in-depth understanding of how this completely new storage engine works and how to optimize for it.

 

CU in Copenhagen, Lisbon.. or at another conference soon :-)

 

Andreas