Debian Codegraph @

docs/onboarding.md

raw
1 ## Onboarding a program onto Landlock
2
3 When onboarding a program to use Landlock, first build a rough threat
4 model and analyze the list of inputs which the program reads and
5 processes.
6
7 A rough checklist:
8
9 * [ ] stdin?
10 * [ ] input files that the program is explicitly opening?
11 * [ ] configuration files?
12 * [ ] configuration files used by libraries?
13 * [ ] incoming network requests
14 * [ ] responses to outgoing network requests
15 * [ ] others...?
16
17 Consider which of these are potentially attacker-provided and which
18 are caller-provided. Inputs that are under control of the calling
19 process should normally be considered safe.
20
21 ## Enforce the strongest policy you can
22
23 Always strive to enforce the strongest Landlock policy that you can.
24
25 With higher Landlock ABI levels, you can enforce stronger policies.
26
27 ## Find the right place for Landlock enforcement during startup
28
29 * Shuffle the steps during program startup so that:
30 * Safe inputs (e.g. config files) are opened and processed first,
31 unconstrained by Landlock
32 * Landlock enforces the narrowest possible sandboxing policy
33 * Attacker-provided inputs are processed within the sandbox
34 * File descriptors opened before Landlock enforcement continue to be
35 work after enforcement. If only a fixed number of attacker-provided
36 files are processed by the program, you can open them before
37 Landlock enforcement, and start reading them after Landlock
38 enforcement.
39
40 ## Rules for file system access rights
41
42 The presets `landlock.ROFiles`, `landlock.RODirs`, `landlock.RWFiles`
43 and `landlock.RWDirs` provide sensible defaults for common read and
44 write access to files and directories.
45
46 If you have a need for a narrower configuration, see [Custom
47 Filesystem Rules](custom_fs_rules.md).
48
49 Take into account:
50
51 * The `LANDLOCK_ACCESS_FS_REFER` right is implicitly denied in ABI v1
52 and not included in `RWFiles` and `RWDirs`. If your program needs
53 to link or rename files across different directories, you must
54 specifically grant that access right using `FSRule.WithRefer()`.
55 When you add that, the enforcement of that Landlock policy will
56 require Landlock ABI V2 or higher.
57 * If your program needs to invoke IOCTLs on newly opened device files,
58 you must specifically grant that access right using
59 `FSRule.WithIoctlDev()`.
60
61 ## Rules for network access rights
62
63 For comprehensive sandboxing of network access, please augment
64 Landlock with other mechanisms (e.g., Seccomp-BPF).
65
66 * A variety of other protocols outside of TCP are not restrictable
67 (see [*socket*(2)](https://man.gnoack.org/2/socket)).
68
69 The bug needs to be fixed in the Linux kernel and is tracked here:
70 https://github.com/landlock-lsm/linux/issues/6
71 * Multipath TCP bind() is not restrictable with Landlock yet, and the
72 resulting TCP servers are backwards compatible with vanilla TCP
73 clients.
74
75 The bug needs to be fixed in the Linux kernel and is tracked here:
76 https://github.com/landlock-lsm/linux/issues/54