Repository navigation
fix(core): validate module ids when they are deserialized - #117
Merged
Merged
Conversation
ModuleId derived Deserialize with serde(transparent), so an id read from a deploy body, a signed manifest or a stored record skipped ModuleId::parse. The id is a path segment of the filesystem store and of the worker/OCI control socket, whose directory the OCI runtime bind-mounts, so an unchecked id could escape those roots. - Deserialize ModuleId through parse (try_from = "String") - Check again that the id stays one path segment where the store directory and the control socket path are built - Answer a deploy JSON body serde refuses with the documented 400 INVALID_ARGUMENT problem, as the manifest route already does - Regression tests for deserialization, the deploy routes and the filesystem store Closes #116 Tags: #security #core #web #store Co-Authored-By: htjulia <htjulia1@gmail.com>
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.
Summary
ModuleIdderivedDeserializewith#[serde(transparent)], so ids read from the deploy envelope, a signed manifest'sidor a stored record skippedModuleId::parse. The id is a path segment of the filesystem module store and of the worker/OCI control socket (whose directory the OCI runtime bind-mounts), so an unchecked id could escape those roots.protrus-core:ModuleIdnow deserializes throughparse(#[serde(into = "String", try_from = "String")]). The serialized form is unchanged.protrus-store-fs:module_dirchecks the id is a single path segment undermodules/(defence in depth; newFsStoreError::UnsafeModuleId).protrus-host: both control-socket paths are built by one helper,worker_control_socket, which applies the same check.protrus-web: a newDeployBodyextractor forPOST /platform/modulesandPUT /platform/modules/{id}. A JSON body serde refuses, including a badrecord.module_id, now gets the documented 400INVALID_ARGUMENTproblem (design 24, "bad deploy envelope"; Java mapsIllegalArgumentExceptionthe same way inProteanAdminErrorAdvice). Before, it got axum's plain-text 422. A missing or wrong content type still gets axum's own rejection. The manifest route and the MCP deploy tools already reported serde failures, and now reject bad ids too.docs/design/24: non-parity row added. Java stores the descriptor id as given, while Rust validates it.Shared-lib names, scope names,
usesentries and bundle file paths were checked and are already validated before they reach a path.Closes #116
Verification
cargo test --workspace: 38 suites, 408 passed, 0 failed, 6 ignoredmodule_id_deserializes_only_through_parse(core),a_manifest_id_that_is_not_a_module_id_does_not_deserialize(artifact),a_record_cannot_carry_a_module_id_that_escapes_the_store(store-fs),deploy_rejects_a_body_module_id_that_is_not_a_path_segment(web: POST, PUT and from-manifest)