Security: enforce authentication on the bundled NATS event bus#12317
Open
thistehneisen wants to merge 1 commit into
Open
Security: enforce authentication on the bundled NATS event bus#12317thistehneisen wants to merge 1 commit into
thistehneisen wants to merge 1 commit into
Conversation
The embedded NATS server was constructed without any authentication option, so any client able to reach the port could subscribe to and publish forged internal events (postprocessing/antivirus verdicts, upload finalize/revert, notifications). Clients already authenticate via OCIS_EVENTS_AUTH_USERNAME/ OCIS_EVENTS_AUTH_PASSWORD, but the server never enforced them. - add AuthUsername/AuthPassword to the nats service config (symmetric OCIS_EVENTS_AUTH_* env vars) - add a server-side Auth option and wire it into the server command - warn when the broker is bound to a non-loopback address without auth - require event-bus credentials in the ocis_full and ocis_multi example deployments and stop defaulting OCIS_INSECURE=true in ocis_multi
d2035e5 to
db18919
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security: enforce authentication on the bundled NATS event bus
Summary
The bundled NATS server is started with no authentication. The internal
event bus carries security-relevant control messages (postprocessing /
antivirus verdicts, upload finalize/abort/revert, share and notification
events). Any party that can open a TCP connection to the NATS port can both
subscribe to and publish forged events of any type, because:
username/password/token/NKey/authorization option — it accepts any client.
OCIS_EVENTS_AUTH_USERNAME/OCIS_EVENTS_AUTH_PASSWORDfor clients, but the server never enforces them (no accounts are
configured server-side), so the client-side auth is currently inert.
multi-service example deployments bind the broker to
0.0.0.0.Consumers trust event content with no message authenticity (single subject,
type is a plaintext metadata string). A forged
PostprocessingFinished(
Outcome: continue/delete) orRevertRevision/CleanUploadevent isacted on by the storage layer with only a non-secret mount-id check, enabling
antivirus bypass, finalize-of-unscanned-content, and tampering/destruction of
other users' in-flight uploads; forged
SendSSE/ShareCreatedevents enablenotification spoofing.
Affected code
services/nats/pkg/command/server.go—nats.NewNATSServer(...)is calledwith only
Host,Port,ClusterID,StoreDir,TLSConfig,AllowNonTLS. No authentication option is ever set.services/nats/pkg/server/nats/options.go,services/nats/pkg/server/nats/nats.go— nousername/password/token/NKey/authorization option exists on the embedded
server wrapper.
services/nats/pkg/config/defaults/defaultconfig.go—EnableTLS: falseby default; client auth config exists but is unenforced server-side.
deployments/examples/ocis_full/ocis.yml,deployments/examples/ocis_multi/docker-compose.yml(
NATS_NATS_HOST: 0.0.0.0, andOCIS_INSECUREdefaulting true inocis_multi).Downstream trust (context, fix tracked separately — see "Out of scope"):
vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/decomposedfs.goacts on
PostprocessingFinished/RevertRevision/CleanUploadwith only anon-secret
MountIDcomparison (skipped when empty).Impact
to the bus can forge postprocessing verdicts (antivirus bypass, finalize
unscanned/infected content), force-delete or revert arbitrary users'
uploads, and spoof notifications/SSE.
single-binary deployment this is
127.0.0.1(internal only); in the shippedmulti-service example topologies the broker is bound to
0.0.0.0with noauthentication, reachable by any peer on the network / any co-resident
container, or via an internal request-forgery foothold.
broker authentication is a systemic root cause that applies to every
deployment. CVSS:3.1 (proposed)
AV:A/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:H— adjust on review.Proposed fix
Primary (this PR, oCIS):
authorization option to
services/nats/pkg/server/nats/{options,nats}.goand set it in
services/nats/pkg/command/server.gofrom the existingNatsauth config (the same credentials clients already send viaOCIS_EVENTS_AUTH_USERNAME/OCIS_EVENTS_AUTH_PASSWORD/ token), so thebroker actually rejects unauthenticated clients. Make the broker refuse to
start (or log a prominent warning, per maintainer preference) when bound to
a non-loopback host without credentials/TLS.
0.0.0.0without credentials; document the network-isolation/credentials requirement;
stop defaulting
OCIS_INSECURE=trueinocis_multi.Backwards compatibility / risk
OCIS_EVENTS_AUTH_*keep working (the servernow enforces what clients already send). Deployments that relied on an
anonymous bus must set credentials — call this out clearly in the changelog
and upgrade notes.
guard only triggers for non-loopback binds without credentials.
Test plan
auth is configured; accepts correct credentials.
OCIS_EVENTS_AUTH_*set; an external client without credentials cannot subscribe or publish.
0.0.0.0without credentials triggers therefuse/warn behaviour; loopback default still starts cleanly.
Nils Putnins / OffSeq Cybersecurity
npu@offseq.com / https://offseq.com / https://radar.offseq.com