fix(connectors): validate connector key before it becomes a path - #4083
Merged
Conversation
The control API took the `{key}` path segment as-is and the local
config provider spliced it into the config filename under
`config_dir`. Nothing rejected `..`, separators, or control
characters; only the literal `sink_`/`source_` prefix and the absence
of any subdirectory under `config_dir` kept a traversal from landing,
and a refactor of either would have removed that by accident.
Parse the segment into a `ConnectorKey` at the API boundary: at most
128 bytes of ASCII letters, digits, `-`, `_` and `.`, starting with a
letter or digit so `.`, `..` and hidden-file names are impossible
outright. The rejection goes through `ApiError` so it carries the same
`{code, reason}` envelope as every other error, and the two `create_*`
provider methods take the parsed type so the write site cannot be
reached with a raw string.
Keys loaded from configuration files or the HTTP provider are not
rejected, since that would stop existing deployments from starting;
the runtime warns at startup about any key the API cannot address
instead.
Closes apache#4058
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4083 +/- ##
=============================================
- Coverage 85.90% 57.43% -28.47%
+ Complexity 1431 1402 -29
=============================================
Files 1244 1241 -3
Lines 192435 157081 -35354
Branches 158133 123387 -34746
=============================================
- Hits 165307 90225 -75082
- Misses 23037 62914 +39877
+ Partials 4091 3942 -149
🚀 New features to boost your workflow:
|
Member
Author
|
/request-review @hubcio |
hubcio
approved these changes
Sep 7, 2026
hubcio
approved these changes
Sep 7, 2026
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.
Which issue does this PR address?
Closes #4058
Rationale
The
{key}path parameter of the connectors control API reached a filesystem path unvalidated; the issue explains why the missing exploit is an accident of the filename prefix.What changed?
POST /{sinks,sources}/{key}/configsspliced the{key}segment straight intoconfig_dir/{sink,source}_{key}_{version}.toml; only the literalsink_/source_prefix kept..from escaping.Every
{key}route now parses the segment into aConnectorKey(at most 128 bytes of[A-Za-z0-9._-], leading alphanumeric so.,..and hidden names are impossible) through a small extractor that answers with the API's usual400 {"code": "invalid_connector_key"}body, and the providercreate_*methods take the parsed type so the write site cannot see a raw string. Keys loaded from TOML or the HTTP provider are not rejected, since that would stop running deployments; the runtime warns at startup about any key it cannot address.Local Execution
cargo clippy --all-targets -- -D warningsoniggy-connectorsandintegration,cargo test -p iggy-connectors,cargo test -p integration -- connectors::api:: connectors::runtime::error_isolation::source_with_invalid_state, markdownlint, typospreknot installed on this machine); the checks above were run by handAI Usage