SecretFS是一个以安全为重点的FUSE文件系统,为强化版的Linux、MacOS和FreeBSD中的应用程序密钥提供细粒度的访问控制。
项目描述
SecretFS是一个以安全为重点的FUSE文件系统,为强化版的Linux、MacOS和FreeBSD中的应用程序密钥提供细粒度的访问控制。它将现有的目录树镜像到只读的FUSE卷中,并根据用户定义的ACL(访问控制列表)授予或拒绝应用程序对文件的访问。保护密钥的逻辑由文件系统本身处理,无需更改应用程序的代码。
SecretFS的ACL可以限制对特定进程的访问,该进程以特定的命令行、作为特定的用户和/或组运行,并可选地在定义的时间限制内。它启用了这篇文章中强调的安全实践,该文章建议将应用程序密钥存储在临时挂载点上,仅在应用程序初始化时允许访问,这样在应用程序的运行时被攻击后,攻击者将无法获取密钥。
此外,SecretFS可以使用--disable-ls选项禁止列出目录并隐藏影子卷的内容。
安装
sudo pip install secretfs
(或者不使用sudo安装并将secretfs
脚本符号链接到root的$PATH中)- 找到已安装的
etc/secretfs.conf-example
文件,编辑以创建您的ACL并保存为/etc/secretfs.conf
先决条件
-
Python3
-
FUSE
Ubuntu:
sudo apt-get install fuse
OSX Homebrew:
brew install macfuse
创建ACL
ACL在/etc/secretfs.conf
中定义如下
# [rule_id] - any id or name of the ACL rule; must be unique
# path - path to the the secret, relative to the root directory specified at mount time
# process - full path to the process requesting access
# cmdline - full command line following the process executable;
# empty string or no value means empty command line
# user - uid or name of the user to grant access to;
# '*' means any user is allowed
# group - gid or name of the group to grant access to
# '*' means any group is allowed
# ttl - time since the process creation during which access will be granted, in seconds;
# 0 or no value means don't enforce the time limit
[app-foo-secret1-rule1]
path = secret1.txt
process = /usr/bin/foo
cmdline = secret1.txt
user = ubuntu
group = *
;ttl = 0 -- no time limit
[app-foo-secret2.pem]
path = subdir/secret2.txt
...
所有尝试访问secretfs卷上文件的尝试都将记录到/var/log/secretfs.log
(或在以--foreground
运行时记录到stdout)。在挂载SecretFS卷后,尝试从您的应用程序访问秘密;然后在日志中找到相应的条目,并使用捕获的信息创建ACL条目。重新启动SecretFS并再次尝试访问它以验证新的ACL规则导致匹配,并且访问如预期那样获得授权。
挂载
与任何基于FUSE的文件系统一样,挂载SecretFS有几种方法
-
从命令行
$ sudo secretfs <mountpoint> <directory containing secrets>
例如:
$ sudo secretfs /mnt/secrets /opt/secrets-store/
或者更明确地,使用Python
$ sudo python3 /path/to/secretfs.py /mnt/secrets /opt/secrets-store/
-
使用
mount.fuse
命令$ sudo mount.fuse secretfs#/mnt/secrets /opt/secrets-store/
或者更明确
$ sudo mount.fuse /path/to/secretfs.py#/mnt/secrets /opt/secrets-store/
调试
sudo python3 secretfs.py --verbose --foreground /mnt/secrets /opt/secrets-store/
-
/etc/fstab
条目secretfs#/mnt/secrets /opt/secrets-store/ fuse auto 0 0
或者更明确
/path/to/secretfs.py#/mnt/secrets /opt/secrets-store/ fuse auto 0 0
在fstab中指定命令行选项
secretfs#/mnt/secrets /opt/secrets-store/ fuse --disable-ls,--verbose 0 0
然后运行
sudo mount -a
来挂载,umount /mnt/secrets
来卸载
注意事项
请注意,捕获ACL进程路径可能并不直观。一个人可能以/usr/bin/python
启动他们的应用程序,但在secretfs访问日志中展开为类似于"/usr/local/Cellar/python@2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
的东西。这就是为什么审查日志是创建ACL的推荐方法。
对于命令行(ACL规则中的cmdline
)也适用相同的严格性。SecretFS会区分cat secret.txt
和cat ./secret.txt
。
在终端运行时,secretfs.py
通常会在Ctrl-C(或Command+C)时终止,并卸载其卷,除非资源正忙(例如,有一个活动的bash shell带有cd /mnt/secrets
)。在这种情况下,FUSE将静默忽略终止请求。只需cd退出挂载点目录,它应该可以正常卸载。
免责声明
SecretFS是一个实验性项目,尚未经过独立安全专家的评估。自行承担风险。root对所有秘密拥有完全访问权限,不能由SecretFS限制。尚未在FreeBSD上测试。
演示
(参见demo/ascii-demo.gif或在GitHub上查看)
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。
源代码分发
构建分发
secretfs-0.1.0.tar.gz的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 35906f4f798fa006ab5a977ae56af40cba3c876857aed0a28d85a811671f1a7b |
|
MD5 | e1d4ae7ddff5a135411bf59b5bd4f116 |
|
BLAKE2b-256 | c79be44ce528e9b167a91e99bdbe49cb686805239cac12962eac91c23fa6d50c |