Splitting the MQTT URI on every comma broke previously valid single-broker
URIs with commas in the query string, credentials or path (for example
wss://broker/mqtt?token=a,b). A comma now only separates brokers when the
text after it starts with a URI scheme ("scheme://"); other commas stay in
the current broker URI. Adds regression cases for these URIs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MQTT URI can now list several brokers, either as an ActiveMQ-style
failover URI (as used by Amazon MQ active/standby brokers) or as a plain
comma-separated list:
failover:(mqtt+ssl://b-1.example:8883,mqtt+ssl://b-2.example:8883)
Each broker is registered with paho, which tries them in order on
connect and reconnect. Transport options after the closing parenthesis
are ignored. The diagnostics dialer is only installed when every broker
uses a TCP-based scheme.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v3.14.4 started authorising only tokens for the configured account. Kerberos
Factory signs its own tokens for agents with the shared AGENT_JWT_SECRET
under the "factory" identity, so every Factory request to a 3.14.4+ agent
was rejected with 403.
When AGENT_JWT_SECRET is explicitly set, also accept the "factory" identity.
Only holders of that secret can sign such tokens. With the generated
per-install secret only the agent's own login issues tokens, so the identity
stays rejected there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recordings were encrypted in the OpenSSL/CryptoJS "Salted__" format, which
derives the AES key from the configured symmetric key with a single MD5
round. A captured recording therefore allowed fast offline guessing of
weak keys.
New recordings use a versioned format: magic "KRBREC1\0", the PBKDF2
iteration count, a 16-byte salt and a 12-byte nonce, followed by AES-256-GCM
ciphertext. The key is derived with PBKDF2-HMAC-SHA256 (600,000 iterations)
once per process and cached, so cameras do not pay the derivation cost per
recording; each recording still gets a fresh nonce. The header is
authenticated, and decryption caps the iteration count so a crafted file
cannot stall the agent.
DecryptRecording still reads the legacy format, so existing recordings keep
playing through /file and -action decrypt. The legacy decryption now
validates length and padding instead of panicking on truncated input or a
wrong key.
MQTT messages exchanged with Kerberos Hub keep the legacy format, which Hub
expects; their keys are random, so the weak key derivation does not make
them guessable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- JWT signing key: without AGENT_JWT_SECRET, generate a random secret on
first start and keep it in data/config/jwt_secret (0600) instead of
falling back to a publicly known constant. AGENT_JWT_SECRET still takes
precedence, so deployments that share a key with Kerberos Factory are
unchanged.
- Only tokens for the configured account are authorised, and malformed
token claims are rejected instead of panicking.
- /ws (live view) and /file (recordings) now require a valid token. The UI
passes it as ?token=, since browsers cannot set headers on WebSocket
connections or <video src>; it no longer opens the socket before sign-in.
/file no longer sends its own wildcard CORS header.
- pprof is off by default; AGENT_ENABLE_PPROF=true registers it behind auth.
- Release workflows pass tags to shell steps through quoted environment
variables and validate them; the shared release-bump workflow is pinned
to a commit and no longer receives inherited secrets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
158 entries in ui/yarn.lock were resolved from an Azure DevOps feed
(ms-feed-25.pkgs.visualstudio.com) instead of registry.yarnpkg.com. Point them
back at the public registry. Each entry's sha1 was checked against the npm
registry before it was rewritten, so the tarballs are identical. The 96
sha1-only integrity values are replaced with the registry's sha512.
axios is left as is: #359 moves it to 0.34.0 on the public registry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes Dependabot alerts #601 (GHSA-x97p-jq2g-jp4f) and #602
(GHSA-9fr6-4gfg-395g). The dependency ranges are unchanged, so only the axios
lockfile entry moves, now resolved from registry.yarnpkg.com.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The S3 proxy transport always set InsecureSkipVerify. Gate it on
AGENT_TLS_INSECURE like the other HTTP clients in the agent. Deployments that
use an S3 proxy with a self-signed certificate now need AGENT_TLS_INSECURE=true.
Fixes code scanning alert #100 (go/disabled-certificate-check).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VerifyPersistence and VerifySecondaryPersistence sent the Vault access and
secret keys to whatever URI the request body named. Apply the same rule the
Hub check already uses: only the saved URI may be contacted, and redirects
are refused so the keys cannot be forwarded to another host.
Fixes code scanning alerts #84, #85, #86 and #87 (go/request-forgery).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ui: migrate from Create React App to Vite
react-scripts 5 is unmaintained and pins vulnerable versions of
webpack-dev-server, webpack-dev-middleware, postcss 7 and svgo.
- build and dev server: Vite 8 with @vitejs/plugin-react
- tests: Vitest 4 with jsdom (jest.* -> vi.*; mocked default exports
now return { default })
- index.html moves to ui/ and loads src/index.jsx as a module
- REACT_APP_ENVIRONMENT is replaced by import.meta.env.PROD/MODE, and
REACT_APP_AGENT_API_PORT is renamed to VITE_AGENT_API_PORT
- bundled output goes to static/ so it does not mix with public/assets
- package.json is not "type": "module": that would switch CommonJS
interop to Node semantics and break default imports such as
@giantmachines/redux-websocket
- sass 1.54 -> 1.108 (Vite needs the modern compiler API); sass-loader
removed
- requires Node >= 20.19
`yarn build` still writes to machinery/www, so the Dockerfile and CI
workflow are unchanged.
Clears the remaining 9 react-scripts Dependabot alerts. Five alerts for
svgo 1 and decode-uri-component 0.2 remain; they come from build-tool
dependencies of @kerberos-io/ui and are not part of the bundle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ui: vendor @kerberos-io/ui 1.77.1 to clear the last Dependabot alerts
@kerberos-io/ui 1.77.1 moves its build tools (@svgr/webpack,
svg-react-loader, sass-loader, Storybook, Rollup plugins) out of its
runtime dependencies. Those pulled svgo 1 and decode-uri-component 0.2
into the agent's lockfile.
1.77.1 is tagged on GitHub but was never published to npm, so install
it from a tarball built from kerberos-io/ui@ae1faa7 (tag v1.77.1) and
committed under ui/vendor. Compared with the published 1.77.0 the
exports are identical; the only code change is the bundled uuid (8 -> 11).
The Dockerfile copies ui/vendor before `yarn --frozen-lockfile`.
ui/vendor/README.md records the checksum and how to switch back to the
registry once a fixed version is published.
Clears the remaining 5 Dependabot alerts (svgo, decode-uri-component).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ui: install @kerberos-io/ui 1.77.1 from its GitHub release
Replace the vendored tarball with the one attached to the kerberos-io/ui
v1.77.1 GitHub release, as uug-ai/factory already does. That tarball is
built by the ui repo's release workflow and ships with a .sha256 file
(e9f94f44...); yarn.lock pins it by hash.
Its JS is identical to the locally built tarball, and its CSS differs
only in selector order within @extend-generated rules.
This removes ui/vendor and the extra COPY line in the Dockerfile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ui: address lint findings in the Vite migration
- vite.config.mjs: disable import/no-unresolved; eslint-plugin-import 2.x
cannot resolve packages that only define "exports" (vite, plugin-react)
- ui/README.md: turn the scripts table into a list to keep lines short
- README.md: wrap the edited UI paragraph
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
github.com/moq-dev/moq-go was renamed to moq.dev/moq. Its native library
(moq.dev/moq-ffi v0.4.27) ships without LLVM bitcode, so `go build -tags moq`
works on Go 1.26.11+, which rejects the bitcode in moq-go-ffi v0.3.x.
- github.com/moq-dev/moq-go v0.5.7 -> moq.dev/moq v0.7.27
(moq-go-ffi v0.3.7 -> moq.dev/moq-ffi v0.4.27)
- BroadcastProducer.PublishMedia("avc3", nil) ->
PublishVideo(moq.VideoFormatAvc3, nil); the rest of the API the agent
uses is unchanged
- unpin Go: the build image goes back to golang:1.26-trixie and the
devcontainer drops GOTOOLCHAIN=go1.26.10
Compatibility:
- the derived track name is still "0.avc3"
- the relay accepts the new client (wire protocol moq-lite-05 -> moq-lite-07)
- the catalog keeps the same rendition, codec and container; the
per-rendition "timeline" moves to a top-level "archive" and a "clock"
object is added. The Hub viewer's schema (@moq/hang 0.2.16, used by
@moq/watch 0.2.17) accepts it, and timeline is optional and unused for
live playback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
golang:1.26-trixie now resolves to Go 1.26.11, which rejects C archives
that contain LLVM bitcode:
disallowed LTO section ".llvmbc" in #cgo LDFLAGS:
.../moq-go-ffi@v0.3.7/moq/lib/linux_arm64/libmoq_ffi.a
Every moq-go-ffi v0.3.x release ships such archives, so `go build -tags moq`
fails in the Docker build on amd64 and arm64. There is no opt-out. Only
moq-ffi v0.4.27+ (module moq.dev/moq-ffi, used by moq.dev/moq v0.7) is clean,
which needs a migration of the MoQ code.
Pin the build image to golang:1.26.10-trixie and set GOTOOLCHAIN=go1.26.10
in the devcontainer, where verify-moq-devcontainer.sh builds with -tags moq.
The Go CI workflow builds without the moq tag and stays on 1.26.x.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- MQTT verify: accept rtsp_transport in the verify payload and fall back
to the configured transport, like the RTSP url already does, so unsaved
transport choices can be verified from Kerberos Hub.
- RTSPS + forced UDP: fail fast with a clear error when the camera does
not offer SRTP, instead of every SETUP failing with "unable to setup
secure UDP" (which Connect only logs). "auto" already picks TCP here.
- Backchannel: always use TCP. gortsplib's auto fallback only triggers
when no packets are received, which never happens on a send-only
backchannel, and talk-back over UDP is not validated on hardware.
- UDP read buffer: request 4 MiB, capped at net.core.rmem_max, because
gortsplib fails the SETUP when it cannot get the exact size requested.
- Logging: route gortsplib's transport-switch messages through the
structured logger and log the negotiated transport per stream.
- README: document the transport options and their caveats.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
machinery (Go):
- google.golang.org/grpc 1.72.1 -> 1.83.2 (incl. critical :path authz bypass)
- go.opentelemetry.io/otel/* 1.36.0 -> 1.47.0
- go.mongodb.org/mongo-driver 1.17.3 -> 1.17.7
- github.com/klauspost/compress 1.16.7 -> 1.20.2
- github.com/eclipse/paho.mqtt.golang 1.5.0 -> 1.5.1 (govulncheck)
- golang.org/x/net 0.57.0 -> 0.62.0 (govulncheck)
otel 1.47 and x/net 0.62 require Go 1.26, so the build image,
devcontainer and CI move from 1.25 to 1.26.
ui:
- axios 0.21.4 -> 0.33.0 (stays on the 0.x API)
- drop unused i18next-http-backend (app uses i18next-xhr-backend)
- replace uuidv4 with uuid 11
- refresh vulnerable transitive packages to the newest in-range versions
and add resolutions for @tootallnate/once, serialize-javascript, uuid
- refresh @babel/compat-data and helper-compilation-targets so the newer
browserslist targets are recognised by the build
Remaining alerts (webpack-dev-server 4, webpack-dev-middleware 5,
postcss 7, svgo 1, decode-uri-component 0.2) are pinned by
react-scripts 5 and only affect the dev server and build tooling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runTusUpload also serves direct Kerberos Vault uploads. A 429 from a vault
now keeps the existing in-cycle retries instead of ending the attempt, so it
does not advance the vault's retry budget or secondary-storage failover
early, and it never sets the Hub upload pause. Hub uploads still stop at
once and pause until Retry-After (review feedback).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kerberos Hub will answer a recording upload with 429 Too Many Requests and
Retry-After (start of the next day or month in the organisation's
timezone) when the organisation is over its upload limit. Until now the
agent kept the recording and retried every 5 seconds all night.
- A shared, mutex-guarded upload pause (upload_pause.go) holds the
deadline. Retry-After is parsed in both RFC 9110 forms (delay-seconds
and HTTP-date, the latter measured against the response Date header).
Values are clamped to [5 s, 32 days]; a 429 without a usable
Retry-After backs off exponentially from 5 s up to 15 minutes.
- The tus path (create, HEAD, PATCH) and the legacy HEAD/POST on
/storage/upload report 429; the tus loop stops retrying on 429 and
keeps its resume state.
- HandleUpload waits for the pause before touching the queue again.
Recordings and markers stay on disk; the order is unchanged.
- One log line when the pause starts and one when Hub accepts uploads
again. Heartbeats, live view and MQTT are untouched; other status codes
and older Hub versions behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Accumulate gated and discarded sample durations, including previously queued skips, and advance Pion's clock without filler packets before the recovery IDR. Verify exact outgoing RTP timestamp deltas for PLI, FIR, reconnects, and queue overflow.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Gate each video viewer on a fresh IDR after transport connection or recovery, translate viewer PLI/FIR into rate-limited RTSP PLI requests, and preserve keyframe metadata through sample buffering. Add transport, lifecycle, concurrency, and source-routing regressions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The agent hard-coded TCP (interleaved) for every camera connection, so
cameras and networks that only work well over UDP could not be used and
there was no way to let the client negotiate the transport.
Add an optional capture.ipcamera.rtsp_transport setting, also available
as AGENT_CAPTURE_IPCAMERA_RTSP_TRANSPORT, with these values:
- tcp (default, also used when unset): unchanged behaviour
- udp: force RTP over UDP
- auto: let gortsplib try UDP first and fall back to TCP
Unknown values log a warning and fall back to TCP so a typo cannot break
an existing deployment. The setting is applied to the main, sub and
backchannel clients and to both camera verification paths (HTTP and
MQTT). The Settings page gets a transport dropdown next to the RTSP URLs
and the verify request forwards the selected value, so unsaved choices
can be tested. The README documents the new variable.
Tests cover the transport-to-protocol mapping and the environment
override.
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Avoid dereferencing the nil client returned when Hub credentials are absent. Log the disabled worker and cover enabled, disabled, and offline configurations.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Encoders and NVRs expose several media profiles per video input, so
always using the first profile drives the camera on channel 1. Add a
1-based onvif_channel setting (config file, configmap, MongoDB, env var
AGENT_CAPTURE_IPCAMERA_ONVIF_CHANNEL, and onvif_credentials in the HTTP
API). The channel is resolved by grouping GetProfiles results by video
source; 0/unset keeps the existing first-profile behaviour.
PTZ, zoom, presets, position and focus now use the configured channel,
and the Hub heartbeat reads presets from it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep successful upload creation sessions usable when the optional response body is interrupted, while still requiring Location. Preserve the latest failure across retries and add regression coverage and documentation.
Include up to 4 KiB of server error responses and retain the latest failure cause when retries are exhausted. Add coverage for Hub and Vault creation failures and document provider troubleshooting and the temporary ordinary-upload workaround.
Backfill missing S3 checkpoint descriptions from validated legacy filenames while preserving checkpoint values, timestamp, and device key. Skip recordings deleted during directory scans while continuing to report other errors. Add regression coverage and document the metadata fallback.
Store new recordings in UTC date directories with stable timestamp-device filenames, moving recording attributes into upload checkpoints. Use checkpoint metadata for S3 keys and HTTP/tus uploads, rejecting invalid S3 checkpoints instead of silently falling back.
Support flat and dated layouts across listing, playback, uploads, cleanup, and decryption while retaining legacy filename compatibility.
Use the filename's recording timestamp to build username/yyyy/mm/dd object keys, keeping retries consistent across midnight. Reject malformed filenames and timestamps, add date-layout coverage, and document compatibility with historical objects.
Add "focus" and "autofocus" ONVIF actions, sent through navigate-ptz in
the same shape as zoom:
{"action":"focus","payload":{"focus":0.5}} positive = near, -1..1
{"action":"autofocus","payload":{}}
Focus goes through the ONVIF imaging service and is handled before the
PTZ configuration lookup, so it also works on fixed cameras with a
motorised lens. A focus nudge switches the camera to MANUAL focus;
autofocus hands control back.
Cameras differ in which focus moves they support, so the move type is
picked from GetMoveOptions: a continuous move for 500 ms then stop (as
ContinuousZoom), else a relative step, else an absolute step from the
current lens position (Axis only supports absolute moves).
Autofocus toggles MANUAL -> AUTO to force a fresh focus cycle. It
reports an error when the camera does not advertise AUTO, or accepts
AUTO but keeps reporting MANUAL (seen on Dahua).
The imaging requests carry only the focus fields, because the onvif
library's request types serialise every field. Some Axis firmware
rejects a SetImagingSettings that only carries Focus, so that request is
retried once with the current brightness. Rejected requests include the
camera's SOAP fault reason in the error.
Also add POST /api/camera/onvif/focus, mirroring /api/camera/onvif/zoom.
Hub: needs an adjustable focus step. How far one nudge moves the lens
differs a lot between cameras: one full-speed nudge crossed the whole
focus range on an Avigilon, while three barely moved another camera.
The agent uses the focus value (-1..1) as the speed / step size, so Hub
should let users set it (e.g. a focus step or speed control) instead of
sending a fixed value.
Tested against Axis, Dahua, Avigilon and two other ONVIF cameras.
Use port 8082 for UI development endpoints, VS Code debugging, and devcontainer forwarding. Allow overriding the UI API port with REACT_APP_AGENT_API_PORT and document the matching backend setup.
Require Hub and persistence verification URIs to match the saved configuration and reject redirects to prevent credential leakage. Add regression tests for unsaved URIs and cross-host redirects.