Skip to content

[9.4] [Fleet] Validate SSL certificate paths for whitespace#267275

Open
juliaElastic wants to merge 5 commits intoelastic:9.4from
juliaElastic:backport-266365-to-9.4
Open

[9.4] [Fleet] Validate SSL certificate paths for whitespace#267275
juliaElastic wants to merge 5 commits intoelastic:9.4from
juliaElastic:backport-266365-to-9.4

Conversation

@juliaElastic
Copy link
Copy Markdown
Contributor

Backport

This is a backport of PR #266365 to 9.4.

Original PR description

Validates SSL certificate path fields for whitespace characters to prevent
silent failures when saving Fleet settings flyouts.

Conflict resolution

  • oas_docs/output/kibana.serverless.yaml and kibana.yaml: accepted 9.4 version (generated files)
  • x-pack/platform/plugins/shared/fleet/common/services/index.ts: added only the validateSslCertPath export; excluded yaml_utils exports that don't exist on 9.4
  • x-pack/platform/plugins/shared/fleet/server/types/models/output.ts: took incoming compression_level schema fix (schema.maybe(schema.oneOf([...])))

Fixes elastic#265694

TLS certificate fields in Fleet settings forms (Agent binary source,
Output, Fleet Server Hosts, Fleet Proxy) accept file paths with spaces
without validation. These paths are propagated into the generated agent
policy, causing Elastic Agent to fail to resolve the certificate file
and become unhealthy.

**Shared validator — `common/services/ssl_validators.ts`**
- `validateSslCertPath(value)`: rejects whitespace in file paths; exempt
when value is PEM content (leading `-----BEGIN`). Works for Linux,
Windows (`C:\`, `C:/`), and UNC (`\\server\share`) paths without
platform-specific handling.

**Client-side adapters — `ssl_form_validators.ts`**
- `validateSslPathInput` — adapter for `useInput` (returns `string[] |
undefined`)
- `validateSslPathsCombo` — adapter for `useComboInput` (returns
`Array<{message, index}> | undefined`)

**Four form hooks wired**
- `use_download_source_flyout_form.tsx` — 3 inputs
- `use_output_form.tsx` + `output_form_validators.tsx` — 2 combo inputs
+ extended existing `validateSSLCertificate`/`validateSSLKey`
- `use_fleet_server_host_form.tsx` — 9 inputs across 3 SSL groups
(server, ES, agent)
- `use_fleet_proxy_form.tsx` — 3 inputs

**Four server-side handlers hardened**
- `download_source/handler.ts`, `fleet_server_hosts/handler.ts`,
`fleet_proxies/handler.ts`, `output/handler.ts` — each gains a
`throwIfSslPathInvalid` helper calling the shared common function,
returning `400 Bad Request` for invalid paths.

1. Navigate to Fleet → Settings → Agent binary sources → Add / Edit
source
2. In the TLS Certificate section, enter a path with spaces (e.g.
`/path/to my cert.pem`) in any certificate field
3. Confirm the form shows an error and cannot be saved
4. Confirm a valid path (e.g. `/path/to/cert.pem`) or inline PEM content
passes validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<img width="536" height="829" alt="image"
src="https://github.com/user-attachments/assets/5489927a-b71f-4625-9812-15bfea234f06"
/>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Mason Herron <46727170+Supplementing@users.noreply.github.com>
@botelastic botelastic Bot added the Team:Fleet Team label for Observability Data Collection Fleet team label May 1, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic juliaElastic added backport This PR is a backport of another PR release_note:skip Skip the PR/issue when compiling release notes release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels May 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 1, 2026

Approvability

Verdict: Needs human review

This PR adds input validation that will reject SSL certificate paths containing whitespace across multiple Fleet forms and API endpoints. This is a behavioral change affecting what inputs are accepted, and the author does not own any of the modified files.

You can customize Macroscope's approvability policy. Learn more.

@juliaElastic juliaElastic requested a review from Supplementing May 1, 2026 12:15
juliaElastic and others added 2 commits May 1, 2026 14:21
yaml_utils.ts does not exist on the 9.4 branch; remove the two
export lines that were incorrectly included during conflict resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

API Contract Breaking Changes — Terraform Provider Impact

cc @elastic/fleet

The following breaking change(s) affect APIs consumed by the Elastic Terraform Provider.

Endpoint Terraform Resource Reason Owners
/api/fleet/outputs GET elasticstack_fleet_output the response property 'items/items/anyOf[subschema #4: output_kafka]/compression_level' became optional for the status '200' @elastic/fleet
/api/fleet/outputs/{outputId} GET elasticstack_fleet_output the response property 'item/anyOf[subschema #4: output_kafka]/compression_level' became optional for the status '200' @elastic/fleet

What to do

  1. Fix the breaking change if it was unintentional.
  2. If intentional, add an approved entry to packages/kbn-api-contracts/allowlist.json and coordinate with @elastic/terraform-provider.

See the @kbn/api-contracts README for details on the allowlist schema and workflow.

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1811 1813 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 2.4MB 2.4MB +1.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 202.5KB 202.8KB +295.0B

History

@juliaElastic juliaElastic enabled auto-merge (squash) May 1, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants