TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Sandy – A tiny Sandbox to run untrusted code ️

64 点作者 craig超过 5 年前

6 条评论

q3k超过 5 年前
Any blacklist-based syscall filtering solution that aims to run untrusted code is bound to be doomed, as the surface of all possible syscalls and ways they can be exploited to bypass some policy is enormous.<p>Poignantly, the naive approach of &#x27;let&#x27;s just block read(2) to prevent file access&#x27; doesn&#x27;t work - there&#x27;s multiple ways to bypass simple read(2) filtering like this. The easiest that come to mind are:<p><pre><code> - using readv(2) - using sendfile(2) - sym&#x2F;hardlinks to bypass path checks, and the inherent TOCTOU exploits of further naive checks </code></pre> The same applies to any other policy you wish to implement, and for every one of those you need to consider the collection of all Linux syscalls and filter all of the relevant ones. There&#x27;s around 300 syscalls in Linux as of writing.<p>Not to mention typical newbie mistakes that this project makes: not following forks, not checking for 32-bit syscalls, etc.<p>gVisor [1] does this well - instead of filtering, it reimplements the logic for handling Linux syscalls in userspace (eg., is actually responsible for handing out FDs and other handles, presenting the filesystem to the user, etc).<p>[1] - <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;gvisor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;gvisor</a>
评论 #22034805 未加载
roryrjb超过 5 年前
I don&#x27;t think this really is what people might call a sandbox but it can optionally block or allow syscalls happening (in my mind only one aspect of a sandbox) and it looks like it&#x27;s interactive. I think this is great. OpenBSD has had great success with pledge and I have been experimenting with seccomp (via the libseccomp project) with both Node.js bindings and a cli in C for doing a very similar thing as Sandy (although not interactively, which is a nice touch).
评论 #22034096 未加载
评论 #22032706 未加载
minitech超过 5 年前
I’m not really familiar with ptrace, but does this<p><pre><code> if regs.Orig_rax == 0 { </code></pre> mean it only intercepts the read syscall? Seems like any security someone was hoping to provide with this could be bypassed entirely by accident (e.g. a script in a language that always uses readv).<p>Anyway if that <i>is</i> what it means you should probably not describe this as “to run untrusted code”.
评论 #22032998 未加载
评论 #22033644 未加载
cixter超过 5 年前
The coolest thing about this read is the idea of a free-beer.bounty lowkey CTF file in my home dir.
riyakhanna1983超过 5 年前
SandFS does not rely on PTRACE, but uses eBPF. No TOCTTOU races. <a href="https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;803890&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;803890&#x2F;</a>
emmelaich超过 5 年前
See also bubblewrap<p><a href="https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;containers&#x2F;bubblewrap</a>