Your ticks and choices are saved in this browser only.
Runbooks
Pick what happened. The steps are in the order to do them.
Look at the report
Keep it private until the fix is out, so nobody can use it against your users in the meantime.
- ### Accept the report as a draft advisory *Level 1* A report sent through private vulnerability reporting is on your repository's Security and quality tab, under Advisories. You can ask the reporter questions there, reject it, or choose **Accept and open as draft**, which keeps it private ([GitHub's docs](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/managing-privately-reported-security-vulnerabilities)). If the report came another way, such as an email, start a draft advisory yourself on the same page and copy the details in.
Accept the report as a draft advisory. A report sent through private vulnerability reporting is on your repository's Security and quality tab, under Advisories. You can ask the reporter questions there, reject it, or choose Accept and open as draft, which keeps it private (GitHub's docs). If the report came another way, such as an email, start a draft advisory yourself on the same page and copy the details in.
- ### POL-4: When a report comes in *Level 1* **When a report comes in,** fix it in the advisory's private fork, release the fix, then publish the advisory. You can request a CVE from the advisory. If your code is also published as a package on PyPI or npm, Dependabot then alerts the projects that depend on it. > Publishing the advisory deletes its private fork, so merge the fix first ([GitHub's docs](https://docs.github.com/en/code-security/security-advisories/working-with-repository-security-advisories/publishing-a-repository-security-advisory)).
POL-4Level 1When a report comes in, fix it in the advisory's private fork, release the fix, then publish the advisory. You can request a CVE from the advisory. If your code is also published as a package on PyPI or npm, Dependabot then alerts the projects that depend on it.
Publishing the advisory deletes its private fork, so merge the fix first (GitHub's docs).
Afterwards
If the report didn't come through GitHub, set these up so the next one does.
- ### POL-1: Turn on private vulnerability reporting *Level 1* Settings → Advanced Security → Private vulnerability reporting → Enable. People then get a "Report a vulnerability" button on your Security and quality tab, and their report reaches you privately. You can ask questions, reject it, or accept it as a draft advisory to work in.
POL-1Level 1Turn on private vulnerability reporting. Settings → Advanced Security → Private vulnerability reporting → Enable. People then get a "Report a vulnerability" button on your Security and quality tab, and their report reaches you privately. You can ask questions, reject it, or accept it as a draft advisory to work in.
- ### POL-2: Add a SECURITY.md *Level 1 · Level marker* **Add a SECURITY.md** that points to it. In an organization, one `SECURITY.md` in its public `.github` repository covers every repository that doesn't have its own (see [Organizations](https://ha-barkley.github.io/security/controls/organizations/)). `SECURITY.md` ``` # Security policy ## Reporting a problem Please don't open a public issue. Report it privately through GitHub: https://github.com/OWNER/REPO/security/advisories/new I'll reply within 7 days and keep you posted until it's fixed. ## Supported versions Only the latest release gets security fixes. ```
POL-2Level 1Level markerAdd a SECURITY.md that points to it. In an organization, one
SECURITY.mdin its public.githubrepository covers every repository that doesn't have its own (see Organizations).SECURITY.md# Security policy ## Reporting a problem Please don't open a public issue. Report it privately through GitHub: https://github.com/OWNER/REPO/security/advisories/new I'll reply within 7 days and keep you posted until it's fixed. ## Supported versions Only the latest release gets security fixes.
- ### REPO-2: Turn off blank issues and link the private report *Level 1* `.github/ISSUE_TEMPLATE/config.yml` ``` blank_issues_enabled: false contact_links: - name: Report a security problem url: https://github.com/OWNER/REPO/security/advisories/new about: Please report security problems privately, not as an issue. ```
REPO-2Level 1Turn off blank issues and link the private report.
.github/ISSUE_TEMPLATE/config.ymlblank_issues_enabled: false contact_links: - name: Report a security problem url: https://github.com/OWNER/REPO/security/advisories/new about: Please report security problems privately, not as an issue.
Lock them out
Do these first, from a device you trust. If you can't sign in, or someone changed your email or two-factor settings, contact GitHub Support (GitHub's docs).
- ### Change your password and check your email addresses *Level 1* Settings → Password and authentication, then Settings → Emails. Remove any address you didn't add.
Change your password and check your email addresses. Settings → Password and authentication, then Settings → Emails. Remove any address you didn't add.
- ### ACC-1: Turn on two-factor login with a passkey or a security key *Level 1* **Why:** A common way to take over an account is a page that looks like a real login. A password and an authenticator code work on any site you type them into, and a lookalike can pass them straight on to the real one. A passkey or security key only works on the site it was made for. In 2025, phishing like this was used to publish malware from maintainers' accounts on both PyPI and npm ([how it happened](https://ha-barkley.github.io/security/attacks/#phishing)). Settings → Password and authentication. An authenticator app is fine as a second method. Avoid SMS. Store the recovery codes somewhere offline. > A lookalike login page can pass on an authenticator app's code as well as your password. Add a passkey or a security key, and generate new recovery codes on the same page.
ACC-1Level 1Turn on two-factor login with a passkey or a security key.
Why A common way to take over an account is a page that looks like a real login. A password and an authenticator code work on any site you type them into, and a lookalike can pass them straight on to the real one. A passkey or security key only works on the site it was made for. In 2025, phishing like this was used to publish malware from maintainers' accounts on both PyPI and npm (how it happened).
Settings → Password and authentication. An authenticator app is fine as a second method. Avoid SMS. Store the recovery codes somewhere offline.
A lookalike login page can pass on an authenticator app's code as well as your password. Add a passkey or a security key, and generate new recovery codes on the same page.
- ### ACC-3: Review what can act for you *Level 1* **Why:** Every OAuth app, GitHub App, SSH key and signed-in session can act for you without your password, and each is another way into your account. Some were probably added years ago for something you no longer use. After the Shai-Hulud worm, CISA's advice included removing the GitHub Apps and OAuth apps you don't need ([how it happened](https://ha-barkley.github.io/security/attacks/#shai-hulud)). Settings → Applications (OAuth apps and GitHub Apps), SSH keys, and Sessions. Remove anything you don't recognize or no longer use. > Sign out every session you don't recognize, and remove every SSH key and app you didn't add. A new password doesn't stop any of them.
ACC-3Level 1Review what can act for you.
Why Every OAuth app, GitHub App, SSH key and signed-in session can act for you without your password, and each is another way into your account. Some were probably added years ago for something you no longer use. After the Shai-Hulud worm, CISA's advice included removing the GitHub Apps and OAuth apps you don't need (how it happened).
Settings → Applications (OAuth apps and GitHub Apps), SSH keys, and Sessions. Remove anything you don't recognize or no longer use.
Sign out every session you don't recognize, and remove every SSH key and app you didn't add. A new password doesn't stop any of them.
- ### ACC-2: Replace classic personal access tokens with fine-grained ones *Level 1* **Why:** A token works for anyone who has a copy, with no password or 2FA, and copies end up in CI secrets, `.env` files and old laptops. A classic token can act on every repository you can reach and never expires. A fine-grained one only reaches the repository and permissions you gave it, until its expiry date. The Shai-Hulud worm collected tokens like these from developers' machines and CI in 2025 ([how it happened](https://ha-barkley.github.io/security/attacks/#shai-hulud)). Settings → Developer settings → Personal access tokens. Give each token one repository, only the permissions it needs, and an expiry date. Delete tokens you no longer use. > Delete every token you don't recognize and every token that was on the affected machine, then create new ones.
ACC-2Level 1Replace classic personal access tokens with fine-grained ones.
Why A token works for anyone who has a copy, with no password or 2FA, and copies end up in CI secrets,
.envfiles and old laptops. A classic token can act on every repository you can reach and never expires. A fine-grained one only reaches the repository and permissions you gave it, until its expiry date. The Shai-Hulud worm collected tokens like these from developers' machines and CI in 2025 (how it happened).Settings → Developer settings → Personal access tokens. Give each token one repository, only the permissions it needs, and an expiry date. Delete tokens you no longer use.
Delete every token you don't recognize and every token that was on the affected machine, then create new ones.
Find out what was done
Check what was changed while they had access.
- ### Read your security log *Level 1* Settings → Security log lists what was done with your account in the last 90 days. Look for new tokens, keys, apps and email addresses, and for changes to repositories ([GitHub's docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-security-log)). In an organization, an owner can also read its audit log, which goes back 180 days ([GitHub's docs](https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/reviewing-the-audit-log-for-your-organization)).
Read your security log. Settings → Security log lists what was done with your account in the last 90 days. Look for new tokens, keys, apps and email addresses, and for changes to repositories (GitHub's docs). In an organization, an owner can also read its audit log, which goes back 180 days (GitHub's docs).
- ### Check every repository you can write to *Level 1* Look at recent commits on every branch, and at collaborators, deploy keys, webhooks and workflows. If a release or a tag changed, also pick *A bad release went out* above.
Check every repository you can write to. Look at recent commits on every branch, and at collaborators, deploy keys, webhooks and workflows. If a release or a tag changed, also pick A bad release went out above.
- ### Replace the repositories' secrets *Level 1* Anyone who can push a workflow can use a repository's Actions secrets, so treat them as leaked. Get a new credential from wherever each one came from, such as PyPI or npm, update the secret, then revoke the old one.
Replace the repositories' secrets. Anyone who can push a workflow can use a repository's Actions secrets, so treat them as leaked. Get a new credential from wherever each one came from, such as PyPI or npm, update the secret, then revoke the old one.
Afterwards
With signed commits, a commit pushed with a stolen token shows "Unverified". With no stored secrets, CI has nothing to take.
- ### ACC-4: Sign your commits *Level 2 · Level marker* **Why:** Git lets anyone put any name and email on a commit. A signature can't be made without your key, so signed commits let people tell your work from a commit pushed with a stolen token or written to look like yours. In 2021, two malicious commits were pushed to PHP's source code in the names of two of its core developers ([PHP's announcement](https://news-web.php.net/php.internals/113838)). An SSH key is the simplest way. You can use the one you already push with. 1. If you don't have an SSH key, run `ssh-keygen -t ed25519`. It saves the public half as `~/.ssh/id_ed25519.pub`. 2. Tell Git to sign every commit and tag with it. `Terminal` ``` git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519.pub git config --global commit.gpgsign true git config --global tag.gpgsign true ``` Change the path if your key has a different name. 3. Give GitHub the public key, so it can check your signatures. Until you do, your signed commits show "Unverified". In Settings → SSH and GPG keys, choose New SSH key, set Key type to *Signing Key*, and paste the line that `cat ~/.ssh/id_ed25519.pub` prints. Only share the file ending in `.pub`. The one without `.pub` is your private key. From a terminal, the GitHub CLI can do it instead: `Terminal` ``` gh auth refresh -h github.com -s admin:ssh_signing_key gh ssh-key add ~/.ssh/id_ed25519.pub --type signing --title "My laptop" ``` A key you already added for pushing has to be added again as a signing key. Where the private key is kept decides what someone gets if they copy your files or run code on your machine: | Where the key is | Someone copies your files | Malware runs as you | Day to day | |-----------------------------------------------------|-----------------------------------|-----------------------------------|-------------------------------------------------------------------| | A file with no passphrase | They have your key | Can sign | Nothing to type | | A file with a passphrase, loaded into the SSH agent | Useless without the passphrase | Can sign while the key is loaded | Unlock once per login. macOS can keep the passphrase in Keychain. | | A password manager's SSH agent | There's no key file | Asks before each app uses the key | Approve each app | | A security key (`ssh-keygen -t ed25519-sk`) | The key never leaves the hardware | Needs a touch for every signature | A touch for every commit, so a rebase of 20 commits is 20 touches | With a password manager, its own instructions give the value for `user.signingkey`. GPG keys work too, with GitHub's GPG instructions. In a codespace you don't need a key of your own. Turn on Settings → Codespaces → GPG verification for the repositories you trust, and GitHub signs the commits you make there. Commits you make on GitHub's website are signed by GitHub already.
ACC-4Level 2Level markerSign your commits.
Why Git lets anyone put any name and email on a commit. A signature can't be made without your key, so signed commits let people tell your work from a commit pushed with a stolen token or written to look like yours. In 2021, two malicious commits were pushed to PHP's source code in the names of two of its core developers (PHP's announcement).
An SSH key is the simplest way. You can use the one you already push with.
- If you don't have an SSH key, run
ssh-keygen -t ed25519. It saves the public half as~/.ssh/id_ed25519.pub. - Tell Git to sign every commit and tag with it.Change the path if your key has a different name.Terminal
git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519.pub git config --global commit.gpgsign true git config --global tag.gpgsign true
- Give GitHub the public key, so it can check your signatures. Until you do, your signed commits show "Unverified". In Settings → SSH and GPG keys, choose New SSH key, set Key type to Signing Key, and paste the line that
cat ~/.ssh/id_ed25519.pubprints. Only share the file ending in.pub. The one without.pubis your private key. From a terminal, the GitHub CLI can do it instead:A key you already added for pushing has to be added again as a signing key.Terminalgh auth refresh -h github.com -s admin:ssh_signing_key gh ssh-key add ~/.ssh/id_ed25519.pub --type signing --title "My laptop"
Where the private key is kept decides what someone gets if they copy your files or run code on your machine:
Where the key is Someone copies your files Malware runs as you Day to day A file with no passphrase They have your key Can sign Nothing to type A file with a passphrase, loaded into the SSH agent Useless without the passphrase Can sign while the key is loaded Unlock once per login. macOS can keep the passphrase in Keychain. A password manager's SSH agent There's no key file Asks before each app uses the key Approve each app A security key ( ssh-keygen -t ed25519-sk)The key never leaves the hardware Needs a touch for every signature A touch for every commit, so a rebase of 20 commits is 20 touches With a password manager, its own instructions give the value for
user.signingkey. GPG keys work too, with GitHub's GPG instructions.In a codespace you don't need a key of your own. Turn on Settings → Codespaces → GPG verification for the repositories you trust, and GitHub signs the commits you make there. Commits you make on GitHub's website are signed by GitHub already.
- If you don't have an SSH key, run
- ### ACC-5: Then turn on vigilant mode *Level 2* **Why:** Signing only helps if an unsigned commit in your name stands out. Without vigilant mode, GitHub shows an unsigned commit with no label, like most commits. With it on, an unsigned commit in your name shows "Unverified". On the same page, tick "Flag unsigned commits as unverified". Any commit with your name that you didn't sign then shows "Unverified", including one pushed with a stolen token. Wait until a commit you push shows "Verified", or your own commits show "Unverified" too.
ACC-5Level 2Then turn on vigilant mode.
Why Signing only helps if an unsigned commit in your name stands out. Without vigilant mode, GitHub shows an unsigned commit with no label, like most commits. With it on, an unsigned commit in your name shows "Unverified".
On the same page, tick "Flag unsigned commits as unverified". Any commit with your name that you didn't sign then shows "Unverified", including one pushed with a stolen token. Wait until a commit you push shows "Verified", or your own commits show "Unverified" too.
- ### SEC-4: In CI, prefer no secret at all *Level 2* Use the built-in `GITHUB_TOKEN` with the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
SEC-4Level 2In CI, prefer no secret at all. Use the built-in
GITHUB_TOKENwith the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
Revoke it
Revoke it before anything else. Cleaning it out of the code or the history can wait.
- ### SEC-5: If a secret leaks, revoke it first *Level 1* Removing it from the history doesn't help, because clones, forks and caches already have a copy. Issue a new key, then clean up the history.
SEC-5Level 1If a secret leaks, revoke it first. Removing it from the history doesn't help, because clones, forks and caches already have a copy. Issue a new key, then clean up the history.
- ### Check what it was used for *Level 1* For a GitHub token, your security log shows what was done with it ([GitHub's docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-security-log)). For a PyPI or npm token, look at the package's release history for versions you didn't publish. For another service's key, check that service's logs. If a release changed, also pick *A bad release went out* above.
Check what it was used for. For a GitHub token, your security log shows what was done with it (GitHub's docs). For a PyPI or npm token, look at the package's release history for versions you didn't publish. For another service's key, check that service's logs. If a release changed, also pick A bad release went out above.
- ### Find out how it got out *Level 1* It might have been a commit, a workflow log or a lost laptop. Fix that too, or the new key can leak the same way.
Find out how it got out. It might have been a commit, a workflow log or a lost laptop. Fix that too, or the new key can leak the same way.
Afterwards
These keep the next key out of the repository, and leave fewer keys to leak.
- ### REPO-3: Add a .gitignore *Level 1* **Add a .gitignore** before your first commit. `.gitignore` ``` # Python __pycache__/ *.py[cod] .venv/ .pytest_cache/ .ruff_cache/ .coverage # Node node_modules/ # Secrets and local settings .env .env.* secrets.yaml *.pem *.key # Editors and OS .idea/ .DS_Store ```
REPO-3Level 1Add a .gitignore before your first commit.
.gitignore# Python __pycache__/ *.py[cod] .venv/ .pytest_cache/ .ruff_cache/ .coverage # Node node_modules/ # Secrets and local settings .env .env.* secrets.yaml *.pem *.key # Editors and OS .idea/ .DS_Store
- ### CI-3: Turn on secret scanning and push protection *Level 1* Settings → Advanced Security. Push protection stops a push that contains a known token format before it reaches GitHub.
CI-3Level 1Turn on secret scanning and push protection. Settings → Advanced Security. Push protection stops a push that contains a known token format before it reaches GitHub.
- ### ACC-2: Replace classic personal access tokens with fine-grained ones *Level 1* **Why:** A token works for anyone who has a copy, with no password or 2FA, and copies end up in CI secrets, `.env` files and old laptops. A classic token can act on every repository you can reach and never expires. A fine-grained one only reaches the repository and permissions you gave it, until its expiry date. The Shai-Hulud worm collected tokens like these from developers' machines and CI in 2025 ([how it happened](https://ha-barkley.github.io/security/attacks/#shai-hulud)). Settings → Developer settings → Personal access tokens. Give each token one repository, only the permissions it needs, and an expiry date. Delete tokens you no longer use.
ACC-2Level 1Replace classic personal access tokens with fine-grained ones.
Why A token works for anyone who has a copy, with no password or 2FA, and copies end up in CI secrets,
.envfiles and old laptops. A classic token can act on every repository you can reach and never expires. A fine-grained one only reaches the repository and permissions you gave it, until its expiry date. The Shai-Hulud worm collected tokens like these from developers' machines and CI in 2025 (how it happened).Settings → Developer settings → Personal access tokens. Give each token one repository, only the permissions it needs, and an expiry date. Delete tokens you no longer use.
- ### SEC-4: In CI, prefer no secret at all *Level 2* Use the built-in `GITHUB_TOKEN` with the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
SEC-4Level 2In CI, prefer no secret at all. Use the built-in
GITHUB_TOKENwith the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
Take it down
If someone else published it, lock them out first. Pick Someone got into my GitHub account or A token or key leaked above, then come back.
- ### Work out which versions are bad *Level 1* Compare each recent release's files and tag with main. A tag on a commit that isn't on main, or a file your workflow didn't build, is suspect. If your releases are attested, `gh attestation verify` fails for a file your workflow didn't build ([Releases](https://ha-barkley.github.io/security/controls/releases/)).
Work out which versions are bad. Compare each recent release's files and tag with main. A tag on a commit that isn't on main, or a file your workflow didn't build, is suspect. If your releases are attested,
gh attestation verifyfails for a file your workflow didn't build (Releases). - ### Delete the bad releases *Level 1* Delete each one, and its tag, on the repository's Releases page. An immutable release can be deleted too, but its tag name can't be used again ([GitHub's docs](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases)). For an app, also delete the image version on the package's page ([GitHub's docs](https://docs.github.com/en/packages/learn-github-packages/deleting-and-restoring-a-package)). If you published to PyPI or npm, remove it there as well.
Delete the bad releases. Delete each one, and its tag, on the repository's Releases page. An immutable release can be deleted too, but its tag name can't be used again (GitHub's docs). For an app, also delete the image version on the package's page (GitHub's docs). If you published to PyPI or npm, remove it there as well.
- ### Release a fixed version with a higher number *Level 1* A higher version than the bad one moves everyone past it on their next update. Build it from main with your release workflow.
Release a fixed version with a higher number. A higher version than the bad one moves everyone past it on their next update. Build it from main with your release workflow.
- ### Tell your users *Level 1* Publish a security advisory that lists the bad versions and the fixed one ([Security policy](https://ha-barkley.github.io/security/controls/security-policy/#pol-4)), and pin an issue that says the same. If the bad version could have taken something from users, such as passwords or tokens, say what, so they can change it.
Tell your users. Publish a security advisory that lists the bad versions and the fixed one (Security policy), and pin an issue that says the same. If the bad version could have taken something from users, such as passwords or tokens, say what, so they can change it.
Afterwards
These tie each release to a workflow run on main, so a release made any other way is easy to spot.
- ### REL-1: Build and publish releases from a workflow *Level 3 · Level marker* **Build and publish releases from a workflow** instead of your laptop. This one zips an integration, refuses a tag that isn't on main, adds a provenance attestation, and publishes the release with the zip in one step. `.github/workflows/release.yaml` ``` name: Release on: push: tags: ["v*"] permissions: contents: write id-token: write attestations: write jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Only release code that's on main run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main - name: Zip the integration run: | cd custom_components/your_domain zip -r "$GITHUB_WORKSPACE/your_domain.zip" . - uses: actions/attest-build-provenance@v4 with: subject-path: your_domain.zip - name: Publish the release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" your_domain.zip --verify-tag --generate-notes ``` Tell the Marketplace to install the zip with `"zip_release": true` and `"filename": "your_domain.zip"` in `hacs.json`. For a card, build the bundle in the workflow and attach the built file instead. The "Only release code that's on main" step catches a tag pushed from the wrong branch by mistake. It can't stop someone with write access. The workflow that runs is the one in the tagged commit, so they could tag a commit whose workflow leaves that step out. A tag ruleset with *Restrict creations* stops that, because only the people on its bypass list can create release tags (see [Branch and tag protection](https://ha-barkley.github.io/security/controls/branches-and-tags/)).
REL-1Level 3Level markerBuild and publish releases from a workflow instead of your laptop. This one zips an integration, refuses a tag that isn't on main, adds a provenance attestation, and publishes the release with the zip in one step.
.github/workflows/release.yamlname: Release on: push: tags: ["v*"] permissions: contents: write id-token: write attestations: write jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Only release code that's on main run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main - name: Zip the integration run: | cd custom_components/your_domain zip -r "$GITHUB_WORKSPACE/your_domain.zip" . - uses: actions/attest-build-provenance@v4 with: subject-path: your_domain.zip - name: Publish the release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" your_domain.zip --verify-tag --generate-notesTell the Marketplace to install the zip with
"zip_release": trueand"filename": "your_domain.zip"inhacs.json. For a card, build the bundle in the workflow and attach the built file instead.The "Only release code that's on main" step catches a tag pushed from the wrong branch by mistake. It can't stop someone with write access. The workflow that runs is the one in the tagged commit, so they could tag a commit whose workflow leaves that step out. A tag ruleset with Restrict creations stops that, because only the people on its bypass list can create release tags (see Branch and tag protection).
- ### BR-4: Add a tag ruleset for your release tags *Level 3 (or immutable releases) · Level marker* Settings → Rules → Rulesets → New tag ruleset. - Enforcement: *Active*. A disabled ruleset protects nothing. - Target: `v*`, or however you name versions. - Turn on *Restrict updates* and *Restrict deletions*, so a published version can't be moved to different code later. - Turn on *Restrict creations* if only you should cut releases. Then add the Repository admin role to the bypass list, or you won't be able to push new tags either.
BR-4Level 3 (or immutable releases)Level markerAdd a tag ruleset for your release tags. Settings → Rules → Rulesets → New tag ruleset.
- Enforcement: Active. A disabled ruleset protects nothing.
- Target:
v*, or however you name versions. - Turn on Restrict updates and Restrict deletions, so a published version can't be moved to different code later.
- Turn on Restrict creations if only you should cut releases. Then add the Repository admin role to the bypass list, or you won't be able to push new tags either.
- ### REL-3: Turn on immutable releases *Level 3 (or a tag ruleset) · Level marker* **Turn on immutable releases** (Settings → General → Releases), so a published release's files and tag can't be swapped later. It applies to releases you publish after turning it on. Because assets can't be added after publishing, the workflow above creates the release and its file together.
REL-3Level 3 (or a tag ruleset)Level markerTurn on immutable releases (Settings → General → Releases), so a published release's files and tag can't be swapped later. It applies to releases you publish after turning it on. Because assets can't be added after publishing, the workflow above creates the release and its file together.
- ### SEC-4: In CI, prefer no secret at all *Level 2* Use the built-in `GITHUB_TOKEN` with the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
SEC-4Level 2In CI, prefer no secret at all. Use the built-in
GITHUB_TOKENwith the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.
Your GitHub account
Whoever controls your GitHub account controls what every user of your app installs next. Nothing in the repository can protect against a stolen login.
Controls
ACC-1Level 1Turn on two-factor login with a passkey or a security key.
Why A common way to take over an account is a page that looks like a real login. A password and an authenticator code work on any site you type them into, and a lookalike can pass them straight on to the real one. A passkey or security key only works on the site it was made for. In 2025, phishing like this was used to publish malware from maintainers' accounts on both PyPI and npm (how it happened).
Settings → Password and authentication. An authenticator app is fine as a second method. Avoid SMS. Store the recovery codes somewhere offline.
ACC-2Level 1Replace classic personal access tokens with fine-grained ones.
Why A token works for anyone who has a copy, with no password or 2FA, and copies end up in CI secrets,
.envfiles and old laptops. A classic token can act on every repository you can reach and never expires. A fine-grained one only reaches the repository and permissions you gave it, until its expiry date. The Shai-Hulud worm collected tokens like these from developers' machines and CI in 2025 (how it happened).Settings → Developer settings → Personal access tokens. Give each token one repository, only the permissions it needs, and an expiry date. Delete tokens you no longer use.
ACC-3Level 1Review what can act for you.
Why Every OAuth app, GitHub App, SSH key and signed-in session can act for you without your password, and each is another way into your account. Some were probably added years ago for something you no longer use. After the Shai-Hulud worm, CISA's advice included removing the GitHub Apps and OAuth apps you don't need (how it happened).
Settings → Applications (OAuth apps and GitHub Apps), SSH keys, and Sessions. Remove anything you don't recognize or no longer use.
ACC-4Level 2Level markerSign your commits.
Why Git lets anyone put any name and email on a commit. A signature can't be made without your key, so signed commits let people tell your work from a commit pushed with a stolen token or written to look like yours. In 2021, two malicious commits were pushed to PHP's source code in the names of two of its core developers (PHP's announcement).
An SSH key is the simplest way. You can use the one you already push with.
- If you don't have an SSH key, run
ssh-keygen -t ed25519. It saves the public half as~/.ssh/id_ed25519.pub. - Tell Git to sign every commit and tag with it.Change the path if your key has a different name.Terminal
git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519.pub git config --global commit.gpgsign true git config --global tag.gpgsign true
- Give GitHub the public key, so it can check your signatures. Until you do, your signed commits show "Unverified". In Settings → SSH and GPG keys, choose New SSH key, set Key type to Signing Key, and paste the line that
cat ~/.ssh/id_ed25519.pubprints. Only share the file ending in.pub. The one without.pubis your private key. From a terminal, the GitHub CLI can do it instead:A key you already added for pushing has to be added again as a signing key.Terminalgh auth refresh -h github.com -s admin:ssh_signing_key gh ssh-key add ~/.ssh/id_ed25519.pub --type signing --title "My laptop"
Where the private key is kept decides what someone gets if they copy your files or run code on your machine:
Where the key is Someone copies your files Malware runs as you Day to day A file with no passphrase They have your key Can sign Nothing to type A file with a passphrase, loaded into the SSH agent Useless without the passphrase Can sign while the key is loaded Unlock once per login. macOS can keep the passphrase in Keychain. A password manager's SSH agent There's no key file Asks before each app uses the key Approve each app A security key ( ssh-keygen -t ed25519-sk)The key never leaves the hardware Needs a touch for every signature A touch for every commit, so a rebase of 20 commits is 20 touches With a password manager, its own instructions give the value for
user.signingkey. GPG keys work too, with GitHub's GPG instructions.In a codespace you don't need a key of your own. Turn on Settings → Codespaces → GPG verification for the repositories you trust, and GitHub signs the commits you make there. Commits you make on GitHub's website are signed by GitHub already.
- If you don't have an SSH key, run
ACC-5Level 2Then turn on vigilant mode.
Why Signing only helps if an unsigned commit in your name stands out. Without vigilant mode, GitHub shows an unsigned commit with no label, like most commits. With it on, an unsigned commit in your name shows "Unverified".
On the same page, tick "Flag unsigned commits as unverified". Any commit with your name that you didn't sign then shows "Unverified", including one pushed with a stolen token. Wait until a commit you push shows "Verified", or your own commits show "Unverified" too.
ACC-6Level 2Give the project a second maintainer, or at least a plan.
Why When one person can publish, nobody notices an odd release from that account, and nobody can step in if that person loses access or moves on. If its maintainer leaves without a plan, a project can pass to whoever asks for it. In 2018, someone posing as a maintainer took over the event-stream package on npm and added code that stole from bitcoin wallets (how it happened).
A free GitHub organization lets several people share a project and can require two-factor login for all of them. Organizations covers when it's worth it. If you're on your own, write down in the README who can take over.
Check it worked
Settings → Password and authentication lists a passkey or security key. Settings → Developer settings shows no classic tokens. Your recent commits show "Verified".
Branch and tag protection
Only people with write access can push to your repository. These rules stop a mistake, a rushed push or someone with a leaked token from changing what users install.
Why this matters
Your checks only protect users if code can't reach them any other way. Branch rules make main that place. Nothing lands there without passing the checks, and nobody can rewrite what's already there.
That only helps if your releases come from main too. A tag can point at any commit, including one on a side branch that never ran your checks, and a release built from it skips all of them. Tag rules then keep a published version from being moved to different code later.
Controls
BR-1Level 2Level markerAdd a branch ruleset for main. Settings → Rules → Rulesets → New branch ruleset.
- Enforcement: Active.
- Target: the default branch.
- Turn on Restrict deletions.
- Turn on Block force pushes.
- Turn on Require a pull request before merging. Zero required approvals is fine if you work alone, because the pull request still runs your checks before anything lands.
BR-3Level 2Keep the bypass list short. If you add yourself so you can merge in an emergency, every bypass is logged. Don't add bots or apps you don't control.
BR-4Level 3 (or immutable releases)Level markerAdd a tag ruleset for your release tags. Settings → Rules → Rulesets → New tag ruleset.
- Enforcement: Active. A disabled ruleset protects nothing.
- Target:
v*, or however you name versions. - Turn on Restrict updates and Restrict deletions, so a published version can't be moved to different code later.
- Turn on Restrict creations if only you should cut releases. Then add the Repository admin role to the bypass list, or you won't be able to push new tags either.
Check it worked
In a test clone, change the last commit with git commit --amend and try git push --force to main. GitHub should refuse it. Then move an old tag with git tag -f v1.0.0 HEAD and git push --force origin v1.0.0, which GitHub should refuse too. git fetch --tags --force puts your local tag back. If you're on the bypass list, both pushes go through.
Checks in CI
GitHub runs most of these for free on public repositories. Some are a switch in Settings; the rest are a short workflow file.
Controls
CI-1Level 1 (or a security workflow)Level markerTurn on CodeQL default setup. Settings → Advanced Security → Code scanning → CodeQL analysis → Set up → Default. It picks up Python, JavaScript and TypeScript, and runs on every pull request. Check that GitHub Actions is in its list of languages too, because that's the language that scans your workflow files, and default setup doesn't always include it. If it's missing, choose View CodeQL configuration, then Edit, select GitHub Actions under Languages, and choose Save changes.
CI-2Level 1Level markerTurn on Dependabot alerts and security updates in the same Settings page, then add version updates for your package files and your workflow actions.
.github/dependabot.ymlversion: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "weekly" cooldown: default-days: 7 - package-ecosystem: "npm" # cards: package.json and its lockfile directory: "/" schedule: interval: "weekly" cooldown: default-days: 7 - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" cooldown: default-days: 7Dependabot doesn't read an integration's
manifest.json. The workflow below checks those requirements with pip-audit instead.cooldownmakes Dependabot wait until a release is 7 days old before proposing it. It only delays version updates; security updates still arrive straight away.CI-3Level 1Turn on secret scanning and push protection. Settings → Advanced Security. Push protection stops a push that contains a known token format before it reaches GitHub.
CI-4Level 1 (or CodeQL)Level markerAdd a security workflow that runs on pull requests and on main. This one is for an integration; for a card, swap pip-audit for
npm audit --omit=dev..github/workflows/security.yamlname: Security on: pull_request: push: branches: [main] permissions: contents: read jobs: dependency-review: if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/dependency-review-action@v5 with: fail-on-severity: moderate pip-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-python@v7 with: python-version: "3.13" - run: pip install pip-audit==2.10.1 - name: Check the integration's requirements run: | jq -r '.requirements // [] | .[]' custom_components/your_domain/manifest.json > requirements.txt if [ -s requirements.txt ]; then pip-audit -r requirements.txt; fi ruff-security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: astral-sh/ruff-action@v4.1.0 with: args: check --select Sruff-action has no
v4tag, only exact versions such asv4.1.0, so it's pinned to one here.pip-audit sometimes reports a vulnerability that has no fixed version yet, so there's nothing to upgrade to and the job keeps failing. Check whether it affects how your integration uses the library. If it doesn't, skip that one finding with
--ignore-vuln IDand a comment saying why. An unpinned requirement resolves to its newest version on every run, so the result can change without a commit. Dependencies covers pinning.CI-5Level 1Validate against Home Assistant's own rules with hassfest and the Marketplace's validation action.
.github/workflows/validate.yamlname: Validate on: pull_request: push: branches: [main] permissions: contents: read jobs: hassfest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: home-assistant/actions/hassfest@master marketplace: runs-on: ubuntu-latest steps: - uses: hacs/action@main with: category: integrationFor a card, leave out the hassfest job, which only checks integrations, and set
category: plugin, the Marketplace's name for dashboard cards.CI-6Level 1 · optionalOptional: catch problems before you commit. pre-commit hooks run on your machine, so they're a convenience and can be skipped. Keep the CI checks too.
.pre-commit-config.yamlrepos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.17.6 # use the newest release hooks: - id: ruff-check args: [--extend-select, S] - repo: https://github.com/gitleaks/gitleaks rev: v8.30.1 hooks: - id: gitleaks
Keep the workflows and their tokens safe
Every workflow run gets a token that can act on your repository, and every action and script in the run can use it. These steps keep that token weak and keep strangers' text from running as code.
CI-7Level 1Give workflows read-only tokens. Set
permissions: contents: readat the top of every workflow and widen it only in the job that needs more. Then make read-only the default under Settings → Actions → General → Workflow permissions, and untick Allow GitHub Actions to create and approve pull requests. Repositories created since 2023 start read-only, but older ones may still give every workflow write access.CI-8Level 1Keep untrusted text out of
run:lines. An issue title, a pull request title or a branch name is chosen by whoever opens it. Written straight into arun:line with${{ }}, it runs as a shell command with your token. Pass it throughenv:instead, so the shell treats it as text.Do pass it as a variable- name: Log the new issue env: TITLE: ${{ github.event.issue.title }} run: echo "New issue: $TITLE"Don't write it into the command- name: Log the new issue run: echo "New issue: ${{ github.event.issue.title }}"CI-9Level 1Never run a pull request's code in a
pull_request_targetworkflow. That trigger runs with your secrets and a token that can write, so checking out the pull request's code hands both to whoever opened it. Usepull_requestfor anything that builds or tests contributed code.actions/checkoutv7 refuses this by default.CI-10Level 2Pin actions to a full commit SHA. A tag like
@v7can be moved to different code by whoever controls the action, and your next run uses it with your token. The examples here use version tags and branch names so they're easier to read. Dependabot keeps pinned SHAs current when an action publishes new releases.Some Home Assistant actions are updated on a branch instead.
hacs/actionhasn't tagged a release since 2022, and hassfest only started tagging in November 2026. Pin these to a commit SHA from their default branch, not to the old release, and check them for new commits every month or so.CI-11Level 2Don't leave the token behind after checkout.
actions/checkoutsaves the token so latergitcommands work, which also hands it to every later step. Turn that off unless a later step pushes..github/workflows/security.yaml (part)- uses: actions/checkout@v7 with: persist-credentials: falseCI-12Level 2Use a GitHub App token instead of a personal access token. When the built-in token can't do something, such as triggering another workflow, create a GitHub App with only the permissions it needs and install it on the repositories that need it.
actions/create-github-app-tokenturns it into a token that expires after an hour. The app's private key is still a stored secret, but each token reaches only what you picked, and nothing is tied to your own account.CI-13Level 2Check your workflows with zizmor. It finds the problems above, such as untrusted text in
run:lines, broad tokens, unpinned actions and credentials left behind. Runuvx zizmor .github/workflows/before you push, or add it to your security workflow.
Check it worked
Open a pull request that pins an old library with a known vulnerability in manifest.json. pip-audit should fail. For a card, add it to package.json instead, and dependency review and npm audit should both fail. CodeQL's check should run on the pull request.
Checks that block
A failing check only stops code from reaching main when main requires that check to pass. Otherwise it’s a warning, and the code can still be merged.
Controls
GATE-1Level 2 (or a required check)Level markerFor CodeQL, require code scanning results. In your main branch ruleset, turn on Require code scanning results, add CodeQL, and set it to block on security alerts of "High or higher". Requiring "Analyze (python)" only proves the scan ran.
GATE-2Level 2 (or code scanning)Level markerRequire your other checks by job name. Require status checks to pass → add
dependency-review,pip-audit,ruff-security,hassfestandmarketplacefrom the workflows in Checks in CI. A check only shows up in the list after it has run once.GATE-3Level 2Level markerMake sure each check can fail. Remove
continue-on-error: true,|| trueand--exit-zerofrom security steps. Some tools report without failing unless you ask them to. Trivy, for example, needsexit-code: 1.GATE-4Level 2Level markerWork through pull requests, even alone. Push to a branch, open a pull request and merge it when the checks are green. It takes a minute longer and it's the only way the required checks see your code first.
Check it worked
Open a pull request with a failing check. The merge button should be blocked and say which required check failed.
Security policy
When someone finds a problem in your app, they need a way to tell you that isn’t a public issue, because a public issue tells everyone else before you’ve had a chance to fix it.
Controls
POL-1Level 1Turn on private vulnerability reporting. Settings → Advanced Security → Private vulnerability reporting → Enable. People then get a "Report a vulnerability" button on your Security and quality tab, and their report reaches you privately. You can ask questions, reject it, or accept it as a draft advisory to work in.
POL-2Level 1Level markerAdd a SECURITY.md that points to it. In an organization, one
SECURITY.mdin its public.githubrepository covers every repository that doesn't have its own (see Organizations).SECURITY.md# Security policy ## Reporting a problem Please don't open a public issue. Report it privately through GitHub: https://github.com/OWNER/REPO/security/advisories/new I'll reply within 7 days and keep you posted until it's fixed. ## Supported versions Only the latest release gets security fixes.
POL-4Level 1When a report comes in, fix it in the advisory's private fork, release the fix, then publish the advisory. You can request a CVE from the advisory. If your code is also published as a package on PyPI or npm, Dependabot then alerts the projects that depend on it.
Check it worked
Open your repository's Security and quality tab while signed out. You should see the policy. Anyone who is signed in also gets a "Report a vulnerability" button on the Advisories page.
Secrets
A secret is anything that lets someone act as you or as your users, such as a token, a password or a private key. Keep it in the user’s config entry or in GitHub’s encrypted secrets, and out of the code, the logs and diagnostics downloads.
Controls
SEC-1Level 1Ask users for credentials in the config flow, with a password field, and read them from the config entry. Don't hard-code your own account's keys into the app.
config_flow.pyfrom homeassistant.helpers.selector import ( TextSelector, TextSelectorConfig, TextSelectorType, ) STEP_USER = vol.Schema({ vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): TextSelector( TextSelectorConfig(type=TextSelectorType.PASSWORD) ), })SEC-2Level 1Redact diagnostics and keep secrets out of logs. Users paste diagnostics into public issues.
diagnostics.pyfrom homeassistant.components.diagnostics import async_redact_data TO_REDACT = {CONF_PASSWORD, CONF_API_KEY, CONF_TOKEN, "serial_number"} async def async_get_config_entry_diagnostics(hass, entry): return {"entry": async_redact_data(entry.as_dict(), TO_REDACT)}SEC-4Level 2In CI, prefer no secret at all. Use the built-in
GITHUB_TOKENwith the narrowest permissions, and trusted publishing (OpenID Connect) to publish to PyPI or npm instead of a long-lived token.SEC-5Level 1If a secret leaks, revoke it first. Removing it from the history doesn't help, because clones, forks and caches already have a copy. Issue a new key, then clean up the history.
Check it worked
Download your integration's diagnostics with a real config entry and search the file for your password and token. Neither should appear.
Repository basics
Good issue forms get you the version, the logs and the setup on the first try. Closing what you fix tells users which problems are gone.
Controls
REPO-1Level 1Add a bug report form.
.github/ISSUE_TEMPLATE/bug_report.ymlname: Bug report description: Something isn't working labels: [bug] body: - type: input id: version attributes: label: App version placeholder: "1.4.2" validations: required: true - type: input id: ha-version attributes: label: Home Assistant version placeholder: "2026.11.2" validations: required: true - type: dropdown id: install attributes: label: Installation type options: [Home Assistant OS, Container, Other] - type: textarea id: what attributes: label: What happened, and what did you expect? validations: required: true - type: textarea id: logs attributes: label: Logs description: Remove tokens, passwords and addresses before pasting. render: shellREPO-2Level 1Turn off blank issues and link the private report.
.github/ISSUE_TEMPLATE/config.ymlblank_issues_enabled: false contact_links: - name: Report a security problem url: https://github.com/OWNER/REPO/security/advisories/new about: Please report security problems privately, not as an issue.REPO-3Level 1Add a .gitignore before your first commit.
.gitignore# Python __pycache__/ *.py[cod] .venv/ .pytest_cache/ .ruff_cache/ .coverage # Node node_modules/ # Secrets and local settings .env .env.* secrets.yaml *.pem *.key # Editors and OS .idea/ .DS_Store
REPO-4Level 2Close issues with the fix. Write
Fixes #123in the pull request, and GitHub closes the issue when it merges. Close stale questions with a short note rather than leaving them open.REPO-5Level 1List the servers your app talks to in the README, and what it sends to each. Users can't see that from the dashboard.
Check it worked
Click "New issue" on your repository. You should see the bug form and the security link, and no blank issue option.
Releases
Most people install your release, but reviewers and scanners read your repository. If the release is built in CI from code on main, the two match.
Controls
REL-1Level 3Level markerBuild and publish releases from a workflow instead of your laptop. This one zips an integration, refuses a tag that isn't on main, adds a provenance attestation, and publishes the release with the zip in one step.
.github/workflows/release.yamlname: Release on: push: tags: ["v*"] permissions: contents: write id-token: write attestations: write jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Only release code that's on main run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main - name: Zip the integration run: | cd custom_components/your_domain zip -r "$GITHUB_WORKSPACE/your_domain.zip" . - uses: actions/attest-build-provenance@v4 with: subject-path: your_domain.zip - name: Publish the release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" your_domain.zip --verify-tag --generate-notesTell the Marketplace to install the zip with
"zip_release": trueand"filename": "your_domain.zip"inhacs.json. For a card, build the bundle in the workflow and attach the built file instead.The "Only release code that's on main" step catches a tag pushed from the wrong branch by mistake. It can't stop someone with write access. The workflow that runs is the one in the tagged commit, so they could tag a commit whose workflow leaves that step out. A tag ruleset with Restrict creations stops that, because only the people on its bypass list can create release tags (see Branch and tag protection).
REL-2Level 3Keep publishing secrets in a release environment. If the release needs a secret, for example to push an image or publish a package, create an environment under Settings → Environments. Under Deployment branches and tags, allow only your release tags, add the secret to the environment instead of the repository, and add
environment: releaseto the release job. A job started from any other branch or tag can't read it. With the tag ruleset above, only you can start one that can. Trusted publishing, where the registry supports it, needs no secret at all.REL-3Level 3 (or a tag ruleset)Level markerTurn on immutable releases (Settings → General → Releases), so a published release's files and tag can't be swapped later. It applies to releases you publish after turning it on. Because assets can't be added after publishing, the workflow above creates the release and its file together.
REL-4Level 3Don't commit build output you also release. If a card's
dist/is in the repository, make the release workflow fail when a fresh build doesn't match it.
Check it worked
Run gh attestation verify your_domain.zip --repo OWNER/REPO on a downloaded release. It should name your workflow and the commit it built from.
Organizations
An organization owns repositories the way your own account does, but it can have several owners and one set of security settings that every new repository starts with.
These steps apply only if your project is in an organization. A project on a personal account can reach every level without one.
When an organization helps
- More than one person works on the project.
- You publish several apps and want them all to start with the same settings.
- You might hand the project over one day. Changing who's in an organization is easier than transferring every repository.
If you maintain one app on your own, you don't need one. Start with Your GitHub account instead.
What you gain and what it costs
On the free plan, an organization gives you:
- Several owners, each with their own login, so nobody shares a password or a token.
- Two-factor login required for everyone in it.
- One security configuration that new repositories get automatically.
- One Actions policy for every repository, such as which actions may run and whether they must be pinned.
- Default community files, such as a security policy, from a single
.githubrepository.
It has costs too.
- Rules for main and tags are still set in each repository. Organization-wide rulesets need a paid plan (Team or Enterprise).
- Moving an existing repository in has side effects. GitHub redirects the old address, but container images on ghcr.io don't follow, and the default security configuration isn't applied to a repository you move in.
- It's one more thing to protect. An owner can change or delete every repository in the organization.
Controls
Do these in order, and finish the first five before you create or move any repositories into the organization. The default security configuration only reaches repositories created after you set it.
ORG-1Level 1Secure your own account first, then create the organization from it. Settings → Organizations → New organization, on the free plan. Whoever holds an owner's login controls the organization, so do the steps in Your GitHub account before this one.
ORG-2Level 1Require two-factor login for everyone. In the organization's Settings → Authentication security, turn on the two-factor requirement. GitHub removes anyone who doesn't have it, and you can add them back once they've set it up.
ORG-3Level 1Decide who the owners are. If you work alone, one owner is fine, but losing your login then means losing the organization. Keep your recovery codes offline and set up a second way to sign in. It also helps to write down who could take over. If others work with you, make two people you trust owners and everyone else a member.
ORG-4Level 1Limit what members can do. In the organization's Settings, open Member privileges.
- Base permission: Read, which is the default. Give write access per repository instead.
- Repository creation: untick Public and Private, so only owners create repositories. Members can create both by default.
- Admin repository permissions: untick Repository deletion and transfer, so only owners can delete or move a repository.
- Pages creation: untick Public, so only owners can publish a website under the organization's name.
ORG-5Level 1Create a security configuration for every repository, new ones included. In the organization's Settings, open Advanced Security → Configurations → New configuration. Most features start enabled. Change these:
- Name: your organization's name followed by "Baseline", such as "my-org Baseline".
- Dependabot alerts → Security updates: Enabled.
- Dependabot alerts → Malware alerts: Enabled.
- Policy → Use as default for newly created repositories: Public.
- Policy → Enforce configuration: keep Enforce for repository owners, so nobody can turn a feature off in one repository.
If several people have write access, also set Bypass privileges and each Prevent direct alert dismissals, so one person can't push a secret or dismiss an alert alone. Leave the rest as it starts.
Choose Save configuration. Saving doesn't apply it to the repositories you already have, so apply it next:
- On the Configurations page, choose the pencil beside your new configuration.
- Set Apply to: All repositories, and check that Allow repository owners to modify features is Off.
- Choose Review, then Save and enable.
These features are free for public repositories. On a paid plan with GitHub Advanced Security, private repositories are billed per active committer, and the review screen shows how many licenses it would use. Choose All for new repositories only if you mean to pay for them. A repository you move in later needs the configuration applied by hand.
ORG-6Level 2Set an Actions policy. Settings → Actions → General.
- Allow only actions created by GitHub, plus the ones you list, such as
home-assistant/*andhacs/*. - Turn on Require actions to be pinned to a full-length commit SHA. Workflows that use a tag or a branch, like
@v7or@main, then fail, so pin them first and let Dependabot keep the SHAs current. - Under Workflow permissions, choose read-only access, so a workflow without its own
permissionsblock can't write. - Untick Allow GitHub Actions to create and approve pull requests.
- Allow only actions created by GitHub, plus the ones you list, such as
ORG-7Level 1If the organization holds several apps, add a public
.githubrepository with default community files. ASECURITY.mdand.github/ISSUE_TEMPLATE/config.ymlthere show on every repository that doesn't have its own, and thatSECURITY.mdcounts as each of those repositories' security policy for level 1. Use the files from Security policy and Repository basics, with the organization's name in place of a single repository. Some tools only read a repository's own files, so the template below carries a copy too.ORG-8Level 2If the organization holds several apps, start new ones from a template repository. Add the files every new app should start with, then tick Settings → General → Template repository.
SECURITY.md, issue forms and a.gitignorewith secret patterns.github/dependabot.ymlwith a 7-day cooldown- The security workflow from Checks in CI, with actions pinned by SHA
- The release workflow from Releases
A template only copies files. Each new repository still needs its own rulesets for main and tags. Set them up once, export them (Settings → Rules → Rulesets, then Export on each ruleset), and import them into the next repository with New ruleset → Import a ruleset. The bypass list isn't exported, so add it again.
ORG-9Level 1If you move an existing repository in, check what depends on its old address. GitHub redirects links, clones and the Marketplace's entry, but only until someone creates a repository with the old name. Container images on ghcr.io keep their old path, so update the image name in your app's config. Then apply the security configuration to the repository.
Check it worked
Create a test repository from your template. Its Settings → Advanced Security page should show the organization's configuration, with Dependabot alerts, secret scanning, push protection, private reporting and CodeQL turned on. Its Security and quality tab should show the security policy while you're signed out. Delete the test repository afterwards.
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.
Dashboard cards
A card runs on the same page as the user’s Home Assistant login. Anything the card loads can read the login token and use it.
These steps apply only if you publish a dashboard card.
Controls
CARD-1Level 1Bundle your libraries into the card at build time instead of loading them from a CDN when the card runs.
Do bundled at build timeimport { formatDistance } from "date-fns";Don't loaded at run timeconst lib = await import( "https://cdn.example.com/lib@latest/index.js" );
CARD-2Level 1Keep the login token where it is. Talk to Home Assistant through the card's own connection. For an outside service, put the call in an integration and have the card ask the integration.
Do the card's own connectionconst states = await this.hass.callWS({ type: "get_states", });Don't send the token anywherefetch(url, { headers: { Authorization: `Bearer ${this.hass.auth.data.access_token}`, }});CARD-3Level 1Render with Lit templates, not innerHTML. Entity names and attributes come from devices and other apps. Lit escapes them.
innerHTMLturns them into live HTML, and an attribute such asonerrorcan run script with the user's login.CARD-4Level 2Keep build tools current, commit the lockfile, and build with
npm ci. Dependabot's npm updates cover development packages too.
Check it worked
Open the dashboard with your browser's developer tools on the Network tab. The card shouldn't fetch any script from another site, and no request should carry your token outside Home Assistant.
Dependencies
Every package you add runs with the same access as your own code, and its maintainers can ship a new version at any time.
Controls
DEP-1Level 1Use what Home Assistant already ships first.
Why Each package you add is code from more people you have to trust, and one more account that can be taken over. Home Assistant already ships and updates the common ones, so using them doesn't add anyone new for your users to trust.
aiohttp, voluptuous and many device libraries are already installed. Don't list those in
requirements. Home Assistant's own version wins, and a different pin can stop your integration from installing.DEP-2Level 1Check a package before you add it.
Why Some packages are published under a name one letter away from a popular one, so that a typo installs them. Others change hands without anyone noticing. In 2018, someone posing as a maintainer took over event-stream and added code aimed at one bitcoin wallet app (how it happened).
Look for a release in the last year, more than one maintainer, a linked source repository, and the exact spelling of the name.
DEP-3Level 1Pin exact versions.
Why With a range such as
>=2.0, every new install takes whatever was published last, including a version published from a stolen account an hour ago. With an exact pin, a new version only reaches your users after you merge a pull request for it (phished logins, Shai-Hulud).Use
==inmanifest.json, and commit the lockfile for a card. Dependabot proposes updates for a card's lockfile. Formanifest.json, Renovate can do it with a custom manager, or pip-audit in CI tells you when a pinned version has a known vulnerability.DEP-4Level 1Wait at least 7 days before taking a new release.
Why Malicious versions are usually found and removed fast. npm removed the September 2025 phishing versions the same day, and TanStack's within about four and a half hours. With a 7-day cooldown, Dependabot only offers a release once it has been public for a week, so versions like these have been removed before it offers them (how it happened).
Set
cooldown: default-days: 7independabot.yml(Dependabot waits 3 days if you set nothing), or"minimumReleaseAge": "7 days"in Renovate. Security updates aren't delayed.DEP-5Level 1Check for known vulnerabilities in CI.
Why Most vulnerable code in an app is an old version of a library that already has a fix. A check in CI tells you when a package you use gets an advisory, before a user reports it.
Use pip-audit or npm audit (see Checks in CI).
DEP-6Level 2Replace dead packages.
Why A package nobody maintains gets no security fixes, and nobody is watching when it changes hands.
If a library hasn't had a release in years and has open security reports, switch to a maintained one or take over a fork in the open.
Check it worked
pip-audit or npm audit passes on main, and you merge Dependabot's pull requests as they come in.
Apps (add-ons)
An app runs in its own container, but its config file decides how much of the host and of Home Assistant it can reach. Home Assistant shows users a security rating built from those settings.
These steps apply only if you publish an app (add-on).
Controls
APP-1Level 1Ask only for the access the app uses. Leave out
privileged,full_access,host_network,host_pidanddocker_apiunless the app can't work without them, and say why in the README when it does.config.yamlname: Example version: "1.0.0" slug: example arch: [aarch64, amd64] ingress: true ingress_port: 8099 homeassistant_api: true # only if the app calls Home Assistant's API # Leave these out unless the app can't work without them: # privileged, full_access, host_network, host_pid, docker_api
APP-2Level 1Use ingress instead of open ports. Ingress puts the app's web page behind Home Assistant's login. An open port is reachable by anything on the network.
APP-3Level 2Keep AppArmor on and ship a profile that allows only what the app does.
APP-4Level 2Build on Home Assistant's base images, pin their versions, rebuild when they update, and don't run as root inside the container when you don't need to.
Check it worked
Install the app and open its page in Settings → Apps. The security rating should be as high as the app's job allows.
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.
Security for Home Assistant developers
Custom integrations run inside Home Assistant with full access, and cards run on the same page as your login. These controls cover how to keep both safe, and the walk-throughs take you through them in order.
The controls come from what I learned building Barkley, a scanner for Marketplace apps, and from a scan of all 6,753 Marketplace apps in November 2026. The scan found no malware. Mostly it found missing habits that are quick to add. Together they make up the Home Assistant Security Controls (HASC), a community catalog. Each control has an ID, such as CI-4, that you can cite in an issue or a pull request.
Levels
Every control belongs to one of three levels, and each level needs everything in the one below. Some controls can be checked from outside your project, such as a security policy or a protected main branch, and those are tagged "Level marker". A scan, Barkley's included, grades a level on its markers, so a project needs every marker up to that level. The controls nobody can check from outside, like two-factor login, belong to their level just the same.
Level 1 · Basics
Level markers
- A security policy
- Dependabot or Renovate
- A security scanner in CI, such as CodeQL
Also in level 1: two-factor login with a passkey, push protection, and the other level 1 controls on the checklist.
Level 2 · Checks that block
Level markers
- The main branch protected
- A required security check that fails on what it finds
- Changes reach main through pull requests
- Signed commits
Also in level 2: a short bypass list, vigilant mode, and the other level 2 controls on the checklist.
Level 3 · Releases people can check
Level markers
- Release tags protected, by a tag ruleset or immutable releases
- Your latest release's tag is on main, and any files attached to it were uploaded by CI
Also in level 3: don't commit build output you also release.
The November 2026 sweep checked these markers, with two exceptions. Signed commits and pull requests became level 2 markers later, and it only counted a security policy kept in the repository itself. 222 of 6,753 apps met the level 1 markers, 46 met level 2's and 14 met level 3's. Another 40 apps require a blocking security check but don't meet level 1; 38 of them have no security policy.
Where to start
A walk-through takes you through the controls for one situation, in order:
Or turn on two-factor login first, then work through level 1. The checklist lists every control for each level in order, and All controls lists them by family.