51 Commits

Author SHA1 Message Date
Josh Hawkins
890512b054
Container security hardening (phase 3, breaking) (#24081)
* Run the frigate service as the frigate user

* Run go2rtc as its own restricted user

* Run nginx as the frigate user with writable state in /tmp/nginx

* Disable bandwidth stats gracefully when not running as root

* Hand TensorRT model cache ownership to the runtime user

* Document non-root operation and per-hardware device access

* Create /media/frigate after the ownership sweep

* Assert non-root services, JWT migration, and escape hatch in CI

* only write the sweep sentinel when a media volume is mounted

* tolerate homekit config chown failures in the go2rtc run script

* chown the s6 log pipe so non-root nginx can reopen /dev/stdout

* set HOME to /config for non-root services

* run smoke nginx -t and the write probe as the runtime user

* re-own the nginx shm cache on service restart

* discard stdout for the unprivileged smoke nginx -t

* unwrap hard-wrapped prose in the installation docs

* report progress during the ownership sweep

* document EXTRA_GROUPS as the only device access path for dropped services

* expand the non-root device access docs with diagnosis steps and udev rules

* document network storage ownership and the remaining detector hardware

* skip lost+found during the ownership sweep

* hand /tmp/cache to the runtime user before services start

* make bundled models readable by the runtime user

* reload nginx by signaling the master instead of parsing its config as root

* harden root writes into unprivileged-owned paths

Restrict the sweep sentinel to a mount at or below /media/frigate so a
parent /media mount cannot bless a later-shadowed volume. Rebuild
/tmp/nginx root-owned each start so root's cp and tempio writes cannot
follow a symlink an unprivileged nginx planted in the previous run.

* collapse the duplicated sentinel comment

* add a service-runs-as-root helper for granular root services

* validate FRIGATE_ROOT_SERVICES and fail fast on unknown names

* let services listed in FRIGATE_ROOT_SERVICES skip the privilege drop

* record the root-services mode in the sentinel and sweep small trees each boot

* cache the runtime ids in the ownership helper

* chown recordings, previews, and exports to the runtime user at create

* chown the database files after init

* recommend FRIGATE_ROOT_SERVICES in the bandwidth stats warning

* assert granular root services in CI

* document FRIGATE_ROOT_SERVICES

* own every directory level created for a recording segment

* clear the cached runtime ids when ownership tests finish

* skip missing media paths in the per-boot ownership sweep

* clarify granular root services docs

* clean up

* install acl for device access grants

* grant runtime users access to mapped device nodes at boot

* assert device access grants in CI

* document automatic device access grants

* stop telling users device access needs host side setup

* clarify the non-root docs

* link the migration script to the repo

* group the manual device setup under one section

* harden against symlink attacks

/config is owned by the unprivileged runtime user after the ownership sweep, so root operations on files there could be redirected by a planted symlink.

- go2rtc HomeKit setup: replace the root yq/jq normalization and chown with an O_NOFOLLOW helper (prepare_homekit.py), so a symlink at go2rtc_homekit.yml can't redirect a root write or chown onto another file
- go2rtc binary override: ignore /config/go2rtc whenever the service runs as root, so a planted binary can't exec as root under FRIGATE_ROOT_SERVICES
- sweep sentinel: read and write it through safe-sentinel, which trusts only a root-owned regular file and never follows a symlink, so it can't be forged to skip the migration or symlinked to clobber a root file
- ownership sweep: chown with -execdir so a parent directory swapped for a symlink mid-walk can't redirect the chown out of the volume
- validate inputs: restrict DEVICE_ACL_PATHS to /dev, require nonzero numeric EXTRA_GROUPS, and reject PUID/PGID that collide with the go2rtc ids
- docs: correct the TLS key ownership note to match what actually happens

* tweak docs

* stop the ownership sweep chasing entries other mechanisms own

* keep custom binaries out of root services only under granular root
2026-08-30 08:14:43 -06:00
Josh Hawkins
dcda458a82 Container security hardening (phase 1) (#24061)
* Verify s6-overlay downloads against pinned checksums

* Verify go2rtc download against pinned checksums

The v1.9.14 release publishes no checksums file, just the bare per-platform binaries, so these digests come from a one-time fetch rather than upstream. That pins the artifact against later substitution, which is the realistic threat for a version we stay on for months, but it does not verify the original download. The stage moves from `ADD --link` to a script because `ADD --checksum` can't express an architecture-dependent URL.

* Verify main image downloads against pinned checksums

Covers everything the main image downloads on the default path: tempio, the hailort runtime tarball and wheel, the six ffmpeg builds, the libedgetpu deb, and the thirteen Intel driver debs. The hailort tarball was streamed straight into `tar`, which can't be verified before extraction, so it downloads to `/tmp` first. The three ffmpeg blocks per arch collapse into one `install_ffmpeg` helper since they only differed by URL and install dir, and the Intel debs go through a `fetch_intel_deb` helper for the same reason.

The Intel debs are the ones that mattered most here. They're installed as root with `dpkg` on the default amd64 path and had no verification at all. compute-runtime publishes a `ww<week>.sum` asset with every release and npu-driver published `checksum.sha256` on v1.19.0, so those eight digests came from upstream rather than from us. intel-graphics-compiler and level-zero publish none, so those five and everything else here come from a one-time fetch, which pins the artifact against later substitution but doesn't verify the original download. The comment above the map says which is which and how to refresh them, since npu-driver has stopped publishing sums since v1.19.0 and that provenance won't survive the next bump.

Still unpinned: `get-pip.py`, which is a rolling URL where a digest would just break the build on pypa's next edit, and the per-variant artifacts for Axera, Synaptics, and Jetson. apt repositories are out of scope since apt already verifies signatures.

* Restrict generated TLS key permissions

OpenSSL 3.x already writes the key at 600 on its own, so this pins the guarantee rather than fixing an observed leak: the mode no longer depends on the openssl version or the umask the service happens to start with. Only the generated pair is touched. User-mounted certs take the other branch and are never chmod'd, which matters when they're mounted read-only.

* Add security headers and server_tokens off

Adds `X-Content-Type-Options: nosniff` and `Referrer-Policy: strict-origin-when-cross-origin`, and turns off nginx version disclosure.

No `X-Frame-Options` and no CSP `frame-ancestors`. HA's Webpage card and iframe panels frame Frigate's own address cross-origin, and either header would break them silently with nothing in Frigate's logs to explain it. Ingress is same-origin and would survive `SAMEORIGIN`, but Frigate can't tell the two apart from inside the container. `security_headers.conf` is a plain file in the image rather than a generated one, so anyone who does want framing restrictions can bind-mount it.

`add_header` doesn't inherit into a block that declares its own, so the include goes in per block, all nine of them, including the four nested static-asset locations that serve the JS bundles. Those are the ones nosniff actually matters for.

The run script now reads `get_nginx_settings.py` once into a variable instead of shelling out per template. That script imports the frigate config machinery, which is noticeable on an SBC.

Not fixed here: `listen.conf` is included at server level and carries `Strict-Transport-Security`, so those same nine blocks already drop HSTS under TLS today. Folding it into this file would change existing TLS behavior on nine paths, so it needs its own PR.

* Restrict go2rtc config file permissions

* Log failed login attempts with source address

Failed logins returned a bare 401 and left nothing behind, so credential stuffing was invisible unless you were already watching nginx access logs. Both failure branches now log a warning with the attempted username and the client address.

The address comes from `get_remote_addr()`, the same helper the login rate limiter keys on, so the two agree on who the client is and the trusted-proxy handling is consistent. Logging a raw `x-forwarded-for` instead would let an attacker forge the source address in the very log line meant to catch them.

The response is unchanged and identical either way. Which factor failed is only visible in the log, never to the client, and the password is never logged.

* Recommend least-privilege container options in install docs

The compose generator pushed `privileged: true` into every file it produced, no matter what hardware you picked, and it's the default tab on the install page so it's what most people copy. It now emits `security_opt: no-new-privileges:true` instead, and only adds `privileged: true` for hardware that actually needs it, with the reason inline. MemryX is the only one today, since it needs to reach the max-manager. Rockchip and Synaptics only want privileged during initial setup and their documented end state is device mappings, so neither gets it.

`no-new-privileges` merges into the same `security_opt` block as any device-specific entries, so Rockchip still gets its `apparmor=unconfined` and `systempaths=unconfined` without a duplicate key.

The static example now has `privileged` commented out, and there's a short section on the options worth adding, with a note that `cap_drop: ALL` breaks `telemetry.stats.network_bandwidth` since nethogs needs NET_ADMIN/NET_RAW.

* Add amd64 container smoke test to CI

Boots the built amd64 image against a minimal config and asserts the two security headers, that the Server header no longer carries a version, that no frame-ancestors is present, that nginx accepts its own config, and the two file modes. This is also the harness the rest of the hardening work extends.

The two negative assertions are written as `if grep; then exit 1; fi` rather than `! grep`. Bash exempts a negated command from `set -e`, so the `!` form would have passed even with the version and frame-ancestors both present, which is the opposite of what a regression net is for.
2026-08-27 20:30:35 -05:00
Nicolas Mowen
a08e2d7529
Upgrade ffmpeg to 8 by default (#23393)
* Upgrade to ffmpeg 8

* Remove workaround

* Cleanup ffmpeg version resolution

* Include older 7.0 for testing purposes

* include
2026-06-03 12:28:28 -05:00
Nicolas Mowen
20705a3e97
Update oneVPL (#22966) 2026-04-22 08:50:37 -06:00
Nicolas Mowen
6cdf4fe3b8
Update intel runtimes to support Battlemage (#22943) 2026-04-20 08:23:15 -06:00
Nicolas Mowen
15ac76f20d
Manually build intel driver (#22881)
* build intel driver

* Update docs
2026-04-15 07:07:27 -05:00
Nicolas Mowen
411798004a
Update ffmpeg (#22548)
* Update ffmpeg builds to 7.1

* Remove unused

* Cleanup
2026-03-20 08:50:58 -05:00
Nicolas Mowen
119137c4fe
Update Intel Deps (#22351)
* Update intel deps

* Cleanup install deps

* Cleanup install deps
2026-03-09 17:15:40 -06:00
Jakub Sojka
c87f89fcc1
Chore/update yq to 4.48.2 (#20967)
* chore: update yq from 4.33.3 to 4.48.2

* fix: update yq v4 syntax for Frigate config upload command

---------

Co-authored-by: Jakub Sojka <jakub.sojka@mallgroup.com>
2025-11-23 08:41:44 -07:00
Josh Hawkins
6ccf8cd2b8
install python3-h2 to fix webpush issues for some users (#20706) 2025-10-28 09:24:44 -05:00
Nicolas Mowen
d7275a3c1a
Add support for Intel NPU (#20536) 2025-10-17 05:58:59 -05:00
Blake Blackshear
a8b7e5dd24 Merge remote-tracking branch 'origin/master' into dev 2025-09-04 06:33:22 -05:00
Piotr Staśkiewicz
a478c38f8a
update legacy intel-compute packages (#19848) 2025-08-31 06:20:50 -06:00
Tim Wesley
dbceb4dcc7
MemryX MX3 detector integration (#17723)
* sdk_2.0_update

* memryx docs: minor reorg

* ran ruff

* whoops, more ruff fixes

* Fixes (#6)

* Fixes and custom model path updated

* ruff formatting

* removed apt install from main

* add comment about libgomp1 in install_deps

---------

Co-authored-by: Abinila Siva <abinila.siva@memryx.com>
Co-authored-by: Abinila Siva <163017635+abinila4@users.noreply.github.com>
2025-08-22 08:11:48 -05:00
Nicolas Mowen
acf32e1a1e
Various Fixes (#19615)
* Don't write to write None response to file

* fix genai config migration

* Fix JP6 build

* Include base image ARG
2025-08-19 06:49:55 -06:00
Nicolas Mowen
b45f642868
Use sed on correct file (#19590) 2025-08-18 07:21:42 -06:00
harry
ceced7cc91
Install non-free i965 driver (#19571) 2025-08-17 18:45:21 -06:00
Jimmy
7ce26087f7 Add Mesa Teflon as a TFLite detector (#18310)
* Refactor common functions for tflite detector implementations

* Add detector using mesa teflon delegate

Non-EdgeTPU TFLite can use the standard .tflite format

* Add mesa-teflon-delegate from bookworm-backports to arm64 images
2025-08-16 10:20:33 -05:00
Nicolas Mowen
0b9997015a Intel updates (#18493)
* Update openvino and onnxruntime

* Install icd and level-zero-gpu deps from intel directly

* Install

* Add dep

* Fix package install
2025-08-16 10:20:33 -05:00
Felipe Santos
e773d63c16
Improve ffmpeg versions handling (#16712)
* Improve ffmpeg versions handling

* Remove fallback from LIBAVFORMAT_VERSION_MAJOR, it should always be set

* Mention ffprobe in custom ffmpeg docs

* Fix ffmpeg extraction

* Fix go2rtc example formatting

* Add fallback back to LIBAVFORMAT_VERSION_MAJOR

* Fix linter
2025-02-20 18:07:41 -07:00
Lander Noterman
94a9dcede8
JetPack 6: fix BASE_HOOK (#16701) 2025-02-20 05:29:22 -07:00
Lander Noterman
5bd412071a
Add support for JetPack 6 (#16571)
* it builds!

* some fixes

* use python 3.11 (rc1)

* add deadsnakes ppa for more recent python 3.11 in jetson images

* fix pip stuff

* revert to tensor 8.6

* revert changes to docker/main

* add hook to install deadsnakes ppa for tensorrt/jetson

* remove unnecessary pip break-system-packages

* move tflite_runtime to requirements-wheels.txt
2025-02-18 07:38:07 -07:00
Nicolas Mowen
1e709f5b3f
Update coral deps and remove unused pycoral (#16630) 2025-02-17 06:57:05 -07:00
Nicolas Mowen
877b7b2910 Update base image (#15103)
* Change base image

* Update python

* Update coral library

* Fix source file

* Install correct apt packages

* Cleanup

* Fix installation of coral deps

* fix python installations

* Fix devcontainer build

* Get tensorrt build working

* Update other deps

* Filter out tflite log

* Get ROCm build working

* Get rockchip build working

* Get hailo build working

* Add note to comment
2025-02-08 12:47:01 -06:00
Nicolas Mowen
0e4ff91d6b Improve face recognition (#15205)
* Validate faces using cosine distance and SVC

* Formatting

* Use opencv instead of face embedding

* Update docs for training data

* Adjust to score system

* Set bounds

* remove face embeddings

* Update writing images

* Add face library page

* Add ability to select file

* Install opencv deps

* Cleanup

* Use different deps

* Move deps

* Cleanup

* Only show face library for desktop

* Implement deleting

* Add ability to upload image

* Add support for uploading images
2025-02-08 12:47:01 -06:00
Nicolas Mowen
a68c7f4ef8
Pin all intel packages (#14887) 2024-11-09 11:08:25 -06:00
Nicolas Mowen
7c474e6827
Pin intel driver (#14884)
* Pin intel driver

* Use slightly older version
2024-11-09 08:09:36 -07:00
Nicolas Mowen
8ac4b001a2
Various fixes (#14410)
* Fix access

* Reorganize tracked object for imports

* Separate out rockchip build

* Formatting

* Use original ffmpeg build

* Fix build

* Update default search type value
2024-10-17 11:02:27 -05:00
Nicolas Mowen
edaccd86d6
Fix build (#14398) 2024-10-16 19:26:47 -05:00
Nicolas Mowen
9f866be110
Remove line in install deps (#14389) 2024-10-16 11:40:31 -05:00
Nicolas Mowen
06f47f262f
Use config attribute map instead of hard coded (#14387) 2024-10-16 07:27:36 -06:00
Nicolas Mowen
9c751230a1
Include lsof in container (#14145) 2024-10-03 17:23:37 -05:00
Nicolas Mowen
e725730982
Fix shared memory frames being stuck when a camera capture crashed (#14140)
* Fix shared memory frames being stuck when a camera capture crashed

* Update ffmpeg build
2024-10-03 09:31:07 -06:00
Nicolas Mowen
6f2924006c
Include radeontop in arm build (#13886) 2024-09-22 10:56:30 -05:00
Sean Kelly
535bf6e4b9
Update install_deps.sh fix typo (#13842) 2024-09-19 19:21:04 -06:00
Nicolas Mowen
d498fabe72
Update ffmpeg to 7 and update intel hwaccel docs (#13834)
* Update ffmpeg to 7 and update intel hwaccel docs

* Formatting

* Redo early gen naming

* Add gamma back in

* Fix table

* Add link to intel docs

* Add hwaccel arg for disabling gamma

* Formatting

* Fix tests

* Formatting

* Fix nvidia
2024-09-19 13:29:58 -06:00
Nicolas Mowen
ddf3a687a3
Use intel apt for out of tree drivers (#13829) 2024-09-19 07:41:08 -06:00
Nicolas Mowen
0c86c77d42
Ffmpeg 6 (#13754)
* Move back to ffmpeg 6

* Use ffmpeg 6
2024-09-15 11:42:52 -06:00
Nicolas Mowen
d5acd11164
Ffmpeg fixes (#13739)
* Only include hwaccel args if detect is being used

* Include both libmfx libraries
2024-09-14 13:22:03 -05:00
Nicolas Mowen
088a0fb4a5
Ffmpeg cleanup (#13737) 2024-09-14 07:03:39 -06:00
Nicolas Mowen
4f10f82580
Install onevpl tools for intel (#13730)
* Install onevpl tools for intel

* Use updated intel lib
2024-09-13 21:18:56 -05:00
Nicolas Mowen
5ff476c6f9
Configurable ffmpeg (#13722)
* Install multiple ffmpeg versions and add config to make it configurable

* Update docs

* Run ffprobe too

* Cleanup

* Apply config to go2rtc as well

* Fix ffmpeg bin

* Docs

* Restore path

* Cleanup env var

* Fix ffmpeg path for encoding

* Fix export

* Formatting
2024-09-13 15:14:51 -05:00
Nicolas Mowen
641f1244dd
Update ffmpeg (#13720) 2024-09-13 09:55:42 -05:00
Nicolas Mowen
18a6aa1824
Update ffmpeg to 7.0.2 (#13578)
* Update to ffmpeg 7.0

* Reduce CPU by not changing pixel format

* Add basic vulkan support

* Adjust gamma after vaapi change

* Formatting
2024-09-05 18:27:32 -06:00
Nicolas Mowen
ef7846bb41
Update ffmpeg source (#12251)
* Revert "Use latest 5.1 ffmpeg update (#12243)"

This reverts commit 93e08688be9b37d9a605f8606c92d2aa34aae7c8.

* Revert "Change qsv device arg to standard hwaccel arg (#12249)"

This reverts commit 56b4a551dc35698f12035d290ab0b1de275bb920.

* Use different repo for build
2024-07-01 15:46:40 -06:00
Nicolas Mowen
93e08688be
Use latest 5.1 ffmpeg update (#12243)
* Use latesat 5.1 ffmpeg update

* Fix arm build
2024-07-01 11:08:36 -05:00
Nicolas Mowen
126aed2798
Include non-free in hwaccel deps types (#8203) 2023-10-17 21:18:50 -04:00
Nicolas Mowen
c7b2c6b95d
Pin all hwaccel deps (#8191) 2023-10-17 06:37:40 -05:00
Nicolas Mowen
0048cd5edc
Pull radeon driver from bookworm (#7983) 2023-09-28 18:20:48 -05:00
Andrew Reiter
a96a951e23
Nvidia Jetson ffmpeg + TensorRT support (#6458)
* Non-Jetson changes

Required for later commits:
- Allow base image to be overridden (and don't assume its WORKDIR)
- Ensure python3.9
- Map hwaccel decode presets as strings instead of lists
Not required:
- Fix existing documentation
- Simplify hwaccel scale logic

* Prepare for multi-arch tensorrt build

* Add tensorrt images for Jetson boards

* Add Jetson ffmpeg hwaccel

* Update docs

* Add CODEOWNERS

* CI

* Change default model from yolov7-tiny-416 to yolov7-320

In my experience the tiny models perform markedly worse without being
much faster

* fixup! Update docs
2023-07-26 05:50:41 -05:00