[CELEBORN-2317] Validate applicationId to prevent worker path traversal#3674
Open
afterincomparableyum wants to merge 1 commit intoapache:mainfrom
Open
[CELEBORN-2317] Validate applicationId to prevent worker path traversal#3674afterincomparableyum wants to merge 1 commit intoapache:mainfrom
afterincomparableyum wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
Author
|
I'll fix CI issues and push |
cbd03e9 to
1a54265
Compare
The worker builds local shuffle paths by concatenating applicationId received over RPC: `<workingDir>/<appId>/<shuffleId>/<fileName>`. The int32 and fileName is built from int id/epoch/mode, but it was never validated against a charset. With auth disabled, any client on the network could supply `appId = "../foo"` and have the worker mkdir, create, or delete files outside its working dir. With auth enabled, the SASL clientId == applicationId equality check in RpcEndpoint did not constrain format, so a tenant whose registered id contained `..` could still escape.
This change:
- Adds Utils.validateAppId enforcing `^[A-Za-z0-9_-]+$`, which matches
Spark (`application_<ts>_<n>`, `local-<ts>`), Flink, and MR formats.
- Calls it at every worker RPC entry point that takes an applicationId
or shuffleKey from the wire: Controller (ReserveSlots, CommitFiles,
DestroyWorkerSlots), PushDataHandler.handleCore, and the two
checkAuth sites in FetchHandler.
- Adds a canonical path containment check in
StorageManager.createDiskFile (local disk branch) as defense in
depth, before mkdirs() runs.
1a54265 to
6e65966
Compare
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.
What changes were proposed in this pull request?
This change:
^[A-Za-z0-9_-]+$, which matches Spark (application_<ts>_<n>,local-<ts>), Flink, and MR formats.Why are the changes needed?
The worker builds local shuffle paths by concatenating applicationId received over RPC:
<workingDir>/<appId>/<shuffleId>/<fileName>. The int32 and fileName is built from int id/epoch/mode, but it was never validated against a charset. With auth disabled, any client on the network could supplyappId = "../foo"and have the worker mkdir, create, or delete files outside its working dir. With auth enabled, the SASL clientId == applicationId equality check in RpcEndpoint did not constrain format, so a tenant whose registered id contained..could still escape.Does this PR resolve a correctness bug?
Yes
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit tests/CI