moby / moby/profiles

The default seccomp policy is too strict on unshare()

Open
#24 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
12
Forks
16
Avg merge
14d 6h
Merged PRs (30d)
2

Description

The following trivial program should really work:

#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <errno.h>


int main()
{
	if (unshare(CLONE_FILES) == 0)
		printf("unshare(CLONE_FILES) worked\n");
	else
		printf("unshare(CLONE_FILES) failed with errno %d\n", errno);
	return 0;
}

I'm hitting this while running a software package that otherwise works fine.

I assume that somewhere in the stack, someone wanted to prevent containers from creating Linux namespaces. There is indeed quite a bit of attack surface against the Linux kernel exposed by allowing programs to create namespaces. But unshare(CLONE_FILES) does not create a namespace, and the Linux kernel does not require any permissions at all to unshare the file table. (And preventing clone from unsharing the file table would surely break almost every piece of software in existence!) Similarly, I think that unshare(CLONE_FS) should also be allowed.

If the maintainers agree, I'd be happy to submit a patch.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the default seccomp profile in this repository and reproduce the reported C program using unshare(CLONE_FILES), then compare its behavior with unshare(CLONE_FS). Check that the profile permits these file-table operations without broadly permitting namespace creation; done means the program succeeds while the intended namespace restrictions remain in place.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
operating-systems, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.