Repository navigation
fix(ra-rpc): keep caller-supplied text from forging log lines - #1401
Merged
Merged
Conversation
kvinwang
added a commit
that referenced
this pull request
Sep 25, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
source-c
pushed a commit
to silicon-foundation/dstack
that referenced
this pull request
Oct 4, 2026
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> Dstack-TEE#1401. Record it through log_text, like the dispatch and error lines.
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 10, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 16, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.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.
Problem
The shared pRPC layer writes caller-controlled text into service logs verbatim:
dispatch_prpclogsdispatching request: {path}, wherepathis the<method>route segment. Rocket percent-decodes it, soPOST /prpc/Info%0A<forged line>puts a raw newline into the gateway's (or any service's) log. On the gateway that listener is public.rpc error:anderror handling prpc:log the error chain. fix(ra-rpc): bound the error text a failed call returns, and return it in the caller's representation #1234 bounded it to 2 KiB, but line breaks survive. On the VMM, aGuestApicall relays the guest agent's{"error": "..."}body (http-clientserver_error_message) as the VMM's own error. A tenant's guest can therefore write complete, well-formed lines into the host VMM log, which it does not trust.dstack_types::sanitize_for_logalready handles this case on the guest-to-host health-reporting path (gateway/src/proxy/health_check.rs). The RPC log sites did not use it.Fix
Add
ra_rpc::log_text:bound_error_textfollowed bysanitize_for_log, which blanks control characters, Unicode line/paragraph separators and bidi controls. The three log sites in ra-rpc use it. Reply bodies are unchanged: they are JSON- or protobuf-encoded, so callers still get the full bounded message.One visible effect: the multi-line
{err:?}"Caused by:" block is now logged on one line.Verification
logged_text_stays_on_one_linecovers\n,\r, U+2028 and ESC, and checks that bounding still applies.cargo test -p ra-rpc --all-features: all pass (22 + 4 + 10)cargo clippy -p ra-rpc --all-features -- -D warnings --allow unused_variables,cargo fmt --all -- --check: cleancargo check -p dstack-vmm -p dstack-gateway: ok