{"id":878,"date":"2024-11-19T08:00:00","date_gmt":"2024-11-19T13:00:00","guid":{"rendered":"https:\/\/www.sqltabletalk.com\/?p=878"},"modified":"2024-11-15T22:55:53","modified_gmt":"2024-11-16T03:55:53","slug":"alternatives-to-trustworthy-sql-server","status":"publish","type":"post","link":"https:\/\/www.sqltabletalk.com\/?p=878","title":{"rendered":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In SQL Server, the <strong>TRUSTWORTHY<\/strong> database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using <code>WITH EXECUTE AS<\/code> or unsafe CLR assemblies. Enabling <strong>TRUSTWORTHY<\/strong> allows SQL Server to &#8220;trust&#8221; that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.<\/p>\n<p>In this blog, we\u2019ll dive into the purpose of the <strong>TRUSTWORTHY<\/strong> setting, examine potential security implications, and explore secure alternatives using certificate signing to control module access.<\/p>\n<h2>The Role of TRUSTWORTHY in SQL Server<\/h2>\n<p>The <strong>TRUSTWORTHY<\/strong> setting is a database property that allows SQL Server modules to inherit security context from the database level, granting permissions that might extend beyond the database\u2019s boundary. This feature is particularly useful when you need a stored procedure or assembly within a database to interact with other databases or require permissions at a server level.<\/p>\n<h3>Example Use Case:<\/h3>\n<p>Consider a scenario where you have a database, <strong>TrustyDB<\/strong>, that hosts a stored procedure requiring access to data in another database, <strong>FinanceDB<\/strong>. By setting <strong>TRUSTWORTHY<\/strong> to <code>ON<\/code> for <strong>TrustyDB<\/strong>, you can allow the stored procedure to interact with <strong>FinanceDB<\/strong> using elevated permissions.<\/p>\n<pre><code>USE TrustyDB;\nGO\n\nCREATE PROCEDURE dbo.usp_GetEmployeeSalary\nAS\nBEGIN\n    SELECT Salary FROM FinanceDB.dbo.EmployeeSalary;\nEND;<\/code><\/pre>\n<h2>Security Risks with TRUSTWORTHY<\/h2>\n<p>The <strong>TRUSTWORTHY<\/strong> setting broadens the permissions scope of the database, creating the potential for privilege escalation. For instance, if an attacker gains control over a user or module within a <strong>TRUSTWORTHY<\/strong>-enabled database, they may exploit these elevated permissions to access sensitive data or perform unauthorized actions across the SQL Server instance.<\/p>\n<p>Consider the following risks:<\/p>\n<ul>\n<li><strong>Privilege Escalation:<\/strong> Users with elevated permissions within a <strong>TRUSTWORTHY<\/strong> database can execute code across other databases or even access server-level resources.<\/li>\n<li><strong>CLR Assemblies:<\/strong> Unsafe CLR assemblies can be executed within the database, allowing potentially risky interactions with external systems.<\/li>\n<li><strong>Unauthorized Cross-Database Access:<\/strong> Modules can access data in other databases without explicit permissions, which could lead to data exposure.<\/li>\n<\/ul>\n<p>For these reasons, enabling <strong>TRUSTWORTHY<\/strong> should only be done as a last resort, after evaluating security requirements and considering alternative solutions.<\/p>\n<h2>Secure Alternatives to TRUSTWORTHY<\/h2>\n<p>The recommended alternative to using the <strong>TRUSTWORTHY<\/strong> setting is certificate signing. By signing specific modules with a certificate, you can grant only the required permissions to the exact code needing elevated access, all without needing to mark the entire database as <strong>TRUSTWORTHY<\/strong>.<\/p>\n<p>Using certificates provides these benefits:<\/p>\n<ul>\n<li><strong>Granular Permissions:<\/strong> Permissions are limited to specific modules.<\/li>\n<li><strong>Minimal Security Scope:<\/strong> Only the modules that truly need access are granted the necessary permissions.<\/li>\n<li><strong>Controlled Cross-Database Access:<\/strong> Certificates allow controlled permissions at the module level, reducing the risk of unintended privilege escalation.<\/li>\n<\/ul>\n<h3>Scenario 1: Executing a Cross-Database Query with Elevated Permissions<\/h3>\n<p>Let\u2019s say you have a stored procedure in <strong>TrustyDB<\/strong> that needs to access data in another database, <strong>FinanceDB<\/strong>. Instead of enabling <strong>TRUSTWORTHY<\/strong> on <strong>TrustyDB<\/strong>, you can use certificate signing to grant cross-database permissions only to the specific procedure.<\/p>\n<h4>Step-by-Step Solution<\/h4>\n<h5>Create the Stored Procedure in TrustyDB<\/h5>\n<p>This stored procedure queries <strong>FinanceDB.dbo.EmployeeSalary<\/strong> for sensitive data, requiring elevated cross-database permissions.<\/p>\n<pre><code>USE TrustyDB;\nGO\n\nCREATE PROCEDURE dbo.usp_GetEmployeeSalary\nAS\nBEGIN\n    SELECT Salary FROM FinanceDB.dbo.EmployeeSalary;\nEND;<\/code><\/pre>\n<h5>Create a Certificate in TrustyDB<\/h5>\n<p>Generate a certificate specifically for signing this stored procedure.<\/p>\n<pre><code>CREATE CERTIFICATE CertForCrossDbAccess\n    WITH SUBJECT = 'Access FinanceDB for salary data';<\/code><\/pre>\n<h5>Sign the Stored Procedure<\/h5>\n<p>Use the certificate to sign <code>usp_GetEmployeeSalary<\/code>.<\/p>\n<pre><code>ADD SIGNATURE TO dbo.usp_GetEmployeeSalary\n    BY CERTIFICATE CertForCrossDbAccess;<\/code><\/pre>\n<h5>Create a Login from the Certificate in the FinanceDB Database<\/h5>\n<p>Switch to the <strong>FinanceDB<\/strong> database.<\/p>\n<pre><code>USE FinanceDB;\nGO\n\nCREATE LOGIN CertLogin FROM CERTIFICATE CertForCrossDbAccess;\nGRANT SELECT ON dbo.EmployeeSalary TO CertLogin;<\/code><\/pre>\n<h5>Verify Cross-Database Access<\/h5>\n<p>Now, when <code>usp_GetEmployeeSalary<\/code> runs, it will execute with the permissions granted to <code>CertLogin<\/code>, allowing it to access <strong>FinanceDB<\/strong> without requiring the <strong>TRUSTWORTHY<\/strong> setting.<\/p>\n<h3>Scenario 2: Granting Elevated Server Permissions for a Diagnostic Procedure<\/h3>\n<p>Suppose you have a diagnostic stored procedure in <strong>TrustyDB<\/strong> that needs server-level permissions, like <code>VIEW SERVER STATE<\/code>, to retrieve performance metrics.<\/p>\n<h4>Create the Diagnostic Stored Procedure<\/h4>\n<pre><code>USE TrustyDB;\nGO\n\nCREATE PROCEDURE dbo.usp_ServerDiagnostics\nAS\nBEGIN\n    SELECT * FROM sys.dm_exec_requests;\nEND;<\/code><\/pre>\n<h4>Create a Certificate in TrustyDB and Sign the Procedure<\/h4>\n<pre><code>CREATE CERTIFICATE CertForDiagnostics\n    WITH SUBJECT = 'Diagnostics certificate';\nGO\n\nADD SIGNATURE TO dbo.usp_ServerDiagnostics\n    BY CERTIFICATE CertForDiagnostics;<\/code><\/pre>\n<h4>Create a Login in master and Assign Required Permissions<\/h4>\n<p>Use the certificate to create a login in the <strong>master<\/strong> database.<\/p>\n<pre><code>USE master;\nGO\n\nCREATE LOGIN CertLogin_Diagnostics FROM CERTIFICATE CertForDiagnostics;\nGRANT VIEW SERVER STATE TO CertLogin_Diagnostics;<\/code><\/pre>\n<p>Now, <code>usp_ServerDiagnostics<\/code> can execute <code>VIEW SERVER STATE<\/code> without requiring the <strong>TRUSTWORTHY<\/strong> setting on <strong>TrustyDB<\/strong>.<\/p>\n<h3>Scenario 3: Granting CLR Assembly Permissions with Certificate Signing<\/h3>\n<p>Let\u2019s say you have a CLR assembly in <strong>TrustyDB<\/strong> that requires <code>EXTERNAL_ACCESS<\/code> to interact with external files.<\/p>\n<h4>Deploy the CLR Assembly with EXTERNAL_ACCESS<\/h4>\n<p>Deploy the assembly, marking it as <code>EXTERNAL_ACCESS<\/code>.<\/p>\n<pre><code>CREATE ASSEMBLY MyExternalAssembly\nFROM 'C:\\path\\to\\assembly.dll'\nWITH PERMISSION_SET = EXTERNAL_ACCESS;<\/code><\/pre>\n<h4>Create a Certificate and Sign the Assembly<\/h4>\n<pre><code>CREATE CERTIFICATE CertForCLRAccess\n    WITH SUBJECT = 'Certificate for CLR EXTERNAL_ACCESS';\nGO\n\nADD SIGNATURE TO ASSEMBLY MyExternalAssembly\n    BY CERTIFICATE CertForCLRAccess;<\/code><\/pre>\n<h4>Create a Login from the Certificate in master and Grant Access<\/h4>\n<pre><code>USE master;\nGO\n\nCREATE LOGIN CertLogin_CLR FROM CERTIFICATE CertForCLRAccess;\nGRANT EXTERNAL ACCESS ASSEMBLY TO CertLogin_CLR;<\/code><\/pre>\n<p>This setup allows <strong>MyExternalAssembly<\/strong> to execute with <code>EXTERNAL_ACCESS<\/code> permissions without needing <strong>TRUSTWORTHY<\/strong> enabled on <strong>TrustyDB<\/strong>.<\/p>\n<h2>Additional Tips<\/h2>\n<ul>\n<li><strong>Periodic Certificate Renewal:<\/strong> Rotate certificates periodically to enhance security. Drop the old certificate and replace it with a new one.\n<pre><code>USE TrustyDB;\nDROP CERTIFICATE OldCertForAccess;\nCREATE CERTIFICATE NewCertForAccess WITH SUBJECT = 'Updated Certificate';<\/code><\/pre>\n<\/li>\n<li><strong>Auditing and Monitoring:<\/strong> Keep an eye on which modules have been signed and which certificates and logins are in place. Regularly audit permissions to ensure adherence to the principle of least privilege.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>The <strong>TRUSTWORTHY<\/strong> setting in SQL Server enables elevated permissions but comes with significant security risks. Instead of enabling <strong>TRUSTWORTHY<\/strong>, certificate signing provides a secure alternative that grants precise permissions to specific modules. By signing modules with certificates, you reduce the scope of potential misuse, making your SQL Server environment more secure. With these best practices, you can achieve elevated permissions where needed, without the security trade-offs that <strong>TRUSTWORTHY<\/strong> introduces.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to &#8220;trust&#8221; that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[132,35,82,29],"tags":[377,378,380,196,379,131,381,376],"class_list":["post-878","post","type-post","status-publish","format-standard","hentry","category-clr-integration","category-data-integrity","category-database-configuration","category-security","tag-certificate-signing","tag-clr-assemblies","tag-cross-database-access","tag-database-security","tag-permission-management","tag-sql-server","tag-sql-server-permissions","tag-trustworthy-setting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk<\/title>\n<meta name=\"description\" content=\"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to &quot;trust&quot; that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqltabletalk.com\/?p=878\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk\" \/>\n<meta property=\"og:description\" content=\"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to &quot;trust&quot; that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltabletalk.com\/?p=878\" \/>\n<meta property=\"og:site_name\" content=\"SQL Table Talk\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-19T13:00:00+00:00\" \/>\n<meta name=\"author\" content=\"Yvonne Vanslageren\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yvonne Vanslageren\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878\"},\"author\":{\"name\":\"Yvonne Vanslageren\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/68bb31b454bafe9e139183ed4f3e9082\"},\"headline\":\"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting\",\"datePublished\":\"2024-11-19T13:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878\"},\"wordCount\":832,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\"},\"keywords\":[\"Certificate Signing\",\"CLR Assemblies\",\"Cross-Database Access\",\"Database Security\",\"Permission Management\",\"SQL Server\",\"SQL Server Permissions\",\"TRUSTWORTHY Setting\"],\"articleSection\":[\"CLR Integration\",\"Data Integrity\",\"Database Configuration\",\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.sqltabletalk.com\/?p=878#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878\",\"url\":\"https:\/\/www.sqltabletalk.com\/?p=878\",\"name\":\"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#website\"},\"datePublished\":\"2024-11-19T13:00:00+00:00\",\"description\":\"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to \\\"trust\\\" that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltabletalk.com\/?p=878\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=878#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltabletalk.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#website\",\"url\":\"https:\/\/www.sqltabletalk.com\/\",\"name\":\"SQL Table Talk\",\"description\":\"Breaking Down SQL Server, One Post at a Time.\",\"publisher\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltabletalk.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\",\"name\":\"Stephen Planck\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g\",\"caption\":\"Stephen Planck\"},\"logo\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/dexterwiki.com\",\"https:\/\/www.linkedin.com\/in\/stephen-planck-4611b692?trk=people-guest_people_search-card&challengeId=AQErf8gbBmcVMwAAAYsyIsxO-0UvU8z7cHrBpZoo_n3xt9qEKpRN5B_jd_LmAMu-OfeArkQ7GDjobJ2uRoQQV35EQdh_rR6kxA&submissionId=09de7067-c335-8e17-40b8-8dc32b60ed6c&challengeSource=AgEcUCw35zpPmAAAAYsyI4vAWhJTV7Nt4vZYKc3V1qiDBpCkKgUvtlOBgYXcE84&challegeType=AgE_wZiTT09IAQAAAYsyI4vDmNvbZIYe6XHju5V2bXVvM3IVxnJslgY&memberId=AgESFTkUShzs_gAAAYsyI4vGYk0Gic1uc5kB6cKOABA26Gw&recognizeDevice=AgHdSZyUSI5CEwAAAYsyI4vKd_koF9JgpsCJShT8QfbK1QMiv8SI\",\"https:\/\/www.youtube.com\/linuxmate\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/68bb31b454bafe9e139183ed4f3e9082\",\"name\":\"Yvonne Vanslageren\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/22c274a7a354b81a0a8dc5b23e8e0be9bdd81a6bc0541474cfb6b954d6bb2089?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/22c274a7a354b81a0a8dc5b23e8e0be9bdd81a6bc0541474cfb6b954d6bb2089?s=96&d=mm&r=g\",\"caption\":\"Yvonne Vanslageren\"},\"url\":\"https:\/\/www.sqltabletalk.com\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk","description":"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to \"trust\" that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqltabletalk.com\/?p=878","og_locale":"en_US","og_type":"article","og_title":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk","og_description":"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to \"trust\" that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.","og_url":"https:\/\/www.sqltabletalk.com\/?p=878","og_site_name":"SQL Table Talk","article_published_time":"2024-11-19T13:00:00+00:00","author":"Yvonne Vanslageren","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Yvonne Vanslageren","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqltabletalk.com\/?p=878#article","isPartOf":{"@id":"https:\/\/www.sqltabletalk.com\/?p=878"},"author":{"name":"Yvonne Vanslageren","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/68bb31b454bafe9e139183ed4f3e9082"},"headline":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting","datePublished":"2024-11-19T13:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqltabletalk.com\/?p=878"},"wordCount":832,"commentCount":0,"publisher":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0"},"keywords":["Certificate Signing","CLR Assemblies","Cross-Database Access","Database Security","Permission Management","SQL Server","SQL Server Permissions","TRUSTWORTHY Setting"],"articleSection":["CLR Integration","Data Integrity","Database Configuration","Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sqltabletalk.com\/?p=878#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sqltabletalk.com\/?p=878","url":"https:\/\/www.sqltabletalk.com\/?p=878","name":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting - SQL Table Talk","isPartOf":{"@id":"https:\/\/www.sqltabletalk.com\/#website"},"datePublished":"2024-11-19T13:00:00+00:00","description":"In SQL Server, the TRUSTWORTHY database setting can grant elevated permissions across a database boundary, influencing how certain modules execute, particularly those using WITH EXECUTE AS or unsafe CLR assemblies. Enabling TRUSTWORTHY allows SQL Server to \"trust\" that the database owner and associated users won\u2019t misuse elevated permissions to perform unauthorized actions. However, this setting comes with significant security risks if used improperly.","breadcrumb":{"@id":"https:\/\/www.sqltabletalk.com\/?p=878#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltabletalk.com\/?p=878"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltabletalk.com\/?p=878#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltabletalk.com\/"},{"@type":"ListItem","position":2,"name":"Understanding SQL Server\u2019s TRUSTWORTHY Database Setting"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltabletalk.com\/#website","url":"https:\/\/www.sqltabletalk.com\/","name":"SQL Table Talk","description":"Breaking Down SQL Server, One Post at a Time.","publisher":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltabletalk.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0","name":"Stephen Planck","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g","caption":"Stephen Planck"},"logo":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/dexterwiki.com","https:\/\/www.linkedin.com\/in\/stephen-planck-4611b692?trk=people-guest_people_search-card&challengeId=AQErf8gbBmcVMwAAAYsyIsxO-0UvU8z7cHrBpZoo_n3xt9qEKpRN5B_jd_LmAMu-OfeArkQ7GDjobJ2uRoQQV35EQdh_rR6kxA&submissionId=09de7067-c335-8e17-40b8-8dc32b60ed6c&challengeSource=AgEcUCw35zpPmAAAAYsyI4vAWhJTV7Nt4vZYKc3V1qiDBpCkKgUvtlOBgYXcE84&challegeType=AgE_wZiTT09IAQAAAYsyI4vDmNvbZIYe6XHju5V2bXVvM3IVxnJslgY&memberId=AgESFTkUShzs_gAAAYsyI4vGYk0Gic1uc5kB6cKOABA26Gw&recognizeDevice=AgHdSZyUSI5CEwAAAYsyI4vKd_koF9JgpsCJShT8QfbK1QMiv8SI","https:\/\/www.youtube.com\/linuxmate"]},{"@type":"Person","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/68bb31b454bafe9e139183ed4f3e9082","name":"Yvonne Vanslageren","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/22c274a7a354b81a0a8dc5b23e8e0be9bdd81a6bc0541474cfb6b954d6bb2089?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/22c274a7a354b81a0a8dc5b23e8e0be9bdd81a6bc0541474cfb6b954d6bb2089?s=96&d=mm&r=g","caption":"Yvonne Vanslageren"},"url":"https:\/\/www.sqltabletalk.com\/?author=2"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=878"}],"version-history":[{"count":3,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":884,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/878\/revisions\/884"}],"wp:attachment":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}