问题标签 [seccomp]
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.
c - 我加载了一个 seccomp 过滤器来禁止 fork(),但仍然可以毫无问题地使用 fork()
我正在尝试创建一个 seccomp 过滤器,它将 fork() 的使用列入黑名单。这是我的代码:
我这样编译:
然后运行得到以下输出:
暗示我能够成功 fork 并且 seccomp_add_rule 和 seccomp_load 运行成功。有人可以帮我理解我做错了什么吗?谢谢!
sandbox - 错误:未在此范围内声明“scmp_filter_ctx”
我收到编译错误:error: ‘scmp_filter_ctx’ was not declared in this scope
.
我已经声明了一个 seccomp 过滤器。
scmp_filter_ctx ctx;
我已包含该库#include <linux/seccomp.h>
并已libseccomp-dev
使用
sudo apt-get install libseccomp-dev
.
linux - 如何在 linux 中绕过 seccomp
即使一个进程使用 seccomp 并且仅限于退出、读取和写入,我仍然会造成伤害吗?如果可以,怎么可能利用这样的系统?
docker - 从 debian 8 升级到 debian 9 后 Docker seccomp 错误
从 Debian 8 升级到 Debian 9期间docker run
和之后会出现以下错误:docker build
在运行容器时,我能够解决问题,--seccomp-profile:unconfined
但 build 不支持此标志(https://github.com/moby/moby/issues/21105)。我也尝试通过 daemon.json 将它传递给守护进程,但这会在启动期间导致错误。
启用内核支持:
码头工人信息:
有谁知道如何解决它?非常感谢。
c - How to get the return code of the syscall using SECCOMP_RET_DATA and PTRACE_GETEVENTMSG
I'm a little bit confused trying to obtaining syscall's return value using ptrace + seccomp.
man 4 bpf says:
man 2 ptrace says:
man 2 seccomp says:
It turns out that the BPF program can not perform something further after the BPF_RET
statement. So when tracee is interrupted on SECCOMP_RET_TRACE
it's in the syscall-enter-stop
state and the syscall has not yet been made, therefore, the return code is definitely nowhere to take. I expect that after a subsequent call PTRACE_SYSCALL
, tracee will be in the syscall-exit-stop
state and tracer will be able to get the result of the syscall using PTRACE_GETEVENTMSG
. But it doesn't work in my sample.
I am able to get syscall's return code inspecting registers
but I wonder how to do it in the way specified in the documentation.
docker - 关于docker daemon如何初始化seccomp过滤器的问题
我阅读了moby项目的原始代码,并阅读了moby/profiles
文件夹中的seccomp代码。我知道 docker 使用 libseccomp-golang 来支持该功能。
我们通常使用libseccomp.NewFilter()
API 来创建 seccomp 过滤器。libseccomp.GetNativeArch()
但是,我看不到 libseccomp 中的任何 API 参与了该项目,除了
所以我想知道 docker 守护进程如何为每个容器初始化 seccomp 过滤器?如果我错了,请纠正我。
c - C SECCOMP 阻塞或关闭 STDIN/STDOUT
我现在正在实现在 fork 之后在子进程中运行另一个程序。
如上所示,我正在测试运行只是简单的“Hello world”的 C/Python/Java 程序。
我允许使用seccomp进行一些白名单系统调用。
Python 和 C 程序运行,它们的输出被重定向到文件。
在 Java 的情况下,子进程正常终止,但如果我加载seccomp ,输出就会消失。否则,我会看到“Hello World”消息。
谢谢你。
linux - 有没有办法在 exec.Start() 之后和命令开始之前加载 seccomp 过滤器
我正在使用 Go 代码作为模块编写一个简单的沙箱,我需要加载 seccomp 规则来限制命令的系统调用。
我曾经os/exec
运行该命令,但在命令真正启动之前我无论如何都找不到加载过滤器。
我发现 Docker 使用 fork 调用,它需要在程序中添加代码main
,但如果沙箱是一个模块,我认为这不是一个好方法。
在 C 语言中,我们可以像这样使用 seccomp:
在 Go 中,我不知道该怎么做。
英语不是我的第一语言。
c - 隐式引用 seccomp
问题: 我正在尝试使用 seccomp,但我不明白为什么 gcc 告诉我 seccomp() 函数调用具有隐式声明。
警告/错误:这是我尝试编译程序时的 gcc 输出。
问题:我还应该包括什么才能使它工作?
编辑:为什么这有效而第一个无效?
syscall(SYS_seccomp, SECCOMP_SET_MODE_FILTER, 0, &bpf)
privileges - 为什么 seccomp 需要 no_new_privs 位?理论利用的例子
我已经看到,在使用 seccomp 模式过滤器之前,您必须设置此位,因为它保证与父进程相比,子进程不能以更高的权限执行。但我仍然无法找出一个利用示例。你能给我看一个吗?
理论场景:我有一个程序可以在不设置 no_new_privs 位的情况下设置 seccomp 过滤模式。
目标:展示一个利用它的程序
此要求确保非特权进程无法应用恶意过滤器,然后使用 execve(2) 调用 set-user-ID 或其他特权程序,从而可能危及该程序。(例如,这样的恶意过滤器可能会导致尝试使用 setuid(2) 将调用者的用户 ID 设置为非零值,而不是在实际进行系统调用的情况下返回 0。因此,程序可能会被欺骗以保留超级用户权限在可能影响它做危险事情的情况下,因为它实际上并没有放弃特权。)