Skip to main content
User guide

API security

API discovery, risk items, OpenAPI validation, GraphQL policy, sensitive data and cross-border data flows, broken authorisation detection, plus API authentication, gRPC, WebSocket and LLM / MCP endpoint protection.

In the Business and API security group, API security (API 安全), API authentication (API 认证), gRPC protection (gRPC 防护), WebSocket protection (WebSocket 防护) and LLM / MCP protection (大模型 / MCP 防护) protect your sites' endpoints. API security needs View security events; the other pages need View protection policy. All changes need Modify protection policy.

API security

The API security page has nine tabs: API assets, risk items, API specifications, API policy, sensitive data, sensitive data view, cross-border data, broken authorisation detection and asset risk.

API assets

Endpoints are discovered passively. Once a site has API traffic with 2xx, 3xx or 401 responses, the endpoints appear within about a minute, up to 5000 per site and 50000 in total.

The page counts total endpoints, newly discovered, active in 24 hours, shadow APIs, zombie APIs, endpoints handling sensitive data and high-risk endpoints. Views are all endpoints, shadow APIs, zombie APIs, inactive, at risk, sensitive and reachable without authentication. New endpoints can be confirmed, ignored or returned to pending.

Risk items

Endpoint risks are calculated in the background: unauthenticated sensitive endpoints, credentials in URLs, plain-text transport, permissive CORS, unbounded pagination, excessive data exposure, weak authentication, error message leaks, deprecated but reachable, admin endpoints exposed to the internet, GraphQL introspection, GraphQL field suggestions, unbounded GraphQL and mass assignment. Filter by severity and state; Apply (套用) opens the matching configuration with values pre-filled.

API specifications

Upload OpenAPI 3.x or Swagger 2.0 (YAML or JSON, up to 4 MiB). Swagger 2.0 is converted to OpenAPI 3.

  1. Select Upload specification (上传规范).
  2. Run the pre-audit (预审计) first. It scores the specification against OWASP API rules and shows the grade, score and issues without storing anything.
  3. Select Confirm upload (确认上传).
  4. In the version list, choose Set active (设为生效) and pick a mode: Observe (violations logged only) or Enforce (violations blocked according to the site mode).

You can also Generate from traffic (从流量生成), which builds a specification from the last 30 days of traffic and never activates it automatically. Each site keeps up to 50 versions, which can be compared.

Specifications uploaded in the console are stored on the control plane, and the active version reaches every node through configuration snapshots. Older-style specification files placed in the deployment directory data/apis/ are not part of snapshots and must be copied to each node.

Without an active specification, discovery and response sensitive-data detection still run, but they only log and do not mask.

API policy

  • GraphQL policy: endpoint paths, maximum depth, aliases, batch size and complexity (0 means unlimited), whether to forbid introspection (recommended in production), and log only or block when a limit is exceeded.
  • Response validation and mass assignment: needs an active specification. Response validation can be off, observe or block, and checks the first 1 MiB of the response body. Mass assignment detection looks at privileged properties only (recommended) or any undeclared property.

Sensitive data

Set sensitive data detection (DLP) globally or per site. Data is classified in five levels: L1 general data, L2 personal information, L3 sensitive personal information, L4 authentication data and keys, L5 important data. Each type can be logged, masked or blocked.

Built-in types include Chinese ID card numbers, mobile numbers, bank card numbers, email addresses, passport numbers, Hong Kong, Macao and Taiwan travel permits, military officer ID numbers, unified social credit codes, licence plates, internal IPs, addresses, names, bank account numbers, IBANs, social security and medical insurance numbers, cloud access keys, private keys, JWTs, code hosting tokens, third-party API tokens, database connection strings, bot webhooks, echoed passwords and biometric data. Custom rules support RE2 regular expressions, keywords, field names and context words, with Luhn, ID card check digit or unified social credit code validation.

You can also turn on request-side detection, and bulk data theft and unusual exfiltration detection, which counts sensitive records returned per IP, token or account over a period and acts above a threshold or baseline. Test checks samples against the unsaved settings before you save.

Sensitive data view and cross-border data

Sensitive data view shows distribution and trends by type, level and site, lists sensitive endpoints, and lets you turn masking on or off per endpoint. Cross-border data counts sensitive records flowing abroad using offline GeoIP. You can choose which countries or regions count as domestic; Hong Kong, Macao and Taiwan count as abroad by default.

Broken authorisation detection

Detects broken object-level authorisation (BOLA) and function-level authorisation: object enumeration, access to other users' objects, objects accessed by many identities, distributed enumeration, unauthorised calls to admin endpoints and response owner mismatches. It needs a Professional or higher licence, or the add-on.

Select Settings (设置) for a site in the table:

  • Identity sources: JWT claim, session cookie, API key header or identity gateway, with an optional JWT verification key.
  • Privileged identities: recognise administrators by a JWT field value or gateway user group.
  • Routes: route templates such as GET /api/users/{id} block owner=owner_id, up to 200.
  • Thresholds: distinct objects (default 50), window (default 300 seconds), action duration (default 600 seconds), rate limit (default 30 per minute).
  • Allow list: identities or objects, up to 200.

The default action is observe only. Each route shows learning progress and confidence. Once the conditions are met (by default 72 hours observed, at least 10 identities, at least 50 objects with a learned owner, over 90% of requests carrying credentials and a confidence of 80 or more), it shows that blocking can be turned on. Enable blocking (开启拦截) first shows a simulation over the past 7 days.

Asset risk summarises each endpoint's risk, authentication, sensitive data and authorisation signals.

API authentication

Validates JWTs, API keys and client certificates at the WAF. Validated identities can be used for per-identity rate limits and broken authorisation detection.

  • Site policy: require credentials (JWT, API key or client certificate, any one of them) by path prefix, excluded paths and method, and block or log when they are missing. Client certificates (mTLS) can be required site-wide (rejected during the handshake) or per path by rule; this needs an HTTPS port and supports OCSP and CRLs.
  • JWT providers: issuer (iss, aud), public-key signatures (RS, PS, ES, EdDSA) or shared secrets (HS256 to HS512), key source (JWKS URL, local JWKS or PEM public key), clock skew and required claims. In offline deployments a JWKS URL must be internal; otherwise use a local JWKS or PEM key.
  • API keys: when issuing, set the site, expiry date, path prefixes, methods, IP allow list and quota. The key is shown once and only its hash is stored. After rotation the old key stays valid for 24 hours.
  • Client CA: upload a CA and an optional CRL.
  • Usage (用量): call volumes per credential.

gRPC protection

Decodes gRPC messages by proto and passes string fields to the semantic engine.

  • Site policy: action for unknown methods (block, log only or nothing), allow only listed methods, message size limit (default 4 MiB) and h2c to the upstream.
  • Method policies: up to 500, keyed by package.Service/Method, with options to forbid the call, inspect fields, require a JWT, set a message limit, rate-limit and apply field rules (required, maximum length, regex, value range, allowed values).
  • Proto versions: upload .proto files or a FileDescriptorSet (.pb, .binpb), up to 50 versions. Without a proto, messages can be decoded blind.

WebSocket protection

  • Handshake checks: Origin validation (on by default), optionally requiring an Origin header, and limits on subprotocols and extensions (only permessage-deflate by default).
  • Message inspection: log only by default, or block (closing the connection with code 1008), configurable per path. Binary messages and GraphQL over WebSocket are inspected.
  • Limits: maximum message size (default 1 MiB), messages per connection (100 per second by default, burst 200), connection duration and concurrent connections per IP.

LLM / MCP protection

Protects LLM endpoints and MCP servers on your sites.

  • Endpoint declarations: one path and type per line: openai_chat, openai_responses, anthropic, gemini, generic or mcp. The page suggests likely endpoints found in API assets.
  • Prompt injection and jailbreaks: offline rules plus heuristic scoring, with sensitivity lenient (from 80), balanced (from 60) or strict (from 40), and custom injection phrases.
  • Sensitive data and topics: detects sensitive data and forbidden topics in prompts, and can log, mask or block.
  • Limits and rate limits: request body limit, prompt token limit, max_tokens limit, requests and token budget per period.
  • Response inspection: streams are inspected event by event for sensitive output, and canary markers detect system prompt leaks.
  • MCP: allowed and forbidden tools, resource URIs, prompt templates and JSON-RPC methods; path traversal and SSRF checks on arguments; logging of tool description poisoning and definition changes; Origin validation; and optionally required authentication (the site must have API authentication turned on).

Start with Log only (仅记录) to observe without blocking or masking.

On this page