Securing JSON APIs

JSON APIs can expose you to a variety of Information Security problems. Most of them arise from handling request bodies in the form of JSON documents.

Depending on the functions your API allows access to, a badly secured JSON API can expose you to spoofing, tampering, repudiation, information disclosure and denial of service. While some of these threats require in-depth protections, others can already be eliminated by very broad restrictions.

JSON Protection

Already on an API-wide (or global) level, you can protect yourself against certain attacks. Membrane API Gateway's JSON Protection feature protects you against both.

Usage

<spring:beans xmlns="http://membrane-soa.org/proxies/1/"
                xmlns:spring="http://www.springframework.org/schema/beans"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd">
  <router>

      <serviceProxy port="2000">
          <jsonProtection />
          <target host="api.predic8.de" port="80"/>
      </serviceProxy>

  </router>

</spring:beans>
More fine-grained configuration options are also available.

Other Protections

Attacks using Injection or Cross Site Scripting usually rely on using special characters like single quotes (') or left angle brackets (<).

Using JSON Schema Validation to validate Requests received by the Gateway, usage of these types of characters can be prohibited. Nowadays, JSON Schema Validation is usually done in conjuction with OpenAPI.

Rate Limiting might also help reduce the exploitability of existing weaknesses so far, that they become irrelevant (e.g. guessing the correct password).