Skip to content

Commit 9257e5e

Browse files
ruffslmikaelarguedaskyrofa
authored andcommitted
Add and update security designs for Contexts (ros2#274)
* Add initial draft for ROS 2 Security Contexts Signed-off-by: ruffsl <[email protected]> Co-Authored-By: Mikael Arguedas <[email protected]> * Update policy schema for contexts * Update DDS-Security integration for contexts * Allow contexts to formalize cross domain bridging * Update context vocab * Update design for runtime argument * Simplify context arg * Removing shell specific $ from variables * Restore notes on synlinks * Remove the use of alternate lookup methods It's now redundan given context paths can be independent of namespace ros2#274 (comment) * Update policy schema to match that currently used * Update key argument name for security context * Publish Security Contexts document * Update context directory overide env name * Update story for ROS_SECURITY_ROOT_DIRECTORY * Context -> Enclave * Rename for enclave terminology change * Update runtime argument for enclave assignment * Relegate lunch interrogation to future work * Disassociate context paths from namespaces * Update override example of root directory and CLA * Rename security environment variables * Update behavor of ROS_SECURITY_ENCLAVE_OVERRIDE Co-authored-by: Mikael Arguedas <[email protected]> Co-authored-by: Kyle Fazzari <[email protected]>
1 parent 5fa559f commit 9257e5e

File tree

5 files changed

+443
-51
lines changed

5 files changed

+443
-51
lines changed

articles/150_ros_command_line_arguments.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ As a quick summary of ROS command line capabilities:
7878
- to `rosout`, use `--enable-rosout-logs` or `--disable-rosout-logs`
7979
- to `stdout`, use `--enable-stdout-logs` or `--disable-stdout-logs`
8080
- to a external logging library, use `--enable-external-lib-logs` or `--disable-external-lib-logs`
81+
- For enclave assignment, use either `--enclave value` or `-e value` where value is fully qualified enclave path.
8182

8283
For name remapping and parameter assignment, specific nodes can be targeted by prepending the option value with the node name followed by a colon `:`, as in `--remap my_node:from:=to` and `--param my_node:name:=value`.
8384

@@ -201,6 +202,25 @@ ros2 run some_package some_ros_executable --ros-args --disable-rosout-logs --dis
201202

202203
Logging is fully enabled by default, thus `--enable-*` options are usually redundant unless a `--disable-*` option found earlier in the command line is being overridden.
203204

205+
#### Enclave assignments
206+
207+
Enclave assignment may be achieved using the `--enclave`/`-e` option.
208+
This option takes a single string `value` assignment statement, where `value` is a fully qualified enclave path used to locate the respective security artifacts within the configured keystore.
209+
210+
As an example, to assign an enclave path `/foo/bar` one may execute:
211+
212+
```sh
213+
ros2 run some_package some_ros_executable --ros-args --enclave="/foo/bar"
214+
```
215+
216+
or its shorter equivalent:
217+
218+
```sh
219+
ros2 run some_package some_ros_executable --ros-args -e "/foo/bar"
220+
```
221+
222+
As is, this enclave assignment applies to each and every Domain Participant that `some_ros_executable` spawns unless explicitly ignored in code or overridden via security environment variables.
223+
204224
## Implementation
205225

206226
### Extraction

articles/ros2_access_control_policies.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ A policy serves as a high-level abstraction of privileges associated with attrib
3232
## Concepts
3333

3434
Before detailing the SROS 2 policy design of the [access control](https://en.wikipedia.org/wiki/Computer_access_control), by which the system constrains the ability of a subject to access an object, it is important to establish a few concepts useful in formalizing the design approach in terms of security.
35-
In this context, a subject may be thought of as a participant on a distributed data-bus (e.g. a ROS node in the computation graph), whereas an object may be an instance of a particular subsystem (e.g. a ROS topic), and access is defined as the capability to act upon that object (e.g. publish or subscribe).
35+
In this setting, a subject may be thought of as a participant on a distributed data-bus (e.g. a ROS node in the computation graph), whereas an object may be an instance of a particular subsystem (e.g. a ROS topic), and access is defined as the capability to act upon that object (e.g. publish or subscribe).
3636

3737
### Mandatory Access Control
3838

@@ -99,11 +99,33 @@ Attributes:
9999
- **version**: declared version of schema version in use
100100
- Allows for advancing future revisions of the schema
101101

102-
### `<profiles>` Tag
102+
### `<enclaves>` Tag
103103

104-
Encapsulates a sequence of unique profiles.
104+
Encapsulates a sequence of unique enclaves.
105105
This method of nesting sequences allows for additional tags to be extended to the `<policy>` root.
106106

107+
### `<enclave>` Tag
108+
109+
Encapsulates a collection of profiles.
110+
This is specific to an enclave as determined by associative attributes.
111+
112+
Attributes:
113+
- **path**: Fully qualified enclave path
114+
115+
Given that multiple nodes can be composed into a single process, an enclave is used to contain the collection of profiles of all respective nodes.
116+
An enclave may therefore be considered the union of contained profiles.
117+
Note that the union of profiles within an enclave will result in denied privileges of any profile to supersede all allowed privileges for every profile.
118+
E.g. if a profile asks for a permission but a matching permission has been explicitly denied by another profile in the enclave, the deny rule will take precedence.
119+
See section `<profile>` Tag for more info on how MAC is applied.
120+
121+
### `<profiles>` Tag
122+
123+
Encapsulates a sequence of unique profiles and designated metadata.
124+
This method of nesting sequences allows for additional tags to be extended to the `<enclave>` root, as well as associating particular metadata or constraints to the contained profile elements.
125+
126+
Attributes:
127+
- **type**: Specifies the transport type of profiles and metadata
128+
107129
### `<profile>` Tag
108130

109131
Encapsulates a collection of subject privileges.
@@ -119,6 +141,19 @@ That is to say the priority of denied privileges conservatively supersedes allow
119141
This method of flatting privileges enables users to provision general access to a larger set of objects, while simultaneously revoking access to a smaller subset of sensitive objects.
120142
Although recursion of qualifiers is subsequently prevented, transformations are subsequently simplified, preventing potential for unintended access.
121143

144+
### `<metadata>` Tag
145+
146+
Encapsulates arbitrary metadata or constraints.
147+
This could include transport specific permission details applicable to sibling profile elements.
148+
There can only one `metadata` element per `profiles` parent element.
149+
150+
Attributes:
151+
- To be defined
152+
153+
Given the use cases for bridge interfaces where an enclave's credentials may be used to interconnect across multiple transports or to transport specific domains, it may be necessary to qualify certain profile sequences with particular constraints, while doing so multiple times for separate profiles per enclave.
154+
This allows advanced users to holistically control the intersect of permissions across transport domains, while retaining accurate model fidelity of security permissions.
155+
Given how security sensitive bridge interfaces are and the attack surface they expose, it is vital that information flow control within a bridge remains formally verifiable for safe and secure operation.
156+
122157
#### Privileges
123158

124159
Privileges are defined as configuration of rules and permissions for object access.
@@ -286,8 +321,8 @@ Yet, if the intended purpose of SROS 2 policy becomes that of an intermediate re
286321
ROS 2 allows for the remapping of many namespaced subsystems at runtime, such as when reusing launch files to orchestrate larger applications.
287322
While it is perhaps unreasonable to expect this dynamic flexibility from staticky provisioned permissions without allocating such capabilities prior, it should be made possible to infer the necessary capabilities from composed launch files and similar orchestrations.
288323

289-
Static analysis of such remapping in conjunction with the context of the nominal requirements of respective nodes could be used to auto generate the new satisfactory policies.
290-
However, inferring such context from the source code could be equated to the halting problem.
324+
Static analysis of such remapping in conjunction with the setting of the nominal requirements of respective nodes could be used to auto generate the new satisfactory policies.
325+
However, inferring such policies from the source code could be equated to the halting problem.
291326
Thus, it stands to reason nodes could instead provide a manifest or IDL defining these nominal requirements so that permission may as easily be remapped, at least at design time.
292327

293328
## References

articles/ros2_access_control_policies/policy.xsd

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,34 @@
1010
<xs:element name="policy" type="Policy" />
1111
<xs:complexType name="Policy">
1212
<xs:sequence minOccurs="1" maxOccurs="1">
13+
<xs:element name="enclaves" type="Enclaves" />
14+
</xs:sequence>
15+
<xs:attribute name="version" type="xs:string" use="required" fixed="0.2.0"/>
16+
</xs:complexType>
17+
18+
<xs:complexType name="Enclaves">
19+
<xs:sequence minOccurs="1" maxOccurs="unbounded">
20+
<xs:element name="enclave" type="Enclave" />
21+
</xs:sequence>
22+
</xs:complexType>
23+
24+
<xs:complexType name="Enclave">
25+
<xs:sequence minOccurs="1" maxOccurs="unbounded">
1326
<xs:element name="profiles" type="Profiles" />
1427
</xs:sequence>
15-
<xs:attribute name="version" type="xs:string" use="required" />
28+
<xs:attribute name="path" type="xs:string" use="required" />
1629
</xs:complexType>
1730

1831
<xs:complexType name="Profiles">
19-
<xs:sequence minOccurs="1" maxOccurs="unbounded">
20-
<xs:element name="profile" type="Profile" />
32+
<xs:sequence minOccurs="1" maxOccurs="1">
33+
<xs:sequence minOccurs="1" maxOccurs="unbounded">
34+
<xs:element name="profile" type="Profile" />
35+
</xs:sequence>
36+
<xs:sequence minOccurs="0" maxOccurs="1">
37+
<xs:element name="metadata" type="xs:anyType" />
38+
</xs:sequence>
2139
</xs:sequence>
40+
<xs:attribute name="type" type="xs:string" use="optional" />
2241
</xs:complexType>
2342

2443
<xs:complexType name="Profile">

articles/ros2_dds_security.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Let's delve a little further into those first three plugins.
4545

4646
## Authentication
4747

48-
The **Authentication** plugin (see section 8.3 of the [DDS-Security spec][dds_security]) is central to the entire SPI architecture, as it provides the concept of a confirmed identity without which further enforcement would be impossible (e.g. it would be awfully hard to make sure a given ROS node could only access specific topics if it was impossible to securely determine which node it was).
48+
The **Authentication** plugin (see section 8.3 of the [DDS-Security spec][dds_security]) is central to the entire SPI architecture, as it provides the concept of a confirmed identity without which further enforcement would be impossible (e.g. it would be awfully hard to make sure a given ROS identity could only access specific topics if it was impossible to securely determine which identity it was).
4949

5050
The SPI architecture allows for a number of potential authentication schemes, but ROS 2 uses the builtin authentication plugin (called "DDS:Auth:PKI-DH", see section 9.3 of the [DDS-Security spec][dds_security]), which uses the proven Public Key Infrastructure (PKI).
5151
It requires a public and private key per domain participant, as well as an x.509 certificate that binds the participant's public key to a specific name.
@@ -114,7 +114,7 @@ Let's discuss each of these in turn.
114114
### Security files for each domain participant
115115

116116
As stated earlier, the DDS-Security plugins require a set of security files (e.g. keys, governance and permissions files, etc.) per domain participant.
117-
Domain participants map to a specific instance of a node in ROS 2, so each node requires a set of these files.
117+
Domain participants map to a context within process in ROS 2, so each process requires a set of these files.
118118
RCL supports being pointed at a directory containing security files in two different ways:
119119

120120
- Directory tree of all security files.
@@ -125,72 +125,72 @@ Let's delve further into these.
125125

126126
#### Directory tree of all security files
127127

128-
RCL supports finding security files in one directory that is the root of a directory structure corresponding to the fully-qualified names of every node instance (i.e. namespace + node name).
129-
For example, for the `/front/camera` node, the directory structure would look like:
128+
RCL supports finding security files in one directory that is inside the reserved `enclaves` subfolder, within the root keystore, corresponding to the fully-qualified path of every enclave.
129+
For example, for the `/front/camera` enclave, the directory structure would look like:
130130

131131
<root>
132-
└── front
133-
└── camera
134-
├── cert.pem
135-
├── key.pem
136-
├── ...
132+
├── enclaves
133+
│ └── front
134+
│ └── camera
135+
│ ├── cert.pem
136+
│ ├── key.pem
137+
│ ├── ...
138+
└── public
139+
├── ...
137140

138-
To be clear: this directory structure needs to reflect the state of the running system.
139-
In other words, it does not contain a set of files per node on disk, but per node instance _in the ROS graph_.
140-
141-
The set of files expected within each node instance directory are:
141+
The set of files expected within each enclave instance directory are:
142142

143143
- **identity_ca.cert.pem**: The x.509 certificate of the CA trusted by the **Authentication** plugin (the "Identity" CA).
144-
- **cert.pem**: The x.509 certificate of this node instance (signed by the Identity CA).
145-
- **key.pem**: The private key of this node instance.
144+
- **cert.pem**: The x.509 certificate of this enclave instance (signed by the Identity CA).
145+
- **key.pem**: The private key of this enclave instance.
146146
- **permissions_ca.cert.pem**: The x.509 certificate of the CA trusted by the **Access control** plugin (the "Permissions" CA).
147147
- **governance.p7s**: The XML document that specifies to the **Access control** plugin how the domain should be secured (signed by the Permissions CA).
148-
- **permissions.p7s**: The XML document that specifies the permissions of this particular node instance to the **Access control** plugin (also signed by the Permissions CA).
149-
150-
This can be specified by setting the `$ROS_SECURITY_ROOT_DIRECTORY` environment variable to point to the root of the directory tree.
151-
152-
153-
##### Support security files lookup methods
148+
- **permissions.p7s**: The XML document that specifies the permissions of this particular enclave instance to the **Access control** plugin (also signed by the Permissions CA).
154149

155-
If using the directory tree approach to organize security files, RCL supports two different methods for looking up a given node instance's security files in the tree:
156-
157-
- **Exact**: Only load security files from a directory exactly matching the fully-qualified name of the node instance.
158-
For example, given a node named "baz_123" within the "/foo/bar/" namespace, only load security files from `<root>/foo/bar/baz_123/`.
159-
This is the default behavior.
160-
- **Prefix**: Attempt to load the most specific set of security files, but if they can't be found, check for security files under a less-specific node name.
161-
For example, given a node named "baz_123" within the "/foo/bar/" namespace, load security files from `<root>/foo/bar/baz_123/`.
162-
However, if that directory doesn't exist, find the most specific (i.e. longest) node name that _does_ have security files within that namespace (e.g. `<root>/foo/bar/baz_12/`, or `<root>/foo/bar/baz/`, etc.).
163-
Note that it will not search higher in the namespace hierarchy.
164-
165-
The desired lookup method can be specified by setting the `$ROS_SECURITY_LOOKUP_TYPE` environment variable to "MATCH_EXACT" (case-sensitive) for the **Exact** method, or "MATCH_PREFIX" (case-sensitive) for the **Prefix** method.
150+
This can be specified by setting the `ROS_SECURITY_KEYSTORE` environment variable to point to the root of the keystore directory tree, and then specifying the enclave path using the `--ros-args` runtime argument `-e`, `--enclave`, e.g.:
166151

152+
``` shell
153+
export ROS_SECURITY_KEYSTORE="/home/bob/.ros/sros2_keystore"
154+
ros2 run <package> <executable> --ros-args --enclave="/front/camera"
155+
```
167156

168157
#### Manual specification
169158

170-
RCL supports specifying the path to a directory containing the set of security files for the exact node instance that needs to be launched.
171-
The set of files expected within that directory are the same as outlined in the "Directory tree of all security files" section above for individual node instance directories.
159+
RCL also supports specifying the enclave path for the process that needs to be launched using an overriding environmental variable.
160+
This can be done by setting the `ROS_SECURITY_ENCLAVE_OVERRIDE` environment variable to an alternate enclave path within the keystore.
161+
Note that this setting takes precedence over `ROS_SECURITY_KEYSTORE` with `--enclave`.
162+
163+
Note that the following two examples load from the same enclave path as demonstrated prior:
172164

173-
This can be specified by setting the `$ROS_SECURITY_NODE_DIRECTORY` environment variable to point to the directory containing the security files.
174-
Note that this setting takes precedence over `$ROS_SECURITY_ROOT_DIRECTORY`.
165+
``` shell
166+
export ROS_SECURITY_KEYSTORE="/home/bob/.ros/sros2_keystore"
167+
export ROS_SECURITY_ENCLAVE_OVERRIDE="/front/camera"
168+
ros2 run <package> <executable>
169+
```
175170

171+
``` shell
172+
export ROS_SECURITY_KEYSTORE="/home/bob/.ros/sros2_keystore"
173+
export ROS_SECURITY_ENCLAVE_OVERRIDE="/front/camera"
174+
ros2 run <package> <executable> --ros-args --enclave="/spam"
175+
```
176176

177177
### Support for both permissive and strict enforcement of security
178178

179-
Nodes with the security features enabled will not communicate with nodes that don't, but what should RCL do if one tries to launch a node that has no discernable keys/permissions/etc.? It has two options:
179+
Participants with the security features enabled will not communicate with participants that don't, but what should RCL do if one tries to launch a participant that has no discernable enclave with keys/permissions/etc.? It has two options:
180180

181-
- **Permissive mode**: Try to find security files, and if they can't be found, launch the node without enabling any security features.
181+
- **Permissive mode**: Try to find security files, and if they can't be found, launch the participant without enabling any security features.
182182
This is the default behavior.
183-
- **Strict mode**: Try to find security files, and if they can't be found, fail to run the node.
183+
- **Strict mode**: Try to find security files, and if they can't be found, fail to run the participant.
184184

185-
The type of mode desired can be specified by setting the `$ROS_SECURITY_STRATEGY` environment variable to "Enforce" (case-sensitive) for strict mode, and anything else for permissive mode.
185+
The type of mode desired can be specified by setting the `ROS_SECURITY_STRATEGY` environment variable to "Enforce" (case-sensitive) for strict mode, and anything else for permissive mode.
186186

187187

188188
### Support for a master "on/off" switch for all SROS 2 features
189189

190190
In addition to the supported features just discussed, RCL also supports a master shutoff for security features for easy experimentation.
191191
If it's turned off (the default), none of the above security features will be enabled.
192192

193-
In order to enable SROS 2, set the `$ROS_SECURITY_ENABLE` environment variable to "true" (case-sensitive).
193+
In order to enable SROS 2, set the `ROS_SECURITY_ENABLE` environment variable to "true" (case-sensitive).
194194
To disable, set to any other value.
195195

196196

@@ -202,9 +202,9 @@ However, the [SROS 2 CLI](https://github.com/ros2/sros2) should include a tool `
202202

203203
- Create Identity and Permissions CA.
204204
- Create directory tree containing all security files.
205-
- Create a new identity for a given node instance, generating a keypair and signing its x.509 certificate using the Identity CA.
205+
- Create a new identity for a given enclave, generating a keypair and signing its x.509 certificate using the Identity CA.
206206
- Create a governance file that will encrypt all DDS traffic by default.
207-
- Support specifying node instance permissions [in familiar ROS terms](/articles/ros2_access_control_policies.html) which are then automatically converted into low-level DDS permissions.
207+
- Support specifying enclave permissions [in familiar ROS terms](/articles/ros2_access_control_policies.html) which are then automatically converted into low-level DDS permissions.
208208
- Support automatically discovering required permissions from a running ROS system.
209209

210210

0 commit comments

Comments
 (0)