Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/fluentforward-collector-auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@hyperdx/api': patch
---

fix: Stop the collector accepting unauthenticated Fluent Forward logs when
collector authentication is enforced. The `fluentforward` receiver (port 24225)
has no way to check an API key, so it is now left out of the OpAMP config for
teams that enforce collector authentication, which is the default for teams
created at registration.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,49 @@ describe('opampController', () => {
});
});

describe('buildOtelCollectorConfig fluentforward receiver', () => {
it('keeps the fluentforward receiver when collector authentication is not enforced', () => {
const cfg = buildOtelCollectorConfig([
{ apiKey: 'k1', collectorAuthenticationEnforced: false },
]);

expect(cfg.receivers.fluentforward).toEqual({
endpoint: '0.0.0.0:24225',
});
expect(cfg.service.pipelines['logs/in'].receivers).toContain(
'fluentforward',
);
});

it('removes the fluentforward receiver when collector authentication is enforced', () => {
const cfg = buildOtelCollectorConfig([
{ apiKey: 'k1', collectorAuthenticationEnforced: true },
]);

// The receiver cannot authenticate, so it must not listen at all.
expect(cfg.receivers.fluentforward).toBeUndefined();
expect(cfg.service.pipelines['logs/in'].receivers).toEqual([
'otlp/hyperdx',
]);
});

it('keeps the fluentforward receiver when enforcement is on but no API keys exist', () => {
const cfg = buildOtelCollectorConfig([
{ apiKey: '', collectorAuthenticationEnforced: true },
]);

// Without keys nothing is authenticated (otlp/hyperdx is not attached
// either), and fluentforward is the only logs/in receiver: removing it
// would leave the pipeline empty, which the collector rejects.
expect(cfg.receivers.fluentforward).toEqual({
endpoint: '0.0.0.0:24225',
});
expect(cfg.service.pipelines['logs/in'].receivers).toEqual([
'fluentforward',
]);
});
});

describe('buildOtelCollectorConfig datadog receiver', () => {
it('omits the datadog receiver when the flag is off (default)', () => {
configState.ENABLE_DATADOG_RECEIVER = false;
Expand Down Expand Up @@ -244,6 +287,11 @@ describe('opampController', () => {
expect(cfg.service.extensions).toContain('bearertokenauth/datadog');
// The otlp/hyperdx auth extension stays intact alongside it.
expect(cfg.service.extensions).toContain('bearertokenauth/hyperdx');
// Only authenticated receivers feed logs/in; fluentforward is gone.
expect(cfg.service.pipelines['logs/in'].receivers).toEqual([
'otlp/hyperdx',
'datadog',
]);
});
});
});
7 changes: 6 additions & 1 deletion packages/api/src/opamp/controllers/opampController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ export const buildOtelCollectorConfig = (
exporters: ['clickhouse'],
},
'logs/in': {
// TODO: fluentforward needs to be authenticated
receivers: ['fluentforward'],
exporters: ['routing/logs'],
},
Expand Down Expand Up @@ -381,6 +380,12 @@ export const buildOtelCollectorConfig = (
authenticator: 'bearertokenauth/hyperdx',
};
otelCollectorConfig.service.extensions = ['bearertokenauth/hyperdx'];

// fluentforward has no authenticator option, so while it is listening
// anyone who can reach :24225 can ingest without an API key.
delete otelCollectorConfig.receivers.fluentforward;
const logsIn = otelCollectorConfig.service.pipelines['logs/in'];
logsIn.receivers = logsIn.receivers.filter(r => r !== 'fluentforward');
}
}

Expand Down
Loading