ros2 / sros2

tools to generate and distribute keys for SROS 2
Apache License 2.0
89 stars 44 forks source link

Option for smaller or lossy permissions #228

Open ruffsl opened 4 years ago

ruffsl commented 4 years ago

Due to a DDS related size constraint it may be advantageous to provide users an option to reduce the size of generated access control permission files via a lossy transform leveraging posix rule expressions. In particular, such an option could be used to * wildcard over permissions within a node's own private namespace, and/or over action related topics used by clients and servers as well.

As first encountered in https://github.com/ros-swg/turtlebot3_demo/pull/34#issuecomment-663739230 , default enclaves with moderate numbers of node profiles can easily result in signed permission files exceeding 64KB, causing the DDS security handshake to fail as discussed in a SROS2 matrix channel thread, due to the size limits for RTPS packet properties, as clarified in the recent security working group meeting:

Ideally, such limitations could be avoided by generating separate and smaller enclaves specific for each different participant, as opposed to using one monolithic enclave for containing all profile permissions. To use such multiple enclaves however will require further extension to roslaunch in order for users to easily orchestrate prescribed enclaves to different spawned ros2 processes.

In the interim, the DDS security spec allows for the used of posix expressions within permission rules, allowing users to substitute multiple closely related rules using a single wildcarded expression, abbreviating the permissions considerably. After discussing with @mikaelarguedas offline, we think this may best be achieved by extending the template transform to take a optional argument parameter to adjust how private related namespaces are expanded into DDS related topic rules.

https://github.com/ros2/sros2/blob/54e80d50934b3c50a7e657a1682a548700a7ddab/sros2/sros2/policy/templates/dds/permissions.xsl#L256-L264

Although using such wildcard approximations would be a lossy transform for minimal spanning permission profiles, enabling the option within the transform itself would afford users who necessitate such compromises to leave there own ros2 policy files source definitions unaltered. E.g:

      <allow_rule>
        <domains>
          <id>0</id>
        </domains>
        <publish>
          <topics>
+            <topic>rq/talker/*</topic>
-            <topic>rq/talker/describe_parametersRequest</topic>
-            <topic>rq/talker/get_parameter_typesRequest</topic>
-            <topic>rq/talker/get_parametersRequest</topic>
-            <topic>rq/talker/list_parametersRequest</topic>
-            <topic>rq/talker/set_parametersRequest</topic>
-            <topic>rq/talker/set_parameters_atomicallyRequest</topic>
+            <topic>rr/talker/*</topic>
-            <topic>rr/talker/describe_parametersReply</topic>
-            <topic>rr/talker/get_parameter_typesReply</topic>
-            <topic>rr/talker/get_parametersReply</topic>
-            <topic>rr/talker/list_parametersReply</topic>
-            <topic>rr/talker/set_parametersReply</topic>
-            <topic>rr/talker/set_parameters_atomicallyReply</topic>
            <topic>rt/chatter</topic>
            <topic>rt/parameter_events</topic>
            <topic>rt/rosout</topic>
          </topics>
        </publish>