Repository navigation
v10.9.1
HASS.Agent .NET10 10.9.1
The security release after the feature release: 10.9.0 brought new things to do, 10.9.1 is about who can do them. It is what came out of CodeRabbit's AI Deep Scan of the app, a security review of the Home Assistant integration and another of the app, its installer and the release flow. Most of it is invisible. On a PC with more than one Windows user the app asks once who may use it, and an administrator's token on the HA API can be swapped for a Home Assistant user of the PC's own. Works with the Home Assistant integration 10.6.7 or newer; the HA API without an administrator's token needs the integration 10.9.1, the new entities of 10.9.0 need 10.9.0. Signed release.
Who may do what on this PC
- Who may use HASS.Agent on this PC. Its settings, with the Home Assistant token, the MQTT login and the commands it runs, could be read and changed by every user of the PC. They can now be limited to some users. A first install asks (Only me or Every user of this PC); a silent one (winget, a deployment tool) leaves the choice to the app, which asks the first time its window is opened on a PC with a user who is not an administrator. The question names what is at stake: the MQTT password, which opens the whole broker, and what the Home Assistant token can do. It is also under Danger Zone, Users of this PC. Limiting needs an administrator (UAC) and uses a local group, HASS.Agent Users, that an administrator can also manage with Windows' own tools; the ticked users get access at once, without logging on again, and someone left out gets a note once. On a PC whose users are all administrators an update limits the settings to them by itself, which takes nothing from anyone and keeps out a user added later. See Who May Use It on This PC.
- The settings folder can no longer be taken over. Every user may create a folder in ProgramData, so another user could have made HASS.Agent's folder before the first install, or made it a link to a folder of their choosing, whose access rule the installer would then have set. Before an administrator sets the rule, the app now removes such links and takes over what another user owns, and users may change what is in the folder but not delete or replace the folder itself.
- Fixed: a user of the PC could have a command run as SYSTEM. The Windows service (SYSTEM) ran the custom commands and command sensors the settings set for it, and those settings could be written by other users. The service now runs one only when an administrator has approved it:
service-policy.jsonnext to the program, which only administrators can write, approves each by its id and what it runs. A command or command sensor added or changed for the service asks for administrator approval (UAC) when the settings are saved; the prompt shows each one in full, and what is approved is exactly what it showed. An update keeps what was approved before and approves nothing new; the first update from 10.9.0 or older approves the current settings once, so nothing stops working. Until it is approved the service leaves a command to the tray app, and the log says which ones. The editor's Test button runs it as you, never as SYSTEM, and says so when only the service is ticked. See Commands the Service Runs. - Windows tools are started by their full path (
sc.exe,schtasks.exe,shutdown.exe, PowerShell and others). A bare name is looked up in the current folder first, so the app started elevated from a folder someone else can write to could run a planted copy. - Setup starts the app as the user who ran it, not with administrator rights.
- Uninstalling asks whether to remove the settings, with the tokens in them.
Home Assistant
- The HA API no longer needs an administrator's token (integration 10.9.1). The connection used Home Assistant's
fire_eventandsubscribe_events, which only an administrator may use, so the token on the PC was one that can change everything in Home Assistant, and a PC that was broken into gave it away. With the integration 10.9.1 the app uses the integration's own commands instead, which work with a token of a Home Assistant user who is not an administrator; an administrator approves such a PC once in Home Assistant. The app also only gets the commands meant for itself now, not those of every PC. The easy way there: when the app connects with an administrator's token, right after the token is saved or when its window opens, it offers to create a Home Assistant user for this PC (not an administrator, without a password) and switches to its token; the HA API page shows whose the token is and has the same button. An administrator's token keeps working, and with an older integration the app connects as before. How it works, and the way by hand: A Home Assistant user for the PC. - A Home Assistant address typed without
http://orhttps://gets https unless it points into the home network. It always got plain http before, so an address on the internet (a Nabu Casa one, your own domain) sent the token unencrypted, or did not work at all. A.localname, a name without a dot, a private IP address andlocalhoststill get http, as Home Assistant answers there by default. - Switched-off sensors stay at home. A built-in sensor switched off on the Sensors page was only left out of what Home Assistant builds entities from; its value still went out with every update, the title of the active window and the logged-in user included. Only the sensors switched on are sent now.
- Notifications and media commands over the HA API follow their switches, as they always did over MQTT.
- A command sensor's command goes to Home Assistant as a hash, not as its text: the device message stays on the broker, where any client can read it.
- Keep the MQTT login to yourself. Whoever can log in to the broker can send the PC commands and notifications; Connecting to Home Assistant says what to do about it. MQTT messages over 1 MB are ignored.
Updates
- An update installer runs only when it is signed by the publisher. The app downloaded the installer of a new release and started it without checking it, elevated, and from the service as SYSTEM. It now asks Windows to check the Authenticode signature first (unchanged since signing, a trusted certificate chain, a valid timestamp), requires the signer to be the publisher of the releases (Open Source Developer Viktor Révész, issued by Certum Code Signing 2021 CA), and refuses a certificate that has been revoked. Anything else, a damaged download or a release file replaced by someone else, is deleted and the update stops with the reason in the log and in Home Assistant. The publisher is checked by name rather than by certificate, so a renewed certificate keeps updates working.
- The service downloads an update into a new folder that only administrators can use; on older Windows 10 its temp folder let other users get at the installer between the check and the start.
- The update prompt only links to GitHub: links inside the release notes are shown as text.
- The release signatures (Sigstore) are only made after every file in the zip has been checked: the app with the Certum signature, the bundled WebView2 and ASP.NET Core libraries with Microsoft's, and nothing else that could run.
Also in this release
- A hotkey is pressed, not typed, and you see at once whether it is free. In the hotkey editor the combination is pressed in its field (Backspace clears it). The line under it says straight away whether Windows lets HASS.Agent have it, or whether Windows or another program already uses it; it also says when another hotkey of the list has the same combination, and warns about one modifier alone (ctrl+c, alt+f4). A taken combination is kept only when OK is pressed twice; the app then tries it again every minute, so it starts working once the other program lets it go.
- The service no longer restarts its connection after an update.
- The broker drops the PC with "malformed packet"? On one PC with a Realtek 2.5G network card it stopped once the card's Large Send Offload was switched off; Connecting to Home Assistant says how to switch it off.
- The local HTTP API compares the API key in constant time, and a new one comes from the cryptographic random generator.
- Notification pictures: at most two downloads at a time, none from this PC itself, redirects checked one by one, nothing over 50 megapixels; old ones are cleaned up once an hour.
- Limits on what LibreHardwareMonitor sends: at most 4 MB and 5000 values are read.
- The log cannot be fooled by line breaks in text that comes from outside (a notification, an MQTT message).
- A contributing guide, and the project has the OpenSSF Best Practices passing badge.