@@ -7,18 +7,23 @@ import type { ElasticsearchBaseParams } from '@/tools/elasticsearch/types'
77const DEFAULT_CLOUD_PORT = '443'
88
99/**
10- * Characters that must not appear in a decoded Cloud ID component. An `@` would
11- * turn the rest of the authority into a host and send the credential headers to
12- * an attacker-controlled origin; `#`, `?` and `/` truncate the authority.
13- * Mirrors the `strings.IndexAny(component, "#@?/")` reject set in Beats, plus
14- * `\`, which the WHATWG URL parser treats as a path separator for special
15- * schemes and which therefore truncates the authority exactly as `/` does.
10+ * Characters that must not appear in a decoded Cloud ID component name. An `@`
11+ * would turn the rest of the authority into a host and send the credential
12+ * headers to an attacker-controlled origin; `#`, `?` and `/` truncate the
13+ * authority. Mirrors the `strings.IndexAny(component, "#@?/")` reject set in
14+ * Beats, plus two additions:
1615 *
17- * A `:` is deliberately absent — `extractPortFromName` has already split each
18- * component at its last colon, so a surviving colon means a second one, which
19- * the all-digits port check below rejects.
16+ * - `\`, which the WHATWG URL parser treats as a path separator for special
17+ * schemes and which therefore truncates the authority exactly as `/` does.
18+ * - `:`, because `extractPortFromName` has already split the component at its
19+ * last colon, so a colon surviving in the *name* half means the component
20+ * carried two. The all-digits port check below does not catch that when the
21+ * trailing half is numeric: `found.io:9243:5` yields name `found.io:9243`
22+ * and port `5`, which assembles `https://<uuid>.found.io:9243:5` and fails
23+ * as a bare `TypeError: Invalid URL` inside the transport. A hostname cannot
24+ * contain a colon, so rejecting it here cannot refuse a legitimate ID.
2025 */
21- const CLOUD_ID_REJECTED_CHARACTERS = / [ # @ ? / \\ ] /
26+ const CLOUD_ID_REJECTED_CHARACTERS = / [ # @ ? / \\ : ] /
2227
2328/**
2429 * Splits a Cloud ID component of the form `name:port` at its last colon.
0 commit comments