BarkleyGitHub
Controls · INT
Markdown file

Integrations

A custom integration runs inside Home Assistant’s own Python process and can reach every device, token and file in the config folder. Home Assistant has helpers for logins, storage and web requests, and using them is safer than writing your own.

From the 2026 sweep235 integrations add at least one page that opens without logging in to Home Assistant. 69 install a Python package version with a known vulnerability. The Marketplace report has more on this.

These steps apply only if you publish an integration.

Controls

  1. INT-1Level 1Never fetch code at run time. Don't run pip install from inside the integration, and don't download a script and run it. List packages in manifest.json with exact versions, and Home Assistant installs them.

    manifest.json (part)
    "requirements": ["examplelib==2.4.1"]
  2. INT-2Level 1Keep the login on every page you add. HomeAssistantView requires a login unless you turn it off. Only turn it off when the situation calls for it and none of these safer options fits:

    • For calls from a device or a cloud service, use a webhook. It uses an id nobody can guess and can be limited to the local network.
    • For a link to something that can't log in, like a speaker playing a sound or an image in a notification, use a signed path from async_sign_path. The page keeps its login check, and the link expires.
    • For signing in to a cloud account, use Home Assistant's OAuth2 config flow helper (config_entry_oauth2_flow), which provides the redirect page for you.
    • For your card's or panel's JavaScript, use hass.http.async_register_static_paths. These files load without a login by design, so put code in them and keep data out.
    Do webhook for inbound calls
    from homeassistant.components import webhook
    
    webhook.async_register(
        hass, DOMAIN, "Example device",
        entry.data[CONF_WEBHOOK_ID], handle_webhook,
        local_only=True,
    )
    Don't a page with the login turned off for no reason
    class StatusView(HomeAssistantView):
        url = "/api/example/status"
        name = "api:example:status"
        requires_auth = False   # anyone on the network

    If you do turn the login off, return nothing sensitive from that page, and check any token or signature yourself in the handler. Create a webhook id in the config flow with webhook.async_generate_id().

  3. INT-3Level 1Save settings and state with the storage helper, and never with pickle. The helper writes JSON safely, versions it, and keeps it where backups find it. Loading a pickle file runs any code inside it, so anything that can write that file can run code in Home Assistant.

    For other kinds of data: large or binary files (images, firmware, models) go in plain files in your own folder, many records you query go in SQLite, and history belongs in entities, which the recorder already keeps.

    __init__.py
    from homeassistant.helpers.storage import Store
    
    store = Store(hass, 1, f"{DOMAIN}.cache")
    data = await store.async_load() or {}
    await store.async_save(data)
  4. INT-4Level 1Use Home Assistant's shared web session with certificate checks on. Only offer "don't verify SSL" for local devices with self-signed certificates, and default it to off.

    coordinator.py
    from homeassistant.helpers.aiohttp_client import async_get_clientsession
    
    session = async_get_clientsession(hass)
  5. INT-5Level 1Avoid the calls that turn data into code: pickle.load, eval, exec, yaml.load without a safe loader, and subprocess with shell=True.

  6. INT-6Level 1Send each credential only to its own service. A Supervisor token goes to the Supervisor, a user's cloud token goes to that cloud, and nothing goes to your own server unless the README says so.

Check it worked

With Home Assistant running, open each page your integration adds in a private browser window. Every one should ask you to log in, or answer 401, except the ones you opened on purpose for a reason above.

Barkley flags pages that skip the login, credentials sent somewhere other than their owner, code downloaded and run, pickle of stored data, and libraries with known vulnerabilities.

Open the full page