Debian Codegraph @

utils/netcap.8.in

raw
1 .TH NETCAP: "8" "March 2026" "Red Hat" "System Administration Utilities"
2 .SH NAME
3 netcap \- a program to review network capability posture
4 .SH SYNOPSIS
5 .B netcap
6 .\" BEGIN_ADVANCED
7 .RI [ --advanced
8 .RI [ --interface " IFACE ]
9 .RI [ --list-interfaces ]
10 .RI [ --json ]
11 .RI [ --no-color ]]
12 .\" END_ADVANCED
13 .SH DESCRIPTION
14 \fBnetcap\fP is a program that prints out a report of process capabilities.
15 By default, it runs in its historical filtered mode: if an application is
16 using tcp, udp, raw, or packet family sockets AND has any capabilities, it
17 will be in the report. If the process has partial capabilities, it is further
18 examined to see if it has an open-ended bounding set. If this is found to be
19 true, a '+' symbol is added. If the process has ambient capabilities, a '@'
20 symbol is added.
21
22 .\" BEGIN_ADVANCED
23 With \fB\-\-advanced\fP, \fBnetcap\fP switches to bind/listener inventory
24 mode for the current network namespace. In this mode, reachable binds/listeners
25 are reported regardless of whether the owning process has capabilities.
26 .\" END_ADVANCED
27
28 Some directories in the /proc file system are readonly by root. The program
29 will try to access and report what it can.
30 .\" BEGIN_ADVANCED
31 Full output normally requires root,
32 or a combination of \fBCAP_DAC_READ_SEARCH\fP (to read other processes'
33 \fB/proc/<pid>/fd\fP) and \fBCAP_NET_ADMIN\fP (for
34 \fBNETLINK_SOCK_DIAG\fP queries that cover SCTP, DCCP, and VSOCK). Without
35 these permissions, the report is partial; missing sock_diag-derived protocols
36 are omitted without an explicit warning.
37 .\" END_ADVANCED
38
39 .\" BEGIN_ADVANCED
40 .SH OPTIONS
41 .TP
42 .B \-\-advanced
43 Enable the posture/tree view. This mode inventories reachable binds in
44 the current network namespace and shows per-process capabilities, defenses,
45 and flags.
46 .TP
47 .BI \-\-interface " IFACE"
48 With \fB\-\-advanced\fP, limit the report to the named interface. Output
49 format and wrapping are unchanged; only interface-scoped rows for that
50 interface are kept. This also filters \fB\-\-list\-interfaces\fP output to
51 the named interface.
52 .TP
53 .B \-\-list\-interfaces
54 With \fB\-\-advanced\fP, list the current network namespace interface names
55 instead of the exposure tree.
56 .TP
57 .B \-\-json
58 With \fB\-\-advanced\fP, emit machine-readable JSON instead of the tree
59 view. When combined with \fB\-\-list\-interfaces\fP, emit machine-readable
60 interface inventory JSON instead of text.
61 .TP
62 .B \-\-no\-color
63 Suppress colored output. By default, when stdout is a terminal, keywords are
64 colorized by severity to highlight problems, cautions, and positive hardening
65 state.
66 .\" END_ADVANCED
67
68 .\" BEGIN_ADVANCED
69 .SH "ADVANCED MODE"
70 Advanced mode is an attack-surface and posture inventory for the current
71 network namespace. It is intended for administrators who need a structured
72 view of bind ownership and process hardening state.
73
74 With \fB\-\-advanced --list\-interfaces\fP, the advanced-mode interface
75 snapshot is rendered directly without enumerating listeners. This is intended
76 as a simple interface enumeration step before later per-interface analysis.
77 With \fB\-\-advanced --interface IFACE\fP, the same inventory and tree/JSON
78 renderers are used, but only endpoints projected onto that interface are
79 retained.
80
81 The tree layout is:
82
83 .RS
84 Planes \-> interface \-> protocol \-> bind \-> port \-> process \->
85 caps/defenses/flags
86 .RE
87
88 For VSOCK planes, the interface/address hierarchy is skipped and rendered as:
89
90 .RS
91 Planes \-> endpoint \-> process \-> caps/defenses/flags
92 .RE
93
94 Planes are grouped as INET (external), INET (loopback), VSOCK, and
95 LINK-LAYER. These names match the tree output exactly.
96
97 The console tree is a causal exposure chain: protocol, then bind address,
98 then port, then owning process. Wildcard binds are printed as \fB*\fP. In
99 tree view, a single \fB0.0.0.0\fP or \fB::\fP listener is expanded onto every
100 non-loopback interface in the current namespace. The same daemon may therefore
101 appear under multiple interfaces, reflecting wildcard-bind reachability.
102 Some endpoints may appear under interface \fBmulticast/group\fP when bound to
103 multicast addresses that do not map to a single interface; these represent
104 group-joined sockets rather than point-to-point listeners.
105
106 Under each protocol, \fBbind\fP nodes are socket bind addresses
107 (exposure), and \fBport\fP nodes are children of binds.
108 Each process entry may include a \fBunit\fP field showing the systemd service
109 or scope name, extracted from the process cgroup hierarchy; it is omitted when
110 the process is not managed by systemd.
111 Each process line also includes an optional \fBexe\fP field showing the full
112 executable path read from \fB/proc/<pid>/exe\fP; it is omitted for kernel
113 threads or when the path is unreadable. The kernel \fBName:\fP field shown as
114 \fBcomm\fP is truncated to 15 characters, so \fBexe\fP provides the complete
115 binary path.
116
117 Socket selection is protocol-specific:
118 .IP \[bu] 2
119 TCP: LISTEN sockets only.
120 .IP \[bu] 2
121 UDP/UDPLITE: bound sockets.
122 .IP \[bu] 2
123 SCTP/DCCP: listener sockets only; established flows are not shown.
124 These protocols are discovered via \fBNETLINK_SOCK_DIAG\fP, which requires
125 \fBCAP_NET_ADMIN\fP; without that capability, SCTP and DCCP listeners are
126 silently absent from the report.
127 .IP \[bu] 2
128 VSOCK: stream LISTEN sockets, plus bound datagram/seqpacket sockets.
129 .IP \[bu] 2
130 RAW/PACKET: shown as binds; semantics differ from port listeners.
131
132 The defenses section is best-effort: \fBno_new_privs\fP and
133 \fBseccomp\fP mode are read from \fB/proc/<pid>/status\fP when
134 available, and the LSM label is read from
135 \fB/proc/<pid>/attr/current\fP when available. \fBruns_as_nonroot\fP is
136 always reported.
137
138 Flags annotate notable conditions:
139 .IP \[bu] 2
140 \fBwildcard-bind\fP: bind is bound to a wildcard address
141 (for example 0.0.0.0 or ::).
142 .IP \[bu] 2
143 \fBhypervisor-plane\fP: bind is in the VSOCK communication plane.
144 .IP \[bu] 2
145 \fBssh-on-vsock-port-22\fP: VSOCK bind uses port 22.
146 .IP \[bu] 2
147 \fBprivileged-caps\fP: process has capabilities considered privileged for
148 attack-surface review (CAP_SYS_ADMIN, CAP_SYS_PTRACE,
149 CAP_DAC_READ_SEARCH, CAP_NET_ADMIN, and CAP_NET_RAW).
150
151 The \fBcaps\fP field may include bracketed annotations:
152 \fB[ambient-present]\fP indicates ambient capabilities are set, and
153 \fB[open-ended-bounding]\fP indicates the bounding set is non-empty (the
154 process or its children can potentially gain additional capabilities).
155
156 .SH "JSON OUTPUT"
157 When \fB\-\-advanced --json\fP is used, the top-level object contains:
158 .IP \[bu] 2
159 \fBschema_version\fP (integer).
160 .IP \[bu] 2
161 \fBplanes\fP (array).
162
163 Each plane object contains \fBname\fP, optional \fBscope\fP
164 (\fBexternal\fP or \fBloopback\fP), and either:
165 .IP \[bu] 2
166 \fBifaces\fP (INET/LINK-LAYER planes), or
167 .IP \[bu] 2
168 \fBendpoints\fP (VSOCK planes).
169
170 Under \fBifaces\fP: each interface has \fBname\fP and \fBaddrs\fP
171 (array). Each addr object has \fBaddr\fP and \fBendpoints\fP (array).
172
173 For INET and LINK-LAYER planes, each endpoint object has \fBlabel\fP,
174 \fBproto\fP, \fBbind\fP, \fBport\fP, and \fBprocesses\fP (array).
175 For VSOCK planes, endpoint objects use \fBlabel\fP, \fBvsock_type\fP
176 (socket type string: \fBstream\fP/\fBdgram\fP/\fBseqpacket\fP), \fBcid\fP
177 (source CID or the string \fBANY\fP), \fBport\fP, and \fBprocesses\fP;
178 they do not include \fBproto\fP or \fBbind\fP.
179
180 Each process object has \fBcomm\fP, optional \fBexe\fP, \fBpid\fP,
181 \fBuid\fP, optional \fBunit\fP, \fBcaps\fP,
182 \fBambient_present\fP (boolean), \fBopen_ended_bounding\fP (boolean),
183 \fBdefenses\fP object, and \fBflags\fP array.
184
185 \fBambient_present\fP and \fBopen_ended_bounding\fP are the structured
186 equivalents of the \fB[ambient-present]\fP and
187 \fB[open-ended-bounding]\fP annotations that may appear in the caps text
188 string; both fields are always present in JSON output.
189
190 Fields under endpoints/processes/defenses may be omitted when unavailable.
191 When process defenses are present, they include \fBruns_as_nonroot\fP, derived
192 from the real UID (first field of \fBUid:\fP in \fB/proc/<pid>/status\fP):
193 \fByes\fP when real uid != 0, \fBno\fP when real uid == 0. A process that
194 started as root and later changed only effective UID via setuid still reports
195 \fBno\fP.
196
197 If a plane has no discovered binds, it appears with an empty list. If a
198 consumer does not receive a given plane, treat it as none found or omitted by
199 the producer.
200
201 When \fB\-\-advanced --list\-interfaces --json\fP is used, the top-level
202 object
203 contains \fBschema_version\fP (integer) and \fBinterfaces\fP (array of
204 interface-name strings).
205 .\" END_ADVANCED
206
207 .SH INTERPRETATION
208 \fBnetcap\fP reports processes that are both network-facing and running with
209 capabilities. The capability set shown is the permitted set. A '+' annotation
210 means the process has an open-ended bounding set, and an '@' annotation means
211 the process has ambient capabilities.
212
213 .\" BEGIN_ADVANCED
214 Colorized tree output is intended to prioritize remediation quickly:
215 orange highlights problems to fix, yellow highlights cautionary conditions
216 to review, green highlights good hardening state, and uncolored output is
217 neutral context.
218
219 The \fBcaps\fP line shows permitted capabilities. Orange-tier capabilities
220 represent severe privilege that is rarely necessary for network-facing daemons:
221 \fBsys_ptrace\fP, \fBsys_module\fP, \fBsys_rawio\fP, \fBsetuid\fP, \fBsetgid\fP,
222 \fBsetpcap\fP, and \fBaudit_control\fP. Yellow-tier capabilities are common but
223 still materially increase attack impact: \fBsys_admin\fP, \fBdac_override\fP,
224 \fBdac_read_search\fP, \fBnet_admin\fP, \fBnet_raw\fP, \fBchown\fP, \fBfowner\fP,
225 \fBmknod\fP, and \fBsys_chroot\fP. \fBcaps: (full)\fP means all capabilities are
226 present (effectively full root privilege). \fBcaps: (none)\fP is ideal.
227
228 Ambient capabilities are inherited across \fBexecve\fP by child processes
229 (unless constrained by \fBno_new_privs\fP), so their presence on a network
230 daemon is typically a problem. The \fBambient:\fP line lists active ambient
231 capabilities.
232
233 \fB[open-ended-bounding]\fP means the process has not trimmed its bounding
234 set ceiling. This is not active privilege by itself, but it leaves future
235 privilege-acquisition paths open (for example via file capabilities or ambient
236 inheritance). For libcap-ng users, trimming is typically a one-flag change
237 (\fBCAPNG_SELECT_BOUNDS\fP) in existing capability-set calls; with libcap,
238 bounding capabilities are dropped individually.
239
240 Defense fields summarize exploit-resistance posture: \fBno_new_privs: yes\fP
241 blocks privilege gain through setuid/file-capability exec paths and is often
242 the highest-value single toggle. \fBseccomp: filter\fP restricts available
243 syscalls (\fBdisabled\fP means no syscall filtering). \fBruns_as_nonroot: yes\fP
244 indicates non-UID-0 execution.
245
246 Flags provide reachability and interception context: \fBwildcard-bind\fP means
247 the daemon listens on every interface, \fBhypervisor-plane\fP indicates host/
248 guest boundary exposure (VSOCK), and \fBreuseport\fP means another process with
249 the same UID could bind and potentially intercept traffic.
250
251 \fBraw\fP/\fBraw6\fP and \fBpacket\fP protocol nodes denote sockets with IP- or
252 link-layer packet craft/sniff capabilities, significantly expanding what an
253 attacker can do post-compromise.
254 .\" END_ADVANCED
255
256 .SH "SEE ALSO"
257 .BR pscap (8),
258 .BR filecap (8),
259 .BR capabilities (7),
260 .BR netstat (8).
261
262 .SH AUTHOR
263 Steve Grubb