CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
301 stars 189 forks source link

NACM - Module access rules not applied when "copy-config" RPC used #1424

Closed lucianocuchi closed 1 year ago

lucianocuchi commented 1 year ago

Problem:

Scenario:

root@74b52dbc5f65:/usr/local/lib# netopeer2-server -V
netopeer2-server 2.1.59
root@74b52dbc5f65:/usr/local/lib# sysrepoctl -V      
sysrepoctl - sysrepo YANG schema manipulation tool, compiled with libsysrepo v2.2.65 (SO v7.14.25)

ARG V_LIBYANG=395a7d9 ARG V_LIBSSH=0.9.6 ARG V_LIBNETCONF2=2.1.31

Test details:

root@74b52dbc5f65:/# sysrepocfg -X -d operational -x /ietf-netconf-acm:* 
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
    <enable-nacm>true</enable-nacm>
    <read-default>permit</read-default>
    <write-default>permit</write-default>
    <exec-default>permit</exec-default>
    <enable-external-groups>false</enable-external-groups>
    <denied-operations>0</denied-operations>
    <denied-data-writes>0</denied-data-writes>
    <denied-notifications>0</denied-notifications>
    <groups>
        <group>
            <name>admin</name>
            <user-name>netconf-admin</user-name>
            <user-name>netconf-cli</user-name>
        </group>
        <group>
            <name>operator</name>
            <user-name>netconf-operator</user-name>
        </group>
        <group>
            <name>read-only</name>
            <user-name>netconf-ro</user-name>
        </group>
    </groups>
    <rule-list>
        <name>read-only-policy</name>
        <group>read-only</group>
        <rule>
            <name>deny-cudx</name>
            <module-name>*</module-name>
            <access-operations>create update delete exec</access-operations>
            <action>deny</action>
            <comment>Only allow read operation</comment>
        </rule>
    </rule-list>
    <rule-list>
        <name>Netconf-server protection</name>
        <group>operator</group>
        <rule>
            <name>hide-ietf-netconf-server</name>
            <module-name>ietf-netconf-server</module-name>
            <access-operations>create update delete exec</access-operations>
            <action>deny</action>
            <comment>Do not allow modifications to ietf-netconf-server module</comment>
        </rule>
    </rule-list>
</nacm>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
    <rpc-error>
        <error-type>protocol</error-type>
        <error-tag>access-denied</error-tag>
        <error-severity>error</error-severity>
        <error-path>/ietf-netconf:copy-config</error-path>
        <error-message xml:lang="en">Executing the operation is denied because "netconf-ro" NACM authorization failed.</error-message>
    </rpc-error>
</rpc-reply>]]>]]>
michalvasko commented 1 year ago

Try the latest sysrepo, there was a problem in how the NACM was checked.

lucianocuchi commented 1 year ago

OK thanks, we will check it