v3: Close unauthenticated remote access to the CachedDataServer

Open
#748 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
fastapi, nginx, python

Research direction

Start by reading server/cached_data_server.py and utils/install_openrvdas.sh to trace the open WebSocket and HTTP paths. Then inspect the listed Django and display consumers, logger host configurations, and UDPReader behavior to resolve the compatibility decisions. Done means remote access is protected, supported consumers still work through the authenticated proxy, and external users are told how to migrate.

Written by the indexing model from the issue text.

Description

enhancement

Problem

The CachedDataServer has no authentication, and anyone on the network can reach it in two ways:

  • Port 8766 directly. server/cached_data_server.py binds with websockets.serve(..., host='', port=...), which listens on all interfaces. It serves both the WebSocket protocol and the plain-HTTP /fields and /latest/<fields> routes.
  • nginx /cds-ws. utils/install_openrvdas.sh proxies /cds-ws straight to localhost:8766 with no auth, in both the Django and React nginx configs.

Any client that can reach either path can read every cached value and write to the cache with {"type": "publish", ...}. Published values are pushed to every subscriber (display widgets, Grafana and so on), and they look the same as real instrument data.

Authenticated path is now available

The FastAPI backend provides /api/v1/ws/data-server, an authenticated proxy to the CDS that accepts a JWT or an API key with the WEBSOCKET permission. It refuses publish (OceanDataTools/fastapi-template#39, #40). Remote clients have a protected way in, but it doesn't protect anything while the two open paths above remain.

Proposed change (v3, once the Django UI is retired)

  1. Bind the CDS to 127.0.0.1 by default, with a setting or flag for installs that need otherwise.
  2. Remove the /cds-ws location from the nginx configs generated by install_openrvdas.sh.
  3. Point remaining remote consumers at /api/v1/ws/data-server.
  4. Document the change for anyone with external tools on 8766 or /cds-ws.

Things that will break or need a decision

  • Django GUI. django_gui/static/django_gui/websocket.js connects to /cds-ws (WEBSOCKET_PATH in django_gui/settings.py). That's why this waits for v3.
  • Standalone display widgets. display/js/widgets/settings.js.dist also uses /cds-ws. These need to move to the authenticated proxy, which means a token or API key in the page, or a decision that they're retired with Django.
  • Loggers on other hosts. CachedDataReader and CachedDataWriter take a data_server host:port, and logger configs can run on hosts other than the one running the CDS. A logger on another machine that reads from or writes to the CDS breaks if the CDS binds only to localhost. Writes can't move to the proxy, since it refuses publish. Options: keep an opt-in non-localhost bind for multi-host installs, or add an authenticated write path for logger hosts.
  • UDP input. If the CDS runs with --udp, UDPReader listens on all interfaces, which is another unauthenticated write path. The installer doesn't enable it by default, but it should be covered by the same setting or documented.
  • External tools (Grafana datasources, scripts using /latest/...) that hit 8766 or /cds-ws directly need to switch to the proxy and an API key.
Dominant language
Python
Stars
57
Forks
30
Avg merge
3h 14m
Merged PRs (30d)
56

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OceanDataTools/openrvdas

All issues in OceanDataTools/openrvdas

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.