File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ RUN curl -fsSL https://gvisor.dev/archive.key | apt-key add - && \
27
27
COPY --from=build /src/analyze /usr/local/bin/analyze
28
28
COPY --from=build /src/worker /usr/local/bin/worker
29
29
COPY --from=build /src/tools/gvisor/runsc_compat.sh /usr/local/bin/runsc_compat.sh
30
+ COPY --from=build /src/tools/firewall/iptables.rules /usr/local/etc/iptables.rules
30
31
RUN chmod 755 /usr/local/bin/runsc_compat.sh
31
32
32
33
ARG SANDBOX_IMAGE_TAG
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ import (
16
16
const (
17
17
podmanBin = "podman"
18
18
runtimeBin = "/usr/local/bin/runsc_compat.sh"
19
+ iptablesLoadBin = "/usr/sbin/iptables-restore"
20
+ iptablesRules = "/usr/local/etc/iptables.rules"
19
21
rootDir = "/var/run/runsc"
20
22
straceFile = "runsc.log.boot"
21
23
hostname = "box"
@@ -165,6 +167,11 @@ func removeAllLogs() error {
165
167
return nil
166
168
}
167
169
170
+ func loadIptablesRules () error {
171
+ cmd := exec .Command (iptablesLoadBin , iptablesRules )
172
+ return cmd .Run ()
173
+ }
174
+
168
175
func podman (args ... string ) * exec.Cmd {
169
176
args = append ([]string {
170
177
"--cgroup-manager=cgroupfs" ,
@@ -263,6 +270,10 @@ func (s *podmanSandbox) init() error {
263
270
if s .container != "" {
264
271
return nil
265
272
}
273
+ // Load iptables rules to further isolate the sandbox
274
+ if err := loadIptablesRules (); err != nil {
275
+ return fmt .Errorf ("failed restoring iptables rules: %w" , err )
276
+ }
266
277
// Delete existing logs (if any).
267
278
if err := removeAllLogs (); err != nil {
268
279
return fmt .Errorf ("failed removing all logs: %w" , err )
Original file line number Diff line number Diff line change
1
+ # Create the chain used by podman networking for user-defined rules
2
+ *filter
3
+ :CNI-ADMIN - [0:0]
4
+ # Block access to metadata.google.internal/AWS metadata
5
+ -A CNI-ADMIN -d 169.254.169.254/32 -j DROP
6
+ COMMIT
You can’t perform that action at this time.
0 commit comments