Skip to content

fix(ra-rpc): sanitize the method name in the request span - #1407

Merged
kvinwang merged 1 commit into
nextfrom
fix/ra-rpc-method-log-forging
Sep 26, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/ra-rpc-method-log-forging

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Follow-up to #1401.

Problem

declare_prpc_routes! records the percent-decoded <method> route segment as the method field of the request span. The span prefixes every event logged while the request runs, so POST /prpc/Info%0A<text> still puts a line starting with <text> into the service log:

...prpc_post{id=45 method=AcmeInfo
DSTACK-FORGED-LOG-LINE-4c2e9b INFO forged}: ra_rpc: dispatching request: AcmeInfo DSTACK-FORGED-LOG-LINE-4c2e9b INFO forged

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 passed
  • cargo clippy -p ra-rpc -- -D warnings, cargo fmt --all: clean; cargo check -p dstack-kms -p dstack-vmm -p dstack-guest-agent: ok
  • Acceptance suite (PR test: add colocated core component acceptance suite #841) request-contract cases tc-gw-contract-001..003 against a locally built gateway: invariant L7 (no log line begins with caller text after <Method>%0A<marker>) failed on next with 2 forged lines per probe, and passes with this change (0 forged lines, 0 violations across 45/45/626 calls).

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.
@kvinwang
kvinwang merged commit daefa32 into next Sep 26, 2026
11 checks passed
@kvinwang
kvinwang deleted the fix/ra-rpc-method-log-forging branch September 26, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant