Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go.mod: experimental integration of gomodjail (library sandbox) #4012

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Mar 17, 2025

https://github.com/AkihiroSuda/gomodjail

gomodjail imposes syscall restrictions on a specific set of Go modules (excepts ones that use unsafe pointers, reflections, etc.), so as to mitigate their potential vulnerabilities and supply chain attack vectors.

Usage:

gomodjail run --go-mod=./go.mod -- nerdctl run hello-world

or

gomodjail pack --go-mod=./go.mod /usr/local/bin/nerdctl
./nerdctl.gomodjail run hello-world

Hint: use git diff --word-diff for reviewing the changes in this commit

@AkihiroSuda AkihiroSuda force-pushed the gomodjail branch 2 times, most recently from 3ec186f to 295ee0f Compare March 17, 2025 18:03
@AkihiroSuda AkihiroSuda added this to the v2.x.x milestone Mar 18, 2025
@AkihiroSuda AkihiroSuda force-pushed the gomodjail branch 11 times, most recently from 98c3108 to 8587b52 Compare March 18, 2025 08:27
@@ -296,9 +313,10 @@ jobs:
fi
echo "WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622}" >> "$GITHUB_ENV"
- name: "Test (network driver=slirp4netns, port driver=builtin)"
run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} ${TEST_TARGET} /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} -e NERDCTL=${NERDCTL} ${TEST_TARGET} /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is not working because test-integration-rootless.sh does not propagate the env var across the SSH session)

@fahedouch
Copy link
Member

fahedouch commented Mar 18, 2025

@AkihiroSuda in the gomodjail project is there a plan to restrict specific system calls (e.g declarative configuration) for confined modules?

@AkihiroSuda
Copy link
Member Author

@AkihiroSuda in the gomodjail project is there a plan to restrict specific system calls (e.g declarative configuration) for confined modules?

Eventually we may have fine-grained policies, but practically just having "confined" and "unconfined" might be enough to avoid complicating it

https://github.com/AkihiroSuda/gomodjail

gomodjail imposes syscall restrictions on a specific set of Go modules (excepts ones that use unsafe pointers, reflections, etc.),
so as to mitigate their potential vulnerabilities and supply chain attack vectors.

Usage:
```
gomodjail run --go-mod=./go.mod -- nerdctl run hello-world
```

or

```
gomodjail pack --go-mod=./go.mod /usr/local/bin/nerdctl
./nerdctl.gomodjail run hello-world
```

Hint: use `git diff --word-diff` for reviewing the changes in this commit

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@@ -231,6 +236,24 @@ RUN ROOTLESSKIT_VERSION=${ROOTLESSKIT_VERSION/@BINARY}; \
tar xzf "${fname}" -C /out/bin && \
rm -f "${fname}" /out/bin/rootlesskit-docker-proxy && \
echo "- RootlessKit: ${ROOTLESSKIT_VERSION}" >> /out/share/doc/nerdctl-full/README.md
# makeself is needed by `gomodjail pack`.
# TODO: remove dependency on makeself https://github.com/AkihiroSuda/gomodjail/issues/31
Copy link
Member Author

@AkihiroSuda AkihiroSuda Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a blocker 😞

$ ./nerdctl.gomodjail --namespace=nerdctl-test info
Unrecognized flag : --namespace=nerdctl-test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to keep Alpine? https://github.com/containerd/nerdctl/blob/main/Dockerfile#L120-L123
Why not just use the build-base-debian everywhere? https://github.com/containerd/nerdctl/blob/main/Dockerfile#L56

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC static linking didn't work well with glibc, at least in the past.
Basically we should rather try to use Alpine (musl) for building the binaries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not build with CGO at all on alpine, though - (and whatever needs CGO is built on Debian - containerd and the rest, because they do need glibc anyhow).
So, the choice of libc is not relevant to make binaries and should not impact static in any way?
(also, you can build against musl on debian as well).

Anyhow, different discussion (can happen in #4021).

Will look into gomodjail and see if I can help with getting rid of makeself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, left an idea in

(The blocker is about the arg parser of makeself, not about any Alpine stuff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants