JSON-RPC vs XML-RPC: Protocol & Security Differences Comparison Guide
JSON-RPC vs XML-RPC: Security Comparison Guide
API Protocol Security

JSON-RPC vs XML-RPC: Protocol & Security Differences Comparison Guide

JSON-RPC 2.0 and XML-RPC both expose remote procedures, but they use different envelopes and ecosystem assumptions. JSON-RPC is transport-agnostic and uses JSON request/response objects; XML-RPC is an older HTTP-POST protocol with XML bodies.

Guide overviewProtocol Comparison
JSON-RPCJSON + transport agnostic
XML-RPCXML over HTTP POST
Built-in authNeither
Main riskMethod auth + parser safety
Quick answer: JSON-RPC is generally more compact and flexible, supports named/positional params, notifications and batch requests, and can run over different transports. XML-RPC uses an XML methodCall/methodResponse envelope over HTTP POST. Neither protocol defines authentication or authorization by itself. JSON-RPC needs strict method/parameter authorization and safe JSON parsing; XML-RPC additionally requires hardened XML parsing to prevent XXE/entity-expansion risks.

JSON-RPC vs XML-RPC at a Glance

AreaJSON-RPC 2.0XML-RPC
EnvelopeJSON object/arrayXML methodCall/methodResponse
TransportTransport agnosticHTTP POST
ParametersBy-position array or by-name objectOrdered XML values
NotificationsYes; request without idNo equivalent core model
BatchingDefined in JSON-RPC 2.0Not core XML-RPC
SecurityApplication/transport responsibilityApplication/HTTP responsibility + XML parser hardening

The security decision is not 'JSON safe, XML unsafe.' Both can expose privileged methods, broken authorization, oversized payloads and resource-exhaustion risks.

How JSON-RPC 2.0 Works

A JSON-RPC request contains jsonrpc: "2.0", a method, optional params and an optional ID. If the ID is absent, it is a notification and the server must not send a response. Responses carry either result or error plus the ID.

Batch requests can contain multiple logical operations in one payload and may be processed concurrently. Limit batch size and aggregate execution cost.

How XML-RPC Works

XML-RPC sends HTTP POST requests with XML containing one methodCall, method name and parameters. Responses contain a methodResponse with a value or fault.

Never map arbitrary method names directly to reflection, filesystem paths or privileged internal functions. Maintain an explicit method registry and authorization model.

Serialization and Interoperability

JSON is generally more compact and native to modern web stacks. RFC 8259 calls out interoperability issues such as duplicate member names and number precision; reject out-of-contract JSON rather than relying on parser quirks.

XML supports rich tooling but a larger parser feature set. Legacy XML-RPC interoperability may justify its use, but new services should compare JSON-RPC, REST and gRPC based on identity, gateway, schema and observability needs—not serialization aesthetics alone.

Security Differences

AreaJSON-RPCXML-RPC
TransportAdd TLS/secure underlying transportHTTPS/TLS around HTTP
AuthenticationApplication/transportApplication/HTTP
AuthorizationPer method/objectPer method/object
Parser risksDepth/size, duplicate keys, unsafe deserializationXXE, entity expansion, depth/size, unsafe type handling
Batch abuseOne request can amplify workLarge XML still exhausts resources
DispatchNo arbitrary eval/reflectionNo arbitrary method/path mapping

Method Authorization Is the Main Boundary

RPC makes operations explicit: invoice.approve, user.reset or system.restart. Authentication is not permission. Authorize each method and object/tenant, validate state transitions and separate administrative procedures.

Related Ammune reading: API authorization vs authentication and OWASP BFLA.

Parser Hardening

For JSON, use a standards-compliant parser—never eval()—and limit body size, depth, arrays and batch size. Decide duplicate-key handling and reject values outside the method schema.

For XML-RPC, disable external entities/DTD processing unless explicitly required and safely designed. Apply entity-expansion/document-size limits and use maintained parsers.

Errors, Notifications and Observability

Avoid stack traces, paths or internal exception detail in JSON-RPC errors or XML-RPC faults. JSON-RPC notifications intentionally receive no response, so security-sensitive operations should not rely on notification semantics unless another acknowledgement/audit channel exists.

Log method, authenticated subject, authorization result, correlation ID and outcome without recording secrets or unnecessary sensitive parameters.

Which Should You Choose?

NeedLikely fit
Modern JSON-native RPCJSON-RPC
Batch requests / notificationsJSON-RPC
Legacy XML-RPC interoperabilityXML-RPC
Schema-first binary RPC/streamingConsider gRPC
Resource-oriented public APIConsider HTTP/REST

Gatewaying and Exposing RPC Safely

Many RPC services are safest when they are not directly internet-facing. An API gateway or application façade can terminate authentication, enforce request-size/rate limits and expose only a curated set of RPC methods. This is especially useful for legacy XML-RPC services whose native authentication and observability are limited.

Do not assume the gateway can replace method-level authorization. The gateway may know that a caller can reach /rpc, while only the service knows whether that caller may execute billing.refund for a specific tenant or object. Preserve authenticated identity securely across the gateway boundary and re-enforce authorization close to the operation.

For JSON-RPC batches, define whether gateway limits count the HTTP request or each contained RPC operation. A limit of 100 HTTP requests per minute can still permit thousands of method calls if each request contains a large batch.

BoundaryRecommended control
Internet → gatewayTLS, authentication, body/rate limits
Gateway → RPC serviceAuthenticated service identity and trusted identity propagation
RPC dispatcherAllowlisted methods and per-method schema
Business operationObject/tenant/state authorization
ResponseConsistent error mapping and sensitive-detail suppression

Browser-Facing RPC: Cookies, CORS and CSRF

When RPC is called from a browser, transport and parser security are not enough. If authentication relies on ambient cookies, state-changing RPC methods can become CSRF targets unless the application enforces appropriate CSRF protections. CORS is a browser read-policy mechanism and should not be treated as a replacement for CSRF defense.

Prefer explicit authorization headers/tokens for API-style browser clients where the architecture permits, validate request origin/context where appropriate and use SameSite cookies as defense in depth. Do not assume application/json alone forms a complete CSRF boundary.

Legacy XML-RPC endpoints often use Basic authentication or application sessions. Placing internet-facing legacy RPC behind a gateway/facade can standardize authentication, rate limits and browser-origin policy.

JSON-RPC vs XML-RPC: Security Decision Matrix

QuestionJSON-RPC implicationXML-RPC implication
Need modern browser/tooling support?Usually stronger ecosystem fitOften legacy-oriented
Need batch calls?Native batch model; cap aggregate workNot core protocol behavior
Parser attack surface?JSON depth, duplicate keys, deserialization and batch abuseXML entity/DTD, depth, expansion and type handling
Method authorization?Required per method/objectRequired per method/object
Existing legacy integration?May require migration/adaptorCan preserve compatibility

For a new system, protocol choice should follow ecosystem and interoperability requirements. The decisive security controls—authentication, method/object authorization, schema validation, resource limits and observability—must exist either way.

RPC Security Checklist

  • Use TLS.
  • Authenticate clients/services.
  • Allowlist methods.
  • Enforce method/object authorization.
  • Validate per-method parameters.
  • Limit body/depth/batch/execution cost.
  • Avoid eval/reflection dispatch.
  • Disable unsafe XML entities/DTDs.
  • Handle duplicate JSON fields consistently.
  • Do not leak internal errors.
  • Rate-limit expensive methods.
  • Log identity, method and outcome.

Frequently Asked Questions

Is JSON-RPC more secure than XML-RPC?

Not automatically. JSON-RPC avoids XML-specific entity risks, but both need TLS, authentication, authorization, validation and rate limits.

What transport does JSON-RPC use?

JSON-RPC 2.0 is transport agnostic.

Does XML-RPC define authentication?

No. Authentication is added at the HTTP/application layer.

What is a major XML-RPC parser risk?

Unsafe external entity/DTD handling can create XXE or resource-exhaustion risks.

Does JSON-RPC support batch calls?

Yes, so servers should cap batch size and aggregate execution cost.

Primary References

Protect RPC Methods Like Security-Sensitive APIs

Whichever serialization you use, enforce explicit method authorization, safe parsing, rate limits and runtime monitoring.

© Ammune.ai — API security guidance for modern application environments.