fix(audit-2026-06-11/F-SE-H-04): scrub runtime error detail from public data-plane responses
ExecError::Runtime strings (filesystem paths, "blocked by SSRF policy: link-local" cloud-metadata reconnaissance, pool-exhaustion timing, panic fragments, and attacker-thrown strings) were returned verbatim in the public /api/v1/execute + user-route 502 bodies. This handler only serves anonymous data-plane callers (the authenticated script-test path is in manager-core and keeps verbose errors), so log the full text server-side under a correlation id and return a stable generic message plus the id for operator grep. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -750,7 +750,31 @@ impl IntoResponse for ApiError {
|
||||
ExecError::OperationBudgetExceeded => {
|
||||
(StatusCode::INSUFFICIENT_STORAGE, e.to_string())
|
||||
}
|
||||
ExecError::Runtime(_) => (StatusCode::BAD_GATEWAY, e.to_string()),
|
||||
ExecError::Runtime(detail) => {
|
||||
// Audit 2026-06-11 (F-SE-H-04) — runtime / SDK error
|
||||
// strings leak internal detail to the public data
|
||||
// plane: filesystem paths, "blocked by SSRF policy:
|
||||
// link-local" (confirms cloud-metadata reachability),
|
||||
// pool-exhaustion timing, and panic/backtrace
|
||||
// fragments. They also reflect attacker-thrown
|
||||
// strings (`throw "..."`) back into operator-facing
|
||||
// JSON. This handler only ever serves anonymous
|
||||
// data-plane callers (execute-by-id + user routes;
|
||||
// the authenticated script-test path lives in
|
||||
// manager-core and keeps verbose errors), so log the
|
||||
// full text server-side under a correlation id and
|
||||
// return only a stable generic message + the id.
|
||||
let correlation_id = Uuid::new_v4();
|
||||
tracing::warn!(
|
||||
%correlation_id,
|
||||
detail = %detail,
|
||||
"script runtime error (detail scrubbed from response)"
|
||||
);
|
||||
(
|
||||
StatusCode::BAD_GATEWAY,
|
||||
format!("script execution error (ref: {correlation_id})"),
|
||||
)
|
||||
}
|
||||
ExecError::Overloaded { .. } => unreachable!("handled above"),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user