elastic / elastic/integrations
[bug-hunter] otlp_input_otel basic auth can render without htpasswd credentials
- Dominant language
- Handlebars
- Stars
- 333
- Forks
- 647
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 209
Description
## Impact
When users enable Basic Auth in `otlp_input_otel` without setting `basic_auth_htpasswd_file` or `basic_auth_htpasswd_inline`, the generated collector config still enables `basicauth` but renders an empty `htpasswd` block. This produces an invalid auth config (`no credential source provided`) and can prevent receiver auth/startup from working.
## Reproduction Steps
1. From the repo root, create a minimal repro workspace:
```bash
mkdir -p /tmp/gh-aw/agent/repro-otlp && cd /tmp/gh-aw/agent/repro-otlp
npm init -y >/dev/null
npm install handlebars@4 >/dev/null
```
2. Save this script as `repro.js`:
```js
const fs = require('fs');
const Handlebars = require('handlebars');
const template = fs.readFileSync('/home/runner/work/integrations/integrations/packages/otlp_input_otel/agent/input/input.yml.hbs', 'utf8');
const render = Handlebars.compile(template);
const rendered = render({
enable_basic_auth: true,
grpc_endpoint: '0.0.0.0:4317',
http_endpoint: '0.0.0.0:4318',
enable_logs: true,
enable_metrics: false,
enable_traces: false,
});
const hasHtpasswd = /\n\s*htpasswd:\s*(\n|$)/.test(rendered);
const hasFile = /\n\s*file:\s*\S+/.test(rendered);
const hasInline = /\n\s*inline:\s*\|/.test(rendered);
if (hasHtpasswd && !hasFile && !hasInline) {
console.error('FAIL: enable_basic_auth=true renders basicauth.htpasswd without file/inline credentials');
process.exit(1);
}
console.log('PASS');
```
3. Run:
```bash
node repro.js
```
## Expected vs Actual
**Expected:** Enabling Basic Auth should require or enforce at least one credential source (`basic_auth_htpasswd_file` or `basic_auth_htpasswd_inline`), so rendered config is valid.
**Actual:** Rendered config contains:
```yaml
extensions:
basicauth:
htpasswd:
```
with neither `file` nor `inline`, and the repro fails with:
```text
FAIL: enable_basic_auth=true renders basicauth.htpasswd without file/inline credentials
```
## Failing Test
```js
const fs = require('fs');
const Handlebars = require('handlebars');
const template = fs.readFileSync('/home/runner/work/integrations/integrations/packages/otlp_input_otel/agent/input/input.yml.hbs', 'utf8');
const render = Handlebars.compile(template);
const rendered = render({
enable_basic_auth: true,
grpc_endpoint: '0.0.0.0:4317',
http_endpoint: '0.0.0.0:4318',
enable_logs: true,
enable_metrics: false,
enable_traces: false,
});
const hasHtpasswd = /\n\s*htpasswd:\s*(\n|$)/.test(rendered);
const hasFile = /\n\s*file:\s*\S+/.test(rendered);
const hasInline = /\n\s*inline:\s*\|/.test(rendered);
if (hasHtpasswd && !hasFile && !hasInline) {
console.error('FAIL: enable_basic_auth=true renders basicauth.htpasswd without file/inline credentials');
process.exit(1);
}
console.log('PASS');
```
## Evidence
- `packages/otlp_input_otel/agent/input/input.yml.hbs#L1-L11` always renders `extensions.basicauth.htpasswd` when `enable_basic_auth=true`, but `file`/`inline` are both conditional.
- `packages/otlp_input_otel/manifest.yml#L76-L87` marks both `basic_auth_htpasswd_file` and `basic_auth_htpasswd_inline` as `required: false`, despite description saying file is required when Basic Auth is enabled.
- Additional runtime validation evidence using OpenTelemetry basicauth config validation returned:
```text
validation_error=no credential source provided
```
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Bug Hunter](https://github.com/elastic/integrations/actions/runs/25163029194)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
> - [x] expires on May 7, 2026, 11:47 AM UTC
Contributor guide
Assessment
This issue has not been assessed yet.