Skip to main content

Documentation Index

Fetch the complete documentation index at: https://qwady.wiki/llms.txt

Use this file to discover all available pages before exploring further.

Visibility is the foundation of defense-in-depth security. ThornGuard writes an asynchronous audit log for every significant action processed through the proxy. These logs are stored in a highly durable, globally distributed Cloudflare D1 (SQLite) database.

Database Schema

Every event is recorded in the audit_logs table with the following schema:
ColumnTypeDescription
idINTEGERInternal primary key (auto-incrementing).
log_idTEXTPublic-facing UUID identifier (crypto.randomUUID()). Used by the dashboard.
trace_idTEXTCorrelation ID shared with client-visible x-thornguard-trace-id headers.
timestampDATETIMEUTC timestamp (defaults to CURRENT_TIMESTAMP).
license_hashTEXTA SHA-256 hash of the authenticated ThornGuard license identity associated with the request.
target_urlTEXTThe upstream server requested (e.g., api.githubcopilot.com).
rpc_methodTEXTThe specific MCP tool being called (e.g., get_issue).
actionTEXTThe categorization of the event (see Action Types below).
detailsTEXTExtended context, errors, or reasons for blocking.
details_jsonTEXTStructured JSON metadata for richer event context.
policy_rule_idTEXTThe matched policy rule identifier when a policy event is involved.
response_time_msINTEGERTime in milliseconds from request receipt to response completion.
client_ipTEXTClient IP address (captured from CF-Connecting-IP header).
The id field is the internal auto-incrementing primary key. The log_id UUID is the public-facing identifier used by the dashboard and API. Older rows may not have a log_id — the dashboard falls back to id in those cases.
ThornGuard sanitizes sensitive values such as auth headers, ThornGuard tokens, upstream bearer tokens, and token-like query params before they are persisted in ThornGuard-controlled audit records or fanned out to webhook deliveries.

Action Types

Every audit log entry is classified with one of the following action values:
ActionDescription
PROXY_SUCCESSRequest was successfully scrubbed and proxied to upstream.
SSE_STREAM_ESTABLISHEDAn SSE stream was successfully opened to the client.
BLOCKED_MALICIOUSDestructive command intercepted (e.g., rm -rf, sudo).
BLOCKED_AUTHAuthentication failure — license invalid, missing, or expired.
BLOCKED_INSECURE_TARGETTarget URL was rejected because it was not HTTPS.
BLOCKED_ORIGINRequest origin was rejected by the configured allowlist.
BLOCKED_SSRFSSRF attempt blocked — target URL or resolved DNS address was restricted.
BLOCKED_RATE_LIMITRequest dropped because the per-license rate limit was exceeded.
BLOCKED_IP_WHITELISTClient IP was not in the enterprise IP whitelist.
BLOCKED_CUSTOM_DOMAINTarget domain matched a per-license custom blocklist entry.
BLOCKED_CUSTOM_COMMANDCommand pattern matched a per-license custom command blocklist.
BLOCKED_POLICYA structured tenant policy rule blocked the request.
POLICY_AUDITA structured tenant policy rule matched in audit mode.
BLOCKED_APPROVALA tool call was halted pending explicit approval.
PII_REDACTEDPII or secrets were detected and scrubbed from request or response. Details include the types found (e.g., EMAIL, AWS_KEY).
CUSTOM_REDACTION_AUDITA custom enterprise redaction rule matched in audit mode.
UPSTREAM_ERRORThe upstream MCP server returned an error (timeout, non-JSON response, etc.).
TOOL_POISONING_DETECTEDPrompt injection, recommendation poisoning, or hidden characters detected in a tool definition or response.
TOOL_SCHEMA_DRIFTA tool’s input or output schema changed from its TOFU-pinned baseline.
TOOL_COLLISION_DETECTEDDuplicate tool names detected from the same upstream server.
ANOMALY_DETECTEDBehavioral anomaly flagged by EWMA, drift detection, or Markov sequence analysis.
RESPONSE_PROCESSING_ERRORFailed to process or parse upstream response content.
APPROVAL_ERRORApproval system temporarily unavailable (DO failure or missing config).
AUDIT_PURGELogs were purged via a GDPR deletion request.
The dashboard summary cards are action-count summaries for the selected time range. The Risk Signals card intentionally includes blocked events plus redaction, audit, tool-integrity, anomaly, and upstream-error actions that operators usually want to review together.

Querying Logs

Correlation Headers

Successful proxied responses and ThornGuard-generated error responses include:
  • x-thornguard-log-id
  • x-thornguard-trace-id
These values map directly to audit_logs.log_id and audit_logs.trace_id, making it easy to correlate user-visible failures with backend logs and webhook deliveries.

Via the Dashboard

The ThornGuard Dashboard provides a graphical interface for browsing audit logs with filtering by action type, date range, and search — plus 10-second auto-polling for real-time updates. See Dashboard for details.

Via the Wrangler CLI

You can also query logs directly using the Wrangler CLI. View the 10 most recent events:
npx wrangler d1 execute thornguard-audit --remote \
  --command="SELECT log_id, timestamp, action, rpc_method, client_ip, details FROM audit_logs ORDER BY id DESC LIMIT 10;"
View all blocked malicious attempts:
npx wrangler d1 execute thornguard-audit --remote \
  --command="SELECT log_id, timestamp, target_url, details FROM audit_logs WHERE action = 'BLOCKED_MALICIOUS' ORDER BY id DESC;"
View PII redaction events:
npx wrangler d1 execute thornguard-audit --remote \
  --command="SELECT log_id, timestamp, rpc_method, details FROM audit_logs WHERE action = 'PII_REDACTED' ORDER BY id DESC LIMIT 20;"

Log Retention

ThornGuard supports configurable log retention periods per license tier.
  • Default retention: 90 days (Individual), 365 days (Enterprise).
  • Cleanup schedule: A daily cron job runs at 3:00 AM UTC to delete expired logs.
  • Custom retention: Current dashboard controls allow retention changes within your allowed tier limits.

Data Export

Audit logs can be exported from the dashboard Settings page or via the API in multiple formats:
FormatDescriptionUse Case
CSVRFC 4180 comma-separated valuesSpreadsheets, general analysis
JSONStandard JSON arrayProgrammatic access, custom tooling
NDJSONNewline-delimited JSON (one event per line)Streaming ingest, log aggregators
OCSFOpen Cybersecurity Schema Framework 1.3.0SIEM platforms (Splunk, Elastic, etc.)
CEFCommon Event Format (pipe-delimited)Syslog-compatible SIEM ingest
LEEFLog Event Extended FormatHP ArcSight and similar platforms
All formats export up to 10,000 rows for the selected retention period. Outbound integrations: Security-relevant audit events can also be forwarded asynchronously via the integration queue (for example, dashboard-managed webhooks and API-configured sinks). Support levels and sink types are described in Policies & Webhooks.

Compliance Summary

The dashboard Settings page includes a Compliance Report button that generates a JSON summary of your audit posture:
  • Total events and breakdown by action type
  • High-signal event count (blocked requests, redacted data, tool poisoning, anomalies)
  • GDPR purge record count
  • Audit signing status
  • Data retention setting and license tier
  • Report generation timestamp
This summary is useful for internal compliance reviews, SOC 2 evidence collection, and vendor security questionnaires. It is also available via GET /api/compliance/summary.

GDPR Compliance

ThornGuard supports right-to-deletion requests through a one-click audit log purge:
  • Accessible from the dashboard Settings page under Danger Zone.
  • Purging deletes all audit logs associated with your license.
  • A final AUDIT_PURGE action is logged to maintain a record of the deletion event itself.
Purging audit logs is irreversible. All historical data for your license will be permanently deleted.