SecurityForensics

Audit Logging

Tamper-evident hash-chained and HMAC-SHA256 signed audit logs in taicket_mcp, append-only runtime APIs, MongoDB least-privilege roles, and secret redaction.

Tamper-evident hash chaining and HMAC-SHA256 signing

Every MCP tool call, authorization denial, scope failure, approval decision, and configuration mutation appends a structured record to taicket_mcp.mcp_audit_logs. Each entry links cryptographically to its predecessor via prevHash -> entryHash and carries an HMAC-SHA256 signature computed with MCP_AUDIT_SIGNING_KEY.

  • Hash chain continuity:: entryHash is the SHA-256 digest of the canonicalized record fields concatenated with prevHash (with the genesis record anchored to a 64-zero hex seed). Editing or deleting any historical entry invalidates every subsequent entryHash.
  • Keyed authenticity:: hmacSignature is computed as HMAC-SHA256(MCP_AUDIT_SIGNING_KEY, entryHash). Even an attacker who obtains write access to MongoDB cannot forge or rewrite the chain without possessing the server signing key.
  • Privacy-preserving IP attribution:: Raw client IP addresses are hashed with a keyed SHA-256 digest into ipHash before writing, allowing abuse correlation without retaining cleartext residential IPs.
Sample McpAuditLog record in taicket_mcpjson
{
  "sequence": 4812,
  "userId": "555652788592443392",
  "guildId": "123456789012345678",
  "clientId": "dcr_claude_desktop_01",
  "clientName": "Claude Desktop",
  "authKind": "oauth",
  "toolName": "configure_automod",
  "module": "automod",
  "action": "apply",
  "outcome": "allowed",
  "errorCode": null,
  "changesSummary": "Updated spam threshold to 6 messages/5s and synced 2 whitelist roles.",
  "ipHash": "4a1e8f9c7b2d5e0a3c6f1b8d4e9a2c5f7b0d3e6a9c1f4b7d2e5a8c0f3b6d9e1a",
  "prevHash": "7f3b91a0e5c2d8416b9e0f4a2c7d1e8b3a5f9c2d6e0b4a8f1c3d7e9b2a4f6c8d",
  "entryHash": "2c9d4e7f1a8b5c3e0d6f9a2b4c8e1d7f5a3b9c6e2d0f4a8b1c7e3d5f9a2b6c4e",
  "hmacSignature": "e1b4c7a9d2f5e8b1c4a7d0f3e6b9c2a5d8f1e4b7c0a3d6f9e2b5c8a1d4f7e0b3",
  "timestamp": "2026-06-15T14:22:08.412Z"
}

Append-only API and MongoDB least-privilege role

mcp/src/security/audit.ts exposes only appendAuditLog and read-only query helpers (listAuditLogsForUser and listRecentGuildAuditLogs). The module exports zero update, patch, or delete functions.

For production defense-in-depth, operators should restrict the MongoDB user referenced in MCP_MONGODB_URI so that mcp_audit_logs permits insert and find operations only, denying update and remove at the database engine level.

MongoDB custom role restricting mcp_audit_logs to append-onlyjavascript
db.getSiblingDB("taicket_mcp").createRole({
  role: "taicketMcpRuntime",
  privileges: [
    {
      resource: { db: "taicket_mcp", collection: "mcp_audit_logs" },
      actions: ["insert", "find"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_oauth_clients" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_oauth_transactions" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_oauth_codes" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_oauth_grants" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_access_tokens" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_refresh_tokens" },
      actions: ["find", "insert", "update", "remove"]
    },
    {
      resource: { db: "taicket_mcp", collection: "mcp_setup_previews" },
      actions: ["find", "insert", "update", "remove"]
    }
  ],
  roles: []
});

Zero secret logging and redaction pipeline

Both mcp/src/security/audit.ts and the Pino application logger pass objects through a strict key-redaction filter before writing. Fields matching authorization, token, accessToken, refreshToken, secret, password, cookie, confirmationToken, codeVerifier, or key are replaced with [REDACTED]. Raw Discord bearer tokens, MCP PATs, and MongoDB connection strings never appear in audit records or stdout logs.

Verifying audit chain integrity

Security auditors can verify an exported slice of mcp_audit_logs offline by recalculating each entryHash and checking its HMAC-SHA256 signature against MCP_AUDIT_SIGNING_KEY.

Offline HMAC-SHA256 verification for an audit log sequencepython
import hmac
import hashlib

def verify_audit_signature(entry_hash: str, expected_hmac: str, signing_key: str) -> bool:
    computed = hmac.new(
        signing_key.encode("utf-8"),
        entry_hash.encode("utf-8"),
        hashlib.sha256,
    ).hexdigest()
    return hmac.compare_digest(computed, expected_hmac)

Server managers can also inspect their own recent MCP actions directly inside the /account portal or by calling get_setup_status for an authorized server.

Related documentation