Skip to content

Commit a383d87

Browse files
erikhortschclaude
andcommitted
Add OSS Scanner build image and threat model
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent eecdef3 commit a383d87

2 files changed

Lines changed: 120 additions & 0 deletions

File tree

‎.oss-scanner/Dockerfile‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2026 LiveKit, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Build image for Anthropic's OSS Scanner. Keep the Go version at or above go.mod's: GOTOOLCHAIN=local won't fetch one.
16+
FROM golang:1.26-bookworm
17+
18+
ENV DEBIAN_FRONTEND=noninteractive \
19+
GOTOOLCHAIN=local
20+
21+
RUN apt-get update && apt-get install -y --no-install-recommends \
22+
build-essential ca-certificates git \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
WORKDIR /src
26+
COPY . /src
27+
28+
RUN go mod download && go mod verify
29+
RUN go build ./... && go vet ./auth/... ./webhook/... ./datatrack/... ./sdp/...
30+
31+
RUN go test -count=1 -timeout 20m ./... || echo 'WARNING: baseline tests failed'
32+
33+
ENV GOPROXY=off \
34+
GOSUMDB=off
35+
36+
CMD ["bash"]

‎.oss-scanner/threat_model.md‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# LiveKit protocol threat model
2+
3+
`github.com/livekit/protocol` is a Go library shared by the LiveKit server, the
4+
Go server SDK, and LiveKit's media services. It holds the protobuf definitions
5+
and generated code, plus the Go helpers that interpret untrusted input on their
6+
behalf: access-token and webhook verification, SDP and RTP helpers, data-track
7+
packet parsing, and decode budgets for protobuf and JSON.
8+
9+
## Scope and trust boundaries
10+
11+
Audit the hand-written Go on `main`. Prioritise:
12+
13+
- `auth/`: access-token minting, parsing, and verification, and grant
14+
semantics (`ClaimGrants`, `VideoGrant`, `SIPGrant`, agent and inference
15+
grants).
16+
- `webhook/`: `Receive` / `ReceiveWebhookEvent` (signature and body-hash
17+
verification) and the outbound notifier.
18+
- `utils/jwtutil/`, `utils/decodebudget/`: JWT helpers and resource limits for
19+
decoding untrusted protobuf and JSON.
20+
- `datatrack/`, `sdp/`, `utils/rtputil/`, `codecs/`: parsers for packets and
21+
SDP that arrive from clients.
22+
- `sip/`: SIP token building, phone-number normalisation, and trunk and
23+
dispatch-rule matching.
24+
- `utils/` helpers that redact secrets or handle IDs.
25+
26+
Out of scope: generated code (`*.pb.go`, `*.twirp.go`, `*.psrpc.go`), the
27+
`.proto` files themselves, the JS packages under `packages/`, and build tooling
28+
under `magefile.go` and `tools/`. Report a bug in a generated file only when
29+
the generator template or the `.proto` definition causes it.
30+
31+
Untrusted input: access tokens and webhook requests from the network, SDP,
32+
RTP/RTCP, and data-track packets from clients, and any protobuf or JSON a
33+
client can send that these packages decode.
34+
35+
Trusted: API secrets, the caller's configuration, and values the embedding
36+
application passes in after it has authenticated them.
37+
38+
LiveKit server (`livekit/livekit`) is enrolled separately. Report bugs in how
39+
the server uses these packages there; report bugs in the packages here.
40+
41+
## Security properties
42+
43+
- **Token verification:** a token must verify only with its issuer's secret,
44+
only with HS256, and only inside its validity window. Parsing an unverified
45+
token must never be treated as verification. Grants must deserialize exactly
46+
as signed; a token must not gain a grant, room, or identity it was not issued.
47+
- **Webhook verification:** an event must be accepted only when its token
48+
verifies and the body's SHA-256 matches the signed hash.
49+
- **Parsing:** SDP, RTP extensions, data-track packets, and decode-budget
50+
inputs must not panic, loop, or allocate without bound on malformed input.
51+
- **Decode budgets:** the budget must bound the memory and CPU of decoding the
52+
message it is applied to.
53+
- **Secrets:** API secrets must not appear in logs, errors, or redacted output.
54+
55+
## Severity guidance
56+
57+
- **Critical:** forging a token or webhook that verifies without the secret.
58+
- **High:** accepting an expired, wrong-algorithm, or wrong-issuer token;
59+
grant escalation through parsing; a panic reachable from untrusted network
60+
input that crashes the embedding process.
61+
- **Medium:** unbounded resource use from one untrusted input; a decode budget
62+
that undercounts by a large factor; secret leakage into logs.
63+
- **Low / not a finding:** misuse that needs the API secret or caller
64+
configuration; issues only in generated code; outbound webhook delivery
65+
behaviour (retries, ordering) without a security impact.
66+
67+
## Testing
68+
69+
The checkout is at `/src`. Go dependencies are cached. `GOPROXY=off` and
70+
`GOSUMDB=off` prevent downloads. No external services are needed.
71+
72+
```sh
73+
cd /src
74+
go test -count=1 ./...
75+
go test -race -count=1 ./auth/... ./webhook/... ./datatrack/... ./sdp/...
76+
go test -run '^$' -fuzz FuzzPacketUnmarshal -fuzztime 60s ./datatrack
77+
go test -run '^$' -fuzz FuzzSDPFragmentUnmarshal -fuzztime 60s ./sdp
78+
```
79+
80+
## Reports
81+
82+
State the attacker's required access (none, any valid token, or a specific
83+
grant), the entry point, and the demonstrated impact. Provide a minimal
84+
reproducer, preferably a Go test in the affected package.

0 commit comments

Comments
 (0)