Please do not report security vulnerabilities through public GitHub issues.
Report privately through GitHub's Private Vulnerability Reporting (the "Report a vulnerability" button in the repository's Security tab), or contact the maintainers directly. We aim to respond within 48 hours. Please include:
- A description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fixes (optional)
- The API key is sent in the
X-Goog-Api-Keyrequest header, never in the URL, so it doesn't end up in URLs or proxy access logs. ClientandClientBuilderredact the key inDebugoutput (api_key: "[REDACTED]").- The built-in wire inspectors redact secrets.
LoudWirePrinter(whatLOUD_WIRE=1installs) andTracingForwarderredact secret fields, for example third-party retrievalapi_keys in tool configs, and truncate base64 payloads. A customWireInspectorreceives the raw events, so it owns what it writes out (see docs/LOGGING_STRATEGY.md). - Request and response bodies are logged only at
debug. They include prompts, base64 media and function arguments, so treat debug logs as sensitive. GenaiError::Api.messageis a truncated copy of the error response body. It doesn't contain your key, but it may echo parts of your request.
- All API traffic uses HTTPS.
- TLS is provided by
rustls(reqwest'srustlsfeature), verifying against the OS trust store. Minimal containers need a CA bundle installed.
Load the key from the environment or a secrets manager; never hardcode it:
use genai_rs::Client;
let api_key = std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY must be set");
let client = Client::new(api_key);
# let _ = client;When logging errors, the status code and request_id are always safe. Treat
message as containing request data:
use genai_rs::GenaiError;
use std::error::Error;
fn log_error(err: &GenaiError) {
match err {
GenaiError::Api { status_code, request_id, .. } => {
eprintln!("API error {status_code} (request_id={request_id:?})");
}
// `Display` is the top error alone: print each `source()` too
// (`Http`'s transport error is one).
other => {
let mut text = other.to_string();
let mut cause = other.source();
while let Some(e) = cause {
text = format!("{text}: {e}");
cause = e.source();
}
eprintln!("error: {text}");
}
}
}
# let _ = log_error;Validate function arguments. Arguments to your #[tool] and
CallableFunction implementations come from the model. The library passes
them through unchanged. Bound their size, and never pass them unchecked to a
shell, SQL or the filesystem.
Treat model output as untrusted input wherever you render or execute it.
cargo auditruns in theSecurity Auditworkflow (audit.yml) whenCargo.tomlorCargo.lockchanges, and weekly. A failing scheduled run opens a tracking issue.clippywith-D warningsruns on every pull request.