Your ticks and choices are saved in this browser only.
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.
These steps apply only if you publish an integration.
Controls
INT-1Level 1Never fetch code at run time. Don't run
pip installfrom inside the integration, and don't download a script and run it. List packages inmanifest.jsonwith exact versions, and Home Assistant installs them.manifest.json (part)"requirements": ["examplelib==2.4.1"]
INT-2Level 1Keep the login on every page you add.
HomeAssistantViewrequires 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 callsfrom 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 reasonclass StatusView(HomeAssistantView): url = "/api/example/status" name = "api:example:status" requires_auth = False # anyone on the networkIf 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().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__.pyfrom homeassistant.helpers.storage import Store store = Store(hass, 1, f"{DOMAIN}.cache") data = await store.async_load() or {} await store.async_save(data)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.pyfrom homeassistant.helpers.aiohttp_client import async_get_clientsession session = async_get_clientsession(hass)
INT-5Level 1Avoid the calls that turn data into code:
pickle.load,eval,exec,yaml.loadwithout a safe loader, andsubprocesswithshell=True.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.
Attacks on npm, PyPI and GitHub Actions
How six attacks on npm, PyPI and GitHub Actions worked, and which controls would have stopped them.
None of these attacks happened in the Home Assistant Marketplace, and the 2026 sweep found no malware there. The projects here were the victims, and several of them published detailed reports afterwards. Every fact on this page comes from those reports, the registry, GitHub or CISA, linked under each attack.
Phished logins on PyPI and npm, 2025
In July 2025, PyPI found a phishing campaign that sent package maintainers to pypj.org, a lookalike of pypi.org. Four accounts were phished. With one of them, the attacker created API tokens and uploaded two releases of num2words, 0.5.15 and 0.5.16, with malware in them. PyPI removed the releases and revoked the tokens. PyPI's report says the fake site worked as a proxy, so it could capture authenticator-app codes and session cookies as well as passwords. It recommends WebAuthn, meaning a passkey or a security key.
On September 8, 2025, the maintainer of debug, chalk and 16 other npm packages got a 2FA reset email from npmjs.help, which the maintainer later called "shockingly authentic". The npm account was taken over, and new versions such as debug 4.4.2 and chalk 5.6.1 were published with code that redirected cryptocurrency transactions in the browser to the attacker's addresses. npm removed them over the course of the day.
A lookalike site collects the password and the 2FA code.
ACC-1 A passkey or security key only signs in to the site it was made for, so it gives a lookalike nothing to pass on.
The attacker publishes new versions from the maintainer's account.
No control in the repository can stop a publish from the maintainer's own account. This step can only be prevented by ACC-1, in the step before.
Projects that use the package pick up the new version.
DEP-4 npm's versions were gone the same day, so with a 7-day cooldown Dependabot would never have offered them. DEP-3 With exact versions pinned, a new release only reaches your users through a pull request you merge.
Sources: PyPI's incident report, GitHub advisory GHSA-4x49-vf9v-38px, the maintainer's comment.
Shai-Hulud, a worm on npm, 2025
In September 2025, CISA warned of a self-replicating worm that had compromised more than 500 npm packages. Its install script collected GitHub personal access tokens and cloud keys for AWS, Google Cloud and Azure, sent them to the attacker and uploaded them to a public repository named Shai-Hulud. It then signed in to npm as the developer and published infected versions of their other packages, which spread it further. GitHub removed the packages. A second version, which GitHub described in December 2025, also registered infected machines as self-hosted runners and had what GitHub called "destructive functionality".
On December 9, 2025, npm revoked every classic token, limited write tokens to 90 days and made 2FA mandatory for publishing.
An infected version arrives through a dependency update.
DEP-4 A cooldown keeps it out while it's new. DEP-3 Exact pins mean it only arrives in a pull request.
Its install script collects every token it can find, on a laptop or in CI.
ACC-2 A fine-grained token only reaches the repositories and permissions it was given, and it expires. CI-7 A read-only workflow token can't push code or publish anything. SEC-4 With trusted publishing, CI holds no publishing token for the script to find.
It publishes as the developer and keeps whatever access it was given.
ACC-3 CISA's advice included removing the GitHub Apps and OAuth apps you don't need. It also recommended branch protection (BR-1), secret scanning (CI-3) and Dependabot security updates (CI-2).
Sources: CISA's alert, GitHub, September 2025, GitHub, December 2025, npm's token changes.
tj-actions/changed-files, a GitHub Action, March 2025
tj-actions/changed-files was used by over 23,000 repositories. In March 2025, several of its version tags were changed to point to a malicious commit. Workflows that used those tags ran code that read secrets from the runner's memory and printed them in the workflow log, where anyone could read them in a public repository. CISA says an earlier compromise of another action, reviewdog/action-setup, may have made it possible.
Someone with access moves the action's published tags to a new commit.
BR-4 REL-3 For anyone who publishes an action, a tag ruleset or immutable releases stop a published tag from moving.
Every workflow that names the action by tag runs the new code on its next run.
CI-10 A workflow pinned to a commit SHA keeps running the commit it was pinned to.
The code reads the secrets in the job.
CI-7 REL-2 If the job only has a read-only token and no publishing secrets, that's all the code can read.
Sources: GitHub advisory GHSA-mrrh-fwg8-r2c3 (CVE-2025-30066), CISA's alert.
Ultralytics, Nx and TanStack, 2024 to 2026
In December 2024, malicious releases of the Python package ultralytics (8.3.41 and 8.3.42) came out of the project's own release workflow, after an attacker got into its GitHub Actions workflows and poisoned the Actions cache used in the build. Two more (8.3.45 and 8.3.46) were uploaded with a PyPI API token that the workflow could still reach, left over from before the project moved to Trusted Publishing. PyPI's advice was to avoid pull_request_target and shared caches, use Trusted Publishing, and revoke tokens you don't use.
In August 2025, a workflow in the Nx project that checked pull request titles ran on pull_request_target and put the title straight into a shell command. A pull request with a crafted title ran commands with a read and write GitHub token. With it, the attacker pushed a branch that changed a script, started the publish workflow and took its npm token. Malicious versions were live for 4 hours on August 26. Their install script searched the machine for secrets, tried to use local AI tools such as Claude and Gemini, and uploaded what it found to a public GitHub repository.
In May 2026, a TanStack workflow that measured bundle size ran on pull_request_target and built the pull request's code. That code saved a poisoned package store into the Actions cache, under the key the release workflow restores on every push to main. When the release workflow next ran, the malware read its short-lived publishing token from the runner's memory and published 84 versions of 42 packages to npm through trusted publishing. "No npm tokens were stolen," TanStack's postmortem says. An outside researcher reported it 26 minutes after the first publish, and npm had removed all of them within about four and a half hours.
A workflow runs a stranger's pull request with the repository's own access.
CI-9 Never run a pull request's code in a
pull_request_targetworkflow. CI-8 Keep text like a pull request's title out ofrun:lines.The pull request's code reaches the release, through a token, a script or a shared cache.
CI-7 With a read-only default token, Nx's title-check workflow would have had nothing to push a branch with. REL-2 A release environment keeps publishing secrets away from other workflows.
The release goes out with the project's own credentials.
SEC-4 Trusted publishing leaves no token to steal. Ultralytics' second pair of releases used a token left over from before the move. It can't help once untrusted code runs inside the release job, which is what happened at TanStack. DEP-4 For projects that use these packages, a 7-day cooldown would have kept out Nx's and TanStack's versions, which were gone within hours.
Sources: PyPI's analysis of the Ultralytics attack, Nx's postmortem, TanStack's postmortem.
xz-utils, 2024
The release tarballs of xz-utils 5.6.0 and 5.6.1 contained a backdoor (CVE-2024-3094). The project's original maintainer wrote that they were created and signed by Jia Tan, and that the backdoor's files in the repository were harmless without the trigger code, which "was never included in the Git repository". So reading the repository wouldn't have shown the backdoor, because only the release files had all of it.
A release file is made by hand, outside CI.
REL-1 When a workflow builds the release from main and attests it, the release is the code in the repository, and anyone can check that with
gh attestation verify.Reviewers read the repository, and users install the release.
The 2026 sweep found 84 Marketplace apps whose release code differs from their repository.
Sources: CVE-2024-3094, the maintainer's page on the backdoor.
event-stream, 2018
npm's report says an attacker, "posing as a maintainer", took over maintainership of the event-stream package, and on September 9, 2018, added a new dependency, flatmap-stream, in version 3.3.6. Its code was written for one app, the Copay bitcoin wallet, and harvested account details and private keys from wallets holding more than 100 bitcoin or 1,000 bitcoin cash. Copay shipped it in versions 5.0.2 to 5.1.0. npm's security team heard about it on November 26, more than two months later.
A package changes hands.
DEP-2 Check who maintains a package before you add it. DEP-6 Replace packages nobody looks after. ACC-6 For your own project, plan who takes over if you step away.
A new dependency arrives in an update.
DEP-3 With exact pins, it only arrives in a pull request, where the new dependency is in the diff.
Source: npm's report.
# 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. Source: https://ha-barkley.github.io/security/controls/integrations/ From HASC, the Home Assistant Security Controls for integrations, cards and apps. A community catalog, not an official Home Assistant or Open Home Foundation project. Each control has an ID, cited as HASC-CI-4, and a level from 1 to 3. "Level marker" means anyone can check the control from outside the project, and levels are graded on those controls only. > **From the 2026 sweep.** 235 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](https://ha-barkley.github.io/marketplace/2026/malware-and-ways-in/) has more on this. These steps apply only if you publish an integration. ## Controls ### INT-1: Never fetch code at run time *Level 1 · Applies to integrations* 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"] ``` ### INT-2: Keep the login on every page you add *Level 1 · Applies to integrations* `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()`. ### INT-3: Save settings and state with the storage helper, and never with pickle *Level 1 · Applies to integrations* 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) ``` ### INT-4: Use Home Assistant's shared web session *Level 1 · Applies to integrations* **Use 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) ``` ### INT-5: Avoid the calls that turn data into code *Level 1 · Applies to integrations* `pickle.load`, `eval`, `exec`, `yaml.load` without a safe loader, and `subprocess` with `shell=True`. ### INT-6: Send each credential only to its own service *Level 1 · Applies to integrations* 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.