code-access-security

Code Access Security exception in restricted AppDomain

余生颓废 提交于 2021-01-27 13:43:33
问题 Goal : I need to run some code in an AppDomain with very limited permissions - it should have no access to anything at all fancy or unsafe, except for a few helper methods that I have defined elsewhere. What I've done : I'm creating a sandbox AppDomain with the required basic permissions, and creating a proxy object, which runs the code: static AppDomain CreateSandbox() { var e = new Evidence(); e.AddHostEvidence(new Zone(SecurityZone.Internet)); var ps = SecurityManager.GetStandardSandbox(e)

How can I implement ISerializable in .NET 4+ without violating inheritance security rules?

不问归期 提交于 2020-02-26 05:05:28
问题 Background: Noda Time contains many serializable structs. While I dislike binary serialization, we received many requests to support it, back in the 1.x timeline. We support it by implementing the ISerializable interface. We've received a recent issue report of Noda Time 2.x failing within .NET Fiddle. The same code using Noda Time 1.x works fine. The exception thrown is this: Inheritance security rules violated while overriding member: 'NodaTime.Duration.System.Runtime.Serialization

How can I implement ISerializable in .NET 4+ without violating inheritance security rules?

廉价感情. 提交于 2020-02-26 05:05:28
问题 Background: Noda Time contains many serializable structs. While I dislike binary serialization, we received many requests to support it, back in the 1.x timeline. We support it by implementing the ISerializable interface. We've received a recent issue report of Noda Time 2.x failing within .NET Fiddle. The same code using Noda Time 1.x works fine. The exception thrown is this: Inheritance security rules violated while overriding member: 'NodaTime.Duration.System.Runtime.Serialization

Using the .NET Framework security system

蹲街弑〆低调 提交于 2020-01-13 05:22:07
问题 I was wondering - do any of you actually use the various classes in the System.Security.Permissions namespace? I mainly develop desktop/server-side components (i.e., no web) and the general assumption is that FullTrust is always available and no testing is performed on environments for which this is not the case. Apart from MS source code (EnterpriseLibrary and such), I have yet to see actual, in-use source code that makes use of said constructs. Is this prevalent, or are we the exception? I

Anyone really using Code Access Security to protect their assemblies and/or methods?

笑着哭i 提交于 2020-01-02 06:12:10
问题 Seems to me most of developers completely ignore this features. People prefer handling security exceptions as generic ones relying on standard windows roles and rights instead of learning to use CAS ways of enhancing security - probably because CAS is quite confusing in its logic and naming. Can anyone suggest any general rule-of-thumb/best practices for using CAS at his best in a clean way? 回答1: Yes and no. Unfortunately, you're right - developers rarely use CAS at all, let alone utilize it

.NET/Security: Limiting runtime-loaded assemblies from accessing certain APIs

纵饮孤独 提交于 2020-01-01 12:24:12
问题 In a shell application, I need to be able to load and execute other .NET assemblies at runtime, but without giving them full trust. Essentially, I want to limit them (the loaded assemblies) from touching any system resources (threading, networking, etc), with the only exception being isolated storage. However, assemblies which are from "me" need to be executed with full trust. I've been considering Code Access Security, but I'm not quite sure it's what I should use. How would you go about

securing the source code in a node-webkit desktop application

安稳与你 提交于 2019-12-20 10:14:09
问题 first things first , i have seen nwsnapshot. and its not helping. i am building an inventory management system as a desktop app using node-webkit . the project being built is using compoundjs (mvc javascript library). which have a definite folder structure (you know mvc) and multiple javascript files inside them. the problem is nwsnapshot allows the app to have only a single snapshot file but the logic of application is spread over all the folders in different javascript files. so how do i

Looking for a practical approach to sandboxing .NET plugins

≯℡__Kan透↙ 提交于 2019-12-17 08:01:22
问题 I am looking for a simple and secure way to access plugins from a .NET application. Although I imagine that this is a very common requirement, I am struggling to find anything that meets all my needs: The host application will discover and load its plugin assemblies at runtime Plugins will be created by unknown 3rd parties, so they must be sandboxed to prevent them from executing malicious code A common interop assembly will contain types that are referenced by both the host and its plugins

C# secure connection info for MYSQL

我是研究僧i 提交于 2019-12-13 21:04:07
问题 I'm about to release a small tool which uses a database connection for storing data. The question is: How can I prevent people reverse engineering my code and getting the Username and Password to gain access to the database? For earlier projects (which were used only by myself), I defined the connection-string just as a global variable inside my app. But that's highly unsafe as it only takes minutes to get this string out of the exe. Also a lot of methods to obfuscate code can be reversed. I

Do I need to worry about link-demands in a full-trust only .EXE?

好久不见. 提交于 2019-12-13 18:08:50
问题 I'm trying to understand FxCop CA2122 messages (probably before disabling the wretched things), and I have clearly overstepped my understanding of .NET CAS. The application is a .EXE, not marked with AllowPartiallyTrustedCallers. We get CA2122 warnings from Code Analysis, complaining about our failure to propagate LinkDemands upwards from the lowest level of calls to methods which themselves have LinkDemands. Obviously we can run around putting LinkDemands on callers, and then callers of