fix(ra-rpc): sanitize the method name in the request span - #1407
Merged
Merged
Conversation
The prpc routes record the percent-decoded method segment as a span field, and the span prefixes every event of the request, so POST /prpc/Info%0A<text> still started a log line with <text> after Signed-off-by: Kevin Wang <wy721@qq.com> #1401. Record it through log_text, like the dispatch and error lines.
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.
Follow-up to #1401.
Problem
declare_prpc_routes!records the percent-decoded<method>route segment as themethodfield of the request span. The span prefixes every event logged while the request runs, soPOST /prpc/Info%0A<text>still puts a line starting with<text>into the service log:Fix
Record the field through
ra_rpc::log_text, the helper #1401 added for the dispatch and error lines, on both the POST and GET routes. No other caller-controlled span field exists on this path; Rocket's own request span logs the URI still percent-encoded.Verification
cargo test -p ra-rpc --all-features: 22 + 4 + 10 + 1 passedcargo clippy -p ra-rpc -- -D warnings,cargo fmt --all: clean;cargo check -p dstack-kms -p dstack-vmm -p dstack-guest-agent: oktc-gw-contract-001..003against a locally built gateway: invariant L7 (no log line begins with caller text after<Method>%0A<marker>) failed onnextwith 2 forged lines per probe, and passes with this change (0 forged lines, 0 violations across 45/45/626 calls).