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

  • SEARCH
  • Home
  • 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 3347038
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:22:28+00:00 2026-05-18T01:22:28+00:00

I have such piece of code: namespace NetHacking { interface IPlugin { void Execute(PluginData

  • 0

I have such piece of code:

namespace NetHacking
{
    interface IPlugin
    {
        void Execute(PluginData data);
    }

public class PluginData
{
    private readonly string ConstString = "Const data";

    public void Print()
    {
        Console.WriteLine(ConstString);
    }
}

[StructLayout(LayoutKind.Explicit)]
class ExternalPlugin : IPlugin
{
    internal class PluginHack
    {
        public string Text;
    }

    [FieldOffset(0)]
    private PluginData _original;
    [FieldOffset(0)]
    private PluginHack _hack;

    public void Execute(PluginData data)
    {
        _original = data;
        _hack.Text = "Hacking .NET";
    }
}

class Program
{
    static void Main(string[] args)
    {
        try
        {
            var data = new PluginData();
            var plugin = CreatePlugin();
            plugin.Execute(data);

            data.Print();
        }
        catch (Exception)
        {
            Console.WriteLine("Error!");
        }
        Console.WriteLine("End");
        Console.Read();
    }

    private static IPlugin CreatePlugin()
    {
        return new ExternalPlugin();
    }
}}

In the example above PluginData data contains readonly string ConstString string. In theory PluginData passed to Execute method in IPlugin should be used to initialize plugin. Unfortunately ExternalPlugin can overriding ConstString externally.

Is there a way to protect against that ?

  • 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-05-18T01:22:29+00:00Added an answer on May 18, 2026 at 1:22 am

    If you want to protect yourself against malicious plugins tampering with your application you should run them in their own AppDomain with limited permissions and communicate with the plugin via a well-defined interface. Do not give direct access to your program state to the plugin. Of course the plugin will still be able to modify its own copy of any data you send it, but your copy of the data will not be affected.

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

Sidebar

Related Questions

If I have a piece of code such as this: private void DoOperations(//method passed
I have such html piece of code: <ul class=myClass> <li><a href=url1.html>first link</a></li> <li><a href=url2.html>second
I have this piece of code in my Silverlight project: private void button1_Click(object sender,
I have this piece of code: @RequestMapping(value = /test.json, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public
I have such piece of code. I have 4 sets of checkboxes on a
I have the following piece of code which replaces template markers such as %POST_TITLE%
I have a piece of code that confuses me: sort(data, data+count, greater<int>() ); it
i have such code (copy paste from wiki). Its multiplication of those big numbers
I have such XML structure which was returned by SharePoint web services. <rs:data ItemCount=4
I have such code using (Image image = System.Drawing.Image.FromStream(sourceStream)) { Guid objGuid = image.FrameDimensionsList[0];

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.