From 51e4c7f0f0c63fc5b6276276c4dc53bca8a9e3ca Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Sun, 15 Nov 2026 17:21:05 +0000 Subject: [PATCH] server: what a client put in a request never reaches the log raw log_admitted printed the request's model name and last user text through %s, unsanitized -- the one entry point that skipped the log_sanitize every other request-side field passes through. Both come straight from a client's JSON; control characters in a model field or the tail of a message let a client forge log lines, inject terminal escapes, or make the log read as if the operator said something the server never saw. The two strings now pass through log_sanitize at the print, exactly as the peer address already does, so the admission line carries the same guarantee the rest of the log does. --- core/server/server.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/server/server.cpp b/core/server/server.cpp index 0d8c7c9f..7157a0c6 100644 --- a/core/server/server.cpp +++ b/core/server/server.cpp @@ -458,15 +458,15 @@ void Server::log_admitted(const OaiRequest& r) const { if (r.endpoint == Endpoint::Chat) RAD_INFO("req %s %s%s%s model=%s msgs=%d tools=%d prompt=%lld tok n=%d max_tokens=%lld", r.id.c_str(), kind, r.stream ? " stream" : "", from_peer(r.peer).c_str(), - r.model.c_str(), r.n_messages, r.n_tools, (long long)n_prompt, r.n, + log_sanitize(r.model).c_str(), r.n_messages, r.n_tools, (long long)n_prompt, r.n, (long long)r.max_tokens); else RAD_INFO("req %s %s%s%s model=%s prompts=%zu prompt=%lld tok n=%d max_tokens=%lld", r.id.c_str(), kind, r.stream ? " stream" : "", from_peer(r.peer).c_str(), - r.model.c_str(), r.prompts.size(), (long long)n_prompt, r.n, + log_sanitize(r.model).c_str(), r.prompts.size(), (long long)n_prompt, r.n, (long long)r.max_tokens); if (!r.last_user.empty()) - RAD_DEBUG("req %s last user: %s", r.id.c_str(), r.last_user.c_str()); + RAD_DEBUG("req %s last user: %s", r.id.c_str(), log_sanitize(r.last_user).c_str()); } /* ------------------------------------------------------------------ submission */