我可以允许我的程序运行脚本吗?

发布于 2024-11-18 16:56:11 字数 305 浏览 2 评论 0原文

一些用户建议我的(C#)程序应该能够在完成其工作后运行脚本。这可以通过在我的配置对话框中输入的命令行来完成。

我不是安全专家,所以我不确定这在安全方面是否可以接受。由于该应用程序以管理员权限运行(在 Windows 上),这难道不是一个巨大的安全风险吗?有人可以修改我的应用程序的配置文件以指向潜在危险的脚本,不是吗?

另一方面,很多应用程序允许这样做,同时请求管理员权限,所以我想这一定没问题,但我想我最好在到处打开广泛的安全漏洞之前寻求建议 =)

我可以允许我的应用程序运行吗具有启动用户指定脚本的完全权限?

Some users are suggesting that my (C#) program should be able to run scripts after completing it's job. This would be done through a command line to be input in my configuration dialog.

I'm no security expert, so I'm not sure if this acceptable in terms of security. Since the app runs with admin privileges (on Windows), wouldn't that be a huge security risk? Someone could just modify the config files of my application to point to a potentially dangerous script, couldn't they?

On the other hand, plenty of applications allow this, while requesting admin privileges, so I guess it must be ok, but I thought I'd better seek advice before opening wide security holes everywhere =)

Can I allow my application running with full privileges to launch user-specified scripts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泅渡 2024-11-25 16:56:11

您可以通过不同的方式限制对配置的访问 - 从混淆配置文件到使用 NTFS 权限来限制非管理员帐户对其的访问。

You can restrict access to your config in different ways - from obfuscating the config file to using NTFS permissions to limit access of non-admin accounts to it.

╰沐子 2024-11-25 16:56:11

C# 当然允许您运行用户脚本。 System.Diagnostics.Process 使这一切变得非常简单。这里的安全问题是另一个问题。

在进程完成时运行脚本可能非常有用,并且可以决定或破坏目标受众对应用程序的看法。可以理解的是,您不希望您的产品像您所想的那样通过恶意黑客攻击来对抗您自己的消费者。

这个问题的根源在于您的选项(我假设)基于文本并且易于编辑。最好的选择是加密您的配置文件以防止外部对其进行更改。请注意,这并不能阻止人们使用您的应用程序更改您的选项以允许恶意脚本,但如果有人要这样做,他们需要访问您的应用程序实例,而不仅仅是文件读/写访问权限。

这确实给你带来了另一个值得关注的问题。不要在每次安装应用程序时使用相同的密钥。如果您这样做,那么鲍勃可能会导致爱丽丝通过复制爱丽丝的配置来运行恶意脚本,使用他的应用程序实例对其进行解密并进行更改,然后鲍勃可以用新的恶意配置替换爱丽丝的配置。

这是另一个有关如何在 C# 中加密字符串的问题。

C# certainly allows you to run a user script. System.Diagnostics.Process makes that real easy. The question of security here is another problem.

Running scripts when a process completes can be an incredibly useful and can make or break your target audience's opinion of your application. Understandably, you don't want your product to be turned against your own consumers through a malicious hack like you're thinking.

The root of this problem is that your options are (I'm assuming) text based and easily editable. Your best bet is to encrypt your config file to prevent outside changes to it. Note that this doesn't prevent people from using your app to change your options to allow a malicious script, but for somebody to do that, they need access to an instance of your application instead of simply file read/write access.

This does bring to question one more aspect you should watch for. Don't use the same key for every installation of your application. If you do that, then Bob could cause Alice to run a malicious script by copying Alice's config, using his instance of your app to decrypt it and make the change and then Bob can replace Alice's config with the new malicious config.

Here is another SO question for how to encrypt strings in C#.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文