# Home Assistant Security Controls

Security controls for Home Assistant integrations, cards and apps, each with an ID you can cite, such as HASC-CI-4.

Source: https://ha-barkley.github.io/security/controls/

A community catalog, not an official Home Assistant or Open Home Foundation project.

Each control belongs to a family and a level. "Anyone can check" means the control can be confirmed from outside the project, and those controls are what a level is graded on. Controls that apply only to one kind of project say so. The rest apply to all of them.

## ACC · Your GitHub account

| ID                                                                     | Control                                                       | Level | Applies to | Anyone can check |
|------------------------------------------------------------------------|---------------------------------------------------------------|-------|------------|------------------|
| [ACC-1](https://ha-barkley.github.io/security/controls/account/#acc-1) | Turn on two-factor login with a passkey or a security key     | 1     | All        | No               |
| [ACC-2](https://ha-barkley.github.io/security/controls/account/#acc-2) | Replace classic personal access tokens with fine-grained ones | 1     | All        | No               |
| [ACC-3](https://ha-barkley.github.io/security/controls/account/#acc-3) | Review what can act for you                                   | 1     | All        | No               |
| [ACC-4](https://ha-barkley.github.io/security/controls/account/#acc-4) | Sign your commits                                             | 2     | All        | Yes              |
| [ACC-5](https://ha-barkley.github.io/security/controls/account/#acc-5) | Then turn on vigilant mode                                    | 2     | All        | No               |
| [ACC-6](https://ha-barkley.github.io/security/controls/account/#acc-6) | Give the project a second maintainer, or at least a plan      | 2     | All        | No               |

## BR · Branch and tag protection

| ID                                                                             | Control                                                              | Level                     | Applies to | Anyone can check |
|--------------------------------------------------------------------------------|----------------------------------------------------------------------|---------------------------|------------|------------------|
| [BR-1](https://ha-barkley.github.io/security/controls/branches-and-tags/#br-1) | Add a branch ruleset for main                                        | 2                         | All        | Yes              |
| [BR-2](https://ha-barkley.github.io/security/controls/branches-and-tags/#br-2) | Require your checks to pass. Withdrawn, covered by GATE-1 and GATE-2 | Withdrawn                 |            |                  |
| [BR-3](https://ha-barkley.github.io/security/controls/branches-and-tags/#br-3) | Keep the bypass list short                                           | 2                         | All        | No               |
| [BR-4](https://ha-barkley.github.io/security/controls/branches-and-tags/#br-4) | Add a tag ruleset for your release tags                              | 3 (or immutable releases) | All        | Yes              |

## CI · Checks in CI

| ID                                                                | Control                                                             | Level                      | Applies to          | Anyone can check |
|-------------------------------------------------------------------|---------------------------------------------------------------------|----------------------------|---------------------|------------------|
| [CI-1](https://ha-barkley.github.io/security/controls/ci/#ci-1)   | Turn on CodeQL default setup                                        | 1 (or a security workflow) | All                 | Yes              |
| [CI-2](https://ha-barkley.github.io/security/controls/ci/#ci-2)   | Turn on Dependabot alerts and security updates                      | 1                          | All                 | Yes              |
| [CI-3](https://ha-barkley.github.io/security/controls/ci/#ci-3)   | Turn on secret scanning and push protection                         | 1                          | All                 | No               |
| [CI-4](https://ha-barkley.github.io/security/controls/ci/#ci-4)   | Add a security workflow                                             | 1 (or CodeQL)              | All                 | Yes              |
| [CI-5](https://ha-barkley.github.io/security/controls/ci/#ci-5)   | Validate against Home Assistant's own rules                         | 1                          | Integrations, Cards | No               |
| [CI-6](https://ha-barkley.github.io/security/controls/ci/#ci-6)   | Optional: catch problems before you commit                          | 1 · optional               | All                 | No               |
| [CI-7](https://ha-barkley.github.io/security/controls/ci/#ci-7)   | Give workflows read-only tokens                                     | 1                          | All                 | No               |
| [CI-8](https://ha-barkley.github.io/security/controls/ci/#ci-8)   | Keep untrusted text out of `run:` lines                             | 1                          | All                 | No               |
| [CI-9](https://ha-barkley.github.io/security/controls/ci/#ci-9)   | Never run a pull request's code in a `pull_request_target` workflow | 1                          | All                 | No               |
| [CI-10](https://ha-barkley.github.io/security/controls/ci/#ci-10) | Pin actions to a full commit SHA                                    | 2                          | All                 | No               |
| [CI-11](https://ha-barkley.github.io/security/controls/ci/#ci-11) | Don't leave the token behind after checkout                         | 2                          | All                 | No               |
| [CI-12](https://ha-barkley.github.io/security/controls/ci/#ci-12) | Use a GitHub App token instead of a personal access token           | 2                          | All                 | No               |
| [CI-13](https://ha-barkley.github.io/security/controls/ci/#ci-13) | Check your workflows with zizmor                                    | 2                          | All                 | No               |

## GATE · Checks that block

| ID                                                                               | Control                                   | Level                   | Applies to | Anyone can check |
|----------------------------------------------------------------------------------|-------------------------------------------|-------------------------|------------|------------------|
| [GATE-1](https://ha-barkley.github.io/security/controls/blocking-checks/#gate-1) | For CodeQL, require code scanning results | 2 (or a required check) | All        | Yes              |
| [GATE-2](https://ha-barkley.github.io/security/controls/blocking-checks/#gate-2) | Require your other checks by job name     | 2 (or code scanning)    | All        | Yes              |
| [GATE-3](https://ha-barkley.github.io/security/controls/blocking-checks/#gate-3) | Make sure each check can fail             | 2                       | All        | Yes              |
| [GATE-4](https://ha-barkley.github.io/security/controls/blocking-checks/#gate-4) | Work through pull requests, even alone    | 2                       | All        | Yes              |

## POL · Security policy

| ID                                                                             | Control                                                      | Level     | Applies to | Anyone can check |
|--------------------------------------------------------------------------------|--------------------------------------------------------------|-----------|------------|------------------|
| [POL-1](https://ha-barkley.github.io/security/controls/security-policy/#pol-1) | Turn on private vulnerability reporting                      | 1         | All        | No               |
| [POL-2](https://ha-barkley.github.io/security/controls/security-policy/#pol-2) | Add a SECURITY.md                                            | 1         | All        | Yes              |
| [POL-3](https://ha-barkley.github.io/security/controls/security-policy/#pol-3) | Point the issue form there too. Withdrawn, covered by REPO-2 | Withdrawn |            |                  |
| [POL-4](https://ha-barkley.github.io/security/controls/security-policy/#pol-4) | When a report comes in                                       | 1         | All        | No               |

## SEC · Secrets

| ID                                                                     | Control                                                          | Level     | Applies to   | Anyone can check |
|------------------------------------------------------------------------|------------------------------------------------------------------|-----------|--------------|------------------|
| [SEC-1](https://ha-barkley.github.io/security/controls/secrets/#sec-1) | Ask users for credentials in the config flow                     | 1         | Integrations | No               |
| [SEC-2](https://ha-barkley.github.io/security/controls/secrets/#sec-2) | Redact diagnostics and keep secrets out of logs                  | 1         | Integrations | No               |
| [SEC-3](https://ha-barkley.github.io/security/controls/secrets/#sec-3) | Ignore local secret files. Withdrawn, covered by REPO-3 and CI-3 | Withdrawn |              |                  |
| [SEC-4](https://ha-barkley.github.io/security/controls/secrets/#sec-4) | In CI, prefer no secret at all                                   | 2         | All          | No               |
| [SEC-5](https://ha-barkley.github.io/security/controls/secrets/#sec-5) | If a secret leaks, revoke it first                               | 1         | All          | No               |

## REPO · Repository basics

| ID                                                                          | Control                                           | Level | Applies to | Anyone can check |
|-----------------------------------------------------------------------------|---------------------------------------------------|-------|------------|------------------|
| [REPO-1](https://ha-barkley.github.io/security/controls/repository/#repo-1) | Add a bug report form                             | 1     | All        | No               |
| [REPO-2](https://ha-barkley.github.io/security/controls/repository/#repo-2) | Turn off blank issues and link the private report | 1     | All        | No               |
| [REPO-3](https://ha-barkley.github.io/security/controls/repository/#repo-3) | Add a .gitignore                                  | 1     | All        | No               |
| [REPO-4](https://ha-barkley.github.io/security/controls/repository/#repo-4) | Close issues with the fix                         | 2     | All        | No               |
| [REPO-5](https://ha-barkley.github.io/security/controls/repository/#repo-5) | List the servers your app talks to                | 1     | All        | No               |

## REL · Releases

| ID                                                                      | Control                                          | Level                | Applies to | Anyone can check |
|-------------------------------------------------------------------------|--------------------------------------------------|----------------------|------------|------------------|
| [REL-1](https://ha-barkley.github.io/security/controls/releases/#rel-1) | Build and publish releases from a workflow       | 3                    | All        | Yes              |
| [REL-2](https://ha-barkley.github.io/security/controls/releases/#rel-2) | Keep publishing secrets in a release environment | 3                    | All        | No               |
| [REL-3](https://ha-barkley.github.io/security/controls/releases/#rel-3) | Turn on immutable releases                       | 3 (or a tag ruleset) | All        | Yes              |
| [REL-4](https://ha-barkley.github.io/security/controls/releases/#rel-4) | Don't commit build output you also release       | 3                    | All        | No               |

## ORG · Organizations

| ID                                                                           | Control                                                                                                | Level | Applies to | Anyone can check |
|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------|------------|------------------|
| [ORG-1](https://ha-barkley.github.io/security/controls/organizations/#org-1) | Secure your own account first, then create the organization from it                                    | 1     | All        | No               |
| [ORG-2](https://ha-barkley.github.io/security/controls/organizations/#org-2) | Require two-factor login for everyone                                                                  | 1     | All        | No               |
| [ORG-3](https://ha-barkley.github.io/security/controls/organizations/#org-3) | Decide who the owners are                                                                              | 1     | All        | No               |
| [ORG-4](https://ha-barkley.github.io/security/controls/organizations/#org-4) | Limit what members can do                                                                              | 1     | All        | No               |
| [ORG-5](https://ha-barkley.github.io/security/controls/organizations/#org-5) | Create a security configuration for every repository, new ones included                                | 1     | All        | No               |
| [ORG-6](https://ha-barkley.github.io/security/controls/organizations/#org-6) | Set an Actions policy                                                                                  | 2     | All        | No               |
| [ORG-7](https://ha-barkley.github.io/security/controls/organizations/#org-7) | If the organization holds several apps, add a public `.github` repository with default community files | 1     | All        | No               |
| [ORG-8](https://ha-barkley.github.io/security/controls/organizations/#org-8) | If the organization holds several apps, start new ones from a template repository                      | 2     | All        | No               |
| [ORG-9](https://ha-barkley.github.io/security/controls/organizations/#org-9) | If you move an existing repository in                                                                  | 1     | All        | No               |

## INT · Integrations

| ID                                                                          | Control                                                                | Level | Applies to   | Anyone can check |
|-----------------------------------------------------------------------------|------------------------------------------------------------------------|-------|--------------|------------------|
| [INT-1](https://ha-barkley.github.io/security/controls/integrations/#int-1) | Never fetch code at run time                                           | 1     | Integrations | No               |
| [INT-2](https://ha-barkley.github.io/security/controls/integrations/#int-2) | Keep the login on every page you add                                   | 1     | Integrations | No               |
| [INT-3](https://ha-barkley.github.io/security/controls/integrations/#int-3) | Save settings and state with the storage helper, and never with pickle | 1     | Integrations | No               |
| [INT-4](https://ha-barkley.github.io/security/controls/integrations/#int-4) | Use Home Assistant's shared web session                                | 1     | Integrations | No               |
| [INT-5](https://ha-barkley.github.io/security/controls/integrations/#int-5) | Avoid the calls that turn data into code                               | 1     | Integrations | No               |
| [INT-6](https://ha-barkley.github.io/security/controls/integrations/#int-6) | Send each credential only to its own service                           | 1     | Integrations | No               |

## CARD · Dashboard cards

| ID                                                                     | Control                                  | Level | Applies to | Anyone can check |
|------------------------------------------------------------------------|------------------------------------------|-------|------------|------------------|
| [CARD-1](https://ha-barkley.github.io/security/controls/cards/#card-1) | Bundle your libraries into the card      | 1     | Cards      | No               |
| [CARD-2](https://ha-barkley.github.io/security/controls/cards/#card-2) | Keep the login token where it is         | 1     | Cards      | No               |
| [CARD-3](https://ha-barkley.github.io/security/controls/cards/#card-3) | Render with Lit templates, not innerHTML | 1     | Cards      | No               |
| [CARD-4](https://ha-barkley.github.io/security/controls/cards/#card-4) | Keep build tools current                 | 2     | Cards      | No               |

## DEP · Dependencies

| ID                                                                          | Control                                          | Level | Applies to   | Anyone can check |
|-----------------------------------------------------------------------------|--------------------------------------------------|-------|--------------|------------------|
| [DEP-1](https://ha-barkley.github.io/security/controls/dependencies/#dep-1) | Use what Home Assistant already ships first      | 1     | Integrations | No               |
| [DEP-2](https://ha-barkley.github.io/security/controls/dependencies/#dep-2) | Check a package before you add it                | 1     | All          | No               |
| [DEP-3](https://ha-barkley.github.io/security/controls/dependencies/#dep-3) | Pin exact versions                               | 1     | All          | No               |
| [DEP-4](https://ha-barkley.github.io/security/controls/dependencies/#dep-4) | Wait at least 7 days before taking a new release | 1     | All          | No               |
| [DEP-5](https://ha-barkley.github.io/security/controls/dependencies/#dep-5) | Check for known vulnerabilities in CI            | 1     | All          | No               |
| [DEP-6](https://ha-barkley.github.io/security/controls/dependencies/#dep-6) | Replace dead packages                            | 2     | All          | No               |

## APP · Apps (add-ons)

| ID                                                                  | Control                               | Level | Applies to | Anyone can check |
|---------------------------------------------------------------------|---------------------------------------|-------|------------|------------------|
| [APP-1](https://ha-barkley.github.io/security/controls/apps/#app-1) | Ask only for the access the app uses  | 1     | Apps       | No               |
| [APP-2](https://ha-barkley.github.io/security/controls/apps/#app-2) | Use ingress instead of open ports     | 1     | Apps       | No               |
| [APP-3](https://ha-barkley.github.io/security/controls/apps/#app-3) | Keep AppArmor on                      | 2     | Apps       | No               |
| [APP-4](https://ha-barkley.github.io/security/controls/apps/#app-4) | Build on Home Assistant's base images | 2     | Apps       | No               |

71 controls in 13 families, plus 3 withdrawn.
