Archived
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.
This commit is contained in:
1 parent
1b4e405969
commit
51e4c7f0f0
1 file changed
+3
-3
@@ -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 */
|
||||
|
||||
Reference in new issue
Block a user