问题标签 [least-privilege]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net - 如何断言 SqlCommand 以尽可能低的权限运行?
我正在保护在 MS SQL 之上运行的 ASP.NET/MVC Web 应用程序。作为其中的一部分,我有不同的数据库连接来在网站上执行不同的事情。
编辑 - 当然,由 DBA 和 Ops 人员来决定如何访问数据以及如何托管应用程序,但是对于一个不够精细的应用程序,他们无能为力,无法为他们提供所需的控制把事情锁起来。
系统只使用存储过程,没有动态 SQL。一些存储过程会改变数据,因此我将它们称为使用概念上不同的连接,而不是用于仅读取的其他数据访问的连接。SQL 用户无权访问存储过程以外的任何其他数据库对象。帐户授权具有单独的连接。Web 应用程序的某些部分显示计费信息,网站的其他部分直接计费工作。似乎有办法将隔板放置到位,将概念上不同的东西分开。
我正在寻找一种集成测试的方法,我对所选择的特权并不过分慷慨。如果开发人员试图在代码中的错误位置使用错误的访问级别,我想要一种在构建服务器上引发异常的机制,即使错误是所选帐户实际上具有太多权限,这不会给出来自数据库的错误。
我一直在创建 IDbCommand 的实现,该实现将充当 IDbCommand 实例的工厂,基本上将使用两个不同的连接向后端发出相同的命令,这些连接使用在 SQL Server 中具有不同访问权限的不同主体,然后抛出 if较低的特权就足够了。
这种方法有两个问题
- 它几乎没有“优雅”或明显完美无瑕。我几乎没有考虑过它,它已经有很多代码了。我必须将所有发生在较低连接上的事情排队,然后在较高特权的连接上重播,这在它的工作方式上是不现实的,并且可能会导致其他代码出现奇怪的计时问题。我喜欢编写代码,但我也希望我的测试值得信赖且易于理解,并且不会引入一组新的复杂性,这些复杂性会使测试以与被测代码不同的方式变得脆弱。也许如果我完全复制所有工作和所有数据并运行单独的数据库,那么构建服务器脚本将是一场噩梦。
- 它几乎不能称为颗粒状。
当然,这是一个解决了的问题,只是因为运气不好或谷歌 fu 才避开了我几个小时的搜索?
windows - 没有网络访问权限的虚拟服务帐户,例如 NT AUTHORITY\LocalService
背景:我正在编写一项服务,并希望尽可能少地赋予它特权。
虚拟帐户(有时称为“虚拟服务帐户”)是Windows 7/2008R2 的新增功能,文档很少,它是自动管理的帐户,用于需要最低权限但在域环境中使用计算机身份访问网络的服务。
我的服务不需要网络访问,所以我使用 LocalService,但我不喜欢这样一个事实,即如果我授予对文件/等的访问权限,我会授予对作为该帐户运行的所有服务的访问权限。
我可以使用最低权限的帐户吗?
powershell - Just Enough Administration - 命令返回“未持有特权”。
我已经注册了一个 PowerShell 配置以供使用,但遇到了一些困难。希望实现一种配置,允许服务帐户远程进入服务器并重新启动它,而不允许它执行任何其他操作,自然 JEA 似乎是最合适的。我使用以下内容注册了配置:
注册成功,我可以使用“D7_APP_ServerRestart”组中包含的帐户进入会话。使用Get-Command
我所期望的结果,但是在运行Restart-Computer
返回的消息时解释了Privilege not held
我是否缺少设置过程的一部分?
注册EndPoint的服务器是2012R2
database - Restricted PostgreSQL permissions for web app
Goal
Create a database with three users and restrict their privileges (I'm just thinking out loud, so my user separation is also open to correction):
- Superuser - this user allows for the very initial provisioning of the database. Create the application database, create the other users, set their privileges. Default
postgres
superuser works for me, so this one is done. - Administrator - this user has access only to the database that was created during provisioning. Administrator can CRUD all data in all tables, and can also CRUD tables, etc. "Superuser for only this database" type of situation. When the application is being updated, the administrator is the user used by automated tooling to handle database migrations.
- App user - this user is ultimately the one who supports the web app's functionality. Note this has nothing to do with users on web pages etc - this is the user the server leverages to run queries, insert and remove data. I explicitly do not want this user to be able to modify permissions of anything, nor create/destroy tables or indices or anything structural.
What I've tried
First off, looking at the (generally excellent) PostgreSQL documentation, the page on Grant pretty much leaves me cross-eyed. After spending a few hours reading about PostgreSQL roles and privileges I'm generally confused. I think with a bit more work I'll be able to nail down what I want for the admin user, but I'm pretty stuck on the "app user". I've gotten about this far (naming and passwords are all just placeholders):
And here's where I get unsure. I feel like the answer I'm trying to avoid is "revoke everything by default then enumerate all the privileges you'll need at all the different levels on all the different objects". I'm trying to avoid that because I straight up don't know what I need there. If that ends up being the answer, then I'll just have to hunker down and read a bunch more, but generally when I start going down paths like that I've missed something.
Issues
How do I restrict privileges for app-user
so they are unable to modify any structural data (e.g. cannot add or destroy tables) but are able to connect and do anything with rows (row level security is not even on my radar). Is this general model of privileges not really in sync with what PostgreSQL expects? I feel like I'm missing something if I have to walk through every option on that "grant" page to accomplish something like this - whether it be my motivation for doing it in the first place or the means by which I'm going about it.
Context
I'm trying to build my first end-to-end web application. I've done enough general software development and web app development, now I'm trying to understand the pieces that I generally take for granted day to day. I'm trying to set up a PostgreSQL server while keeping the principle of least privilege in mind.
Side-quest
I haven't seen this done on web apps where I have simply joined the development team, although they're generally small and not heavily used. Does doing this actually accomplish anything? Does anyone have compelling reasons for why to do something like this, or why it's a bad or ineffective idea? My assumption was that if I ultimately ended up with a SQL injection vulnerability, this would mitigate the damage because the database user would have limited access. Is that misguided?
Neat articles I've found on the subject:
- http://www.ibm.com/developerworks/opensource/library/os-postgresecurity/index.html
- PDF WARNING: https://wiki.postgresql.org/images/d/d1/Managing_rights_in_postgresql.pdf
- https://www.digitalocean.com/community/tutorials/how-to-use-roles-and-manage-grant-permissions-in-postgresql-on-a-vps--2
- http://blog.2ndquadrant.com/auditing-users-and-roles-in-postgresql/
oauth-2.0 - 最低权限的身份服务器在 Azure 上无法正常工作
我正在尝试实现遵循 OAUTH2/OIDC 协议的架构。为了做到这一点,我有 STS(Identity Server v3 by minimumprivilege)、ASP.NET WebApi 和 ASP.NET MVC 应用程序用于客户端。我的目标是在 Azure 上托管 STS 和 REST 服务,以便不同的客户端可以将它们用作公共服务。到现在为止还挺好。在我决定添加一个使用重定向流之一的新客户端 - 授权代码流之前,一切似乎都运行顺利且完美。我想利用它提供的刷新令牌选项。我想为该客户提供短期访问令牌(10 分钟),并让他使用刷新令牌来获取新令牌。这就是它在代码中的样子:
STS:
Mvc 应用程序(客户端):
问题是,如果我将 STS 托管在 Azure 上,出于某种原因,如果我决定在访问令牌过期后 20 分钟或更长时间内使用刷新令牌,我会收到错误消息。不管我的刷新令牌生命周期是 15 天。
也就是STS生成的日志:
在我的本地计算机上运行的 STS 的相同情况按预期工作。我可以使用我的刷新令牌获取新令牌。
已解决: 问题确实是Fred Han - MSFT所指出的。我需要为我的刷新令牌实现持久存储。实现它真的很容易。我是这样做的:
身份服务器的 Startup.cs:
CustomRefreshTokenStore.cs
entity-framework - 实体框架最小权限原则
我正在阅读我的安全性并有一个一般性问题。在数据库中,用户应该被授予他们需要的唯一属性,即选择、读取、删除等。
当使用实体框架作为 ORM 时,我该如何实现呢?实体没有权限的概念。
谢谢
amazon-web-services - Spinnaker 用户授权和实例权限限制
我正在尝试使用 Spinnaker 烘焙 AMI 并将其部署到 AWS Auto Scaling Group。问题是,实例需要太多权限。如Spinnaker 博客文章中所述(即“在当今世界,让工具完全访问您的环境通常被视为不好的做法”),我想知道是否有办法限制 Spinnaker 实例权限,但仍允许用户将他们的应用程序部署到他们自己的集群中,例如,如果他们在 AWS 中被授权这样做。
当然,文档说您可以限制对应用程序的访问,但这是否足够?应用程序 A 的成员能否以某种方式(例如在管道阶段)利用 Spinnaker 的权限调用 AWS API?(因此能够修改应用程序 B 的集群)。假设已禁用对 Spinnaker 实例的 SSH 访问
winapi - 最小权限原则与用户界面权限隔离
这一直让我感到困惑。这是一个声明“最小特权原则”的声明,而另外一个声明声明使用 UIPI 来保护应用程序免受低完整性级别进程的影响。
作为一个应用程序,我可能不会做任何特权操作,但为了保护我的 UI(使用 UIPI),我将被迫将我的应用程序提升为高度完整性。
矛盾的。有人对此有更好的解释吗?
我知道它们之间的区别。我不是在寻找这些是什么。我正在研究如何在这些之间取得平衡。
例如,
我正在开发一个应用程序,我没有做任何特权操作,所以我的应用程序本身可以在低完整性级别下运行。因此,根据最低权限原则,我很乐意以低完整性级别执行我的应用程序。但是如果我以低完整性级别运行我的应用程序,我很容易受到 UIPI 的攻击。任何人都可以发送消息并引发 DOS 攻击。这让我想,我是否应该继续以高完整性启动我的应用程序,以便没有其他中等完整性应用程序可以攻击我的应用程序。但这违背了“最小特权原则”
amazon-web-services - 我可以从模板为 Cloudformation 堆栈自动创建 IAM 角色吗?
我被告知将我的 Cloudformation 限制为它需要的命令。带着一个角色。为了创建角色,我可以花费数月时间浏览我的模板来确定启动 EC2 实例实际上涉及 10 个不同的 IAM 项目(如创建标签、网络接口、卷等)并找出所有有问题的 ARN 等等我所有的资源。(因为这些资源还没有创建,我需要很多资源才能*
让这个角色下次有用。)
或者,有没有工具可以为我做到这一点?我想象提供我的模板和工具会消失并制作大部分角色。也许一些位来改变模板根据参数做事的地方。
或者,如果我在打开 Cloudtrail 的情况下创建堆栈,是否有工具可以将 cloudtrail 日志转换为策略文档?
或者有什么其他方法可以避免几个月的工作?
amazon-web-services - 我想使用权限边界实现以下目标
我有一个用户,我们称他为 ADMIN,现在我想给他 IAM 策略来创建用户,以及对特定存储桶的 s3 读写访问权限,仅此而已。
现在这个问题最重要的部分是我想限制这个范围,只有 ADMIN可以创建用户,而不是用户自己。
比如Admin创建用户1,用户2,用户3,现在这些用户不能自己创建用户,就像用户1应该不能创建用户4左右。此外,这些用户 1、2、3 应该只具有对特定 s3 存储桶的读写访问权限,就像管理员一样,没有其他权限。
我如何实现这一目标?