Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:44:12+00:00 2026-06-05T12:44:12+00:00

I have an interface which implementing classes export via MEF in my application. The

  • 0

I have an interface which implementing classes export via MEF in my application. The implementing classes are in separate assemblies and aren’t known about at compile-time (think plug-ins).

The interface basically consists of a call which says ‘here is a bunch of key-value pairs, now initialise your licensing state’. I.e.

public LicensingInfo InitialiseLicense(IEnumerable<KeyValuePair<string, string>> keys)

What I would like to know is – is there any way of protecting that interface from a ‘middle man’ implementation? I.e. one that receives the call from my application, then calls the same method on the plug-in assembly with a different bunch of key-value pairs, basically saying ‘yes – here you go – have everything’.

I did try and think of it a different way, in that the application would call the plug-in assembly and pass in an object which could be queried. That method might look something like this:

public LicensingInfo InitialiseLicense(ILicenseQueryProvider provider)

However, again with this method I think that an intercepting object could just simply give a different provider to the library.

So, is there a way I could prevent such interface interception, or should I refactor it such that the plug-in assembly is entirely responsible for licence loading etc within it’s own code? Or is there another way, perhaps, that I could refactor it that I haven’t considered?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:44:14+00:00Added an answer on June 5, 2026 at 12:44 pm

    I believe you can make it harder to break, but not with an interface.

    Here’s what you do:

    You need 2 + n projects: one for the exe (let’s call it program.exe), one for the contracts (contracts.dll), and one for each of your n plugins (plugin.dll).

    program.exe has a hard reference to contracts.dll, as does plugin.dll.

    Sign all of them with a strong name key. See http://msdn.microsoft.com/en-us/library/xc31ft41.aspx

    Instead of an interface ILicenceQueryProvider, create a sealed class LicenceQueryProvider in contracts.dll. Make sure it has no public constructors, only an internal one, and no methods to modify the object (initialized on construction, immutable and with readonly fields).

    Mark contracts.dll with an InternalsVisibleToAttribute, granting program.exe access to the internal constructor. See http://msdn.microsoft.com/en-us/library/System.Runtime.CompilerServices.InternalsVisibleToAttribute.aspx

    This way, program.exe can call the constructor on this object, and plugin.dll can read from it.

    plugin.dll “knows” the object class has not been modified because of the strong name signature. And because it’s sealed, a man in the middle cannot substitute in another implementation.

    Now remember I said you can make it much harder to break, but it is not impossible and will never be, especially if you’re using managed code.

    For example, a man in the middle can use reflection to instantiate the object with the internal constructor.

    Even worse, in your plugin there is code that reads from this object, and makes a decision based on licence information. A hacker can decompile your plugin.dll to IL, and replace that code with code that always grants all privileges.

    Obfuscation would help just a little bit, but not against the reflection attack. Native code would make it somewhat more difficult, but native code can be patched too.

    Ultimately, the code is on the hacker’s machine, and the hacker can do what he wants. He can even run it under a debugger, and modify the data in memory. This is the problem that all copy protection and licencing mechanisms face. In my opinion, licences make it harder on your clients to use your software, and will not stop a determined hacker. Do you (or your company) want to make it hard on your clients to use your software?

    Now this doesn’t mean there is no solution. In fact there is: a hacker cannot modify code that is not on his machine. Have the code run on a server under your control. The client app accesses it through a web service. The web service authenticates the user (not the calling code, that is impossible). Knowing the user, the service can validate the user’s licence. This is the only solution.

    UPDATE

    Just to be clear: such a service needs to run the actual code that has value for the user, not just a licence check. In the latter case, a hacker could modify the client to simply not mke the call, or even substitute a fake licence server. However, the assumption is that a licence is cheaper than it is to recreate the actual logic living in the service. In that case, even hackers will prefer to buy over recreating the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Interface and two Classes which are implementing the Interface. public interface
We have an interface which will be implemented by classes that take care of
I am implementing more classes which extend the Serializable interface. I understood it is
Lets say we have a program which contains such classes: public interface AbstractItem {
I have an interface (say Employee) which has 2 classes that implements it (say
I have an interface named SHAPE . CIRCLE and RECTANGLE are two classes implementing
I have some classes implementing some computations which I have to optimize for different
In my ASP.NET MVC app, I have an interface which acts as the template
In COM, if I have an interface IBase and an interface IX which inherits
I have a generic interface IConstrained which is implemented by the generic Constrained class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.