Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security improvements #454

Open
wants to merge 10 commits into
base: u64ii
Choose a base branch
from

Conversation

Gee-64
Copy link
Contributor

@Gee-64 Gee-64 commented Jan 6, 2025

This PR is intended to allow somewhat secure usage of Ultimate products in a "party setting" with lots of random people on the same LAN/WIFI. It adds (optionally configured) password protection to all network services, as well as the possibility to disable services individually. By default everything is enabled and no password is set (i.e fully backwards compatible). Some code refactoring was done to try and keep things clean.

The PR is a pretty big, but split into separate commits to allow reviewing each one on its own. Happy to change how things are done or break the PR up into separate PRs if that helps, just let me know what you want. Please see it as a starting point for discussion.

I know work for the new U64E2 is top priority so I would fully understand if this particular PR is deferred until U64II is merged / released.

Note: This PR is toward the u64ii branch. The reason for targeting this branch is that the needed refactoring touches the same code as the u64ii branch does and would cause headaches/conflicts when u64ii is merged. I do have a branch which is mergable toward master if that is really preferred, but I doubt it.

The first commit is a "cleanup" commit that centralizes all "product"-related stuff, avoiding code duplication.

The remaining commits can be summarized as this:

  1. Add a "password string" config type (redacted with ****** in the UI)
  2. Move the hostname setting away from the network interfaces into a single global setting
  3. Add a global "Network password" setting
  4. Update all network services to optionally use the "Network password"
  5. Add a small "/v1/info" endpoint to the HTTP API so the web application can show the correct product name
  6. Add the possibility to enable / disable the network services

Issues that this PR relates to:

#441
#429 (though it looks like WiFi passwords are moved to the WiFi module I think?)
#406 (added separate info endpoint in order to not pollute the API version endpoint)

Edit: If anyone wants to try this out as it looks right now there are "softbootable" versions of the firmware to try over at

https://github.com/Gee-64/1541ultimate/releases

Gee-64 added 10 commits January 6, 2025 18:49
Configuration settings of this type are not shown while browsing
the configuration (unless being edited). The password fields are
redacted when reading configuration through the API, but can
be written just like before.
- Rename LAN config settings from "Network settings" to
  "Ethernet Settings".

- Create a new "Network Settings" menu item for stuff that is not
  really related to the interfaces (Ethernet, WiFi).

- Move the hostname setting from the Ethernet / Wifi settings menu to
  the new menu item.

- Increase max hostname length to 31 chars to make room for a default unique
  hostname consisting of a product name plus a partial mac, like for example
  "Ultimate-64-Elite-II-12D3E1" (27 chars).
The "ident" server running on UDP port 64 is used to discover Ultimate devices
on the local network. If a JSON response is sent to the client, a new boolean
field "requires_authentication" is included to indicate if future communication
on the "dma" TCP port 64 should start with a SOCKET_CMD_AUTHENTICATE (0xFF1F)
command. The argument to this new command is simply a password, and the
response to the client is single byte (0x00 for password incorrect, 0x01 for
password correct). An incorrect password will cause the Ultimate to close the
connection after a brief delay (to slow down password brute forcing).
The web API under http://<ultimate-ip>/v1/ is now optionally password
protected. The password should be supplied using a 'X-Password' HTTP header.

Example use:

  curl --header "X-Password: my-secret-password" http://192.168.2.64/v1/version

To determine if a password is needed the client should do a GET on /v1/version
(without a password) and if the HTTP response status code is 401 or 403 then a
password is required.

The HTML page served by the Ultimate web server does not yet support entering a
password.
- Rename make_get_request() to make_binary_get_request() (response is binary data)
- Create make_get_request() (response is JSON data)
- On startup make a request to /v1/info to determine if a password is required
- Add a login page and a logout entry in the left side menu
- The top banner now shows the correct product type (uses /v1/info response)
- Fully backwards compatible with older firmware versions without password support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant