wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
846 stars 786 forks source link

Regex mediator doesn't work as expected for JSON Payloads #7928

Closed HiranyaKavishani closed 4 years ago

HiranyaKavishani commented 4 years ago

Description:

Regex mediator doesn't work as expected for JSON payloads with SQL injection. There are two issues,

  1. JSON payload issue

When using the following like payloads, it didn't detect the SQL injection attacks.

{
  "customerName": "abc",
  "delivered": true,
  "address": "xxxx",
  "pizzaType": "drop table",
  "creditCardNumber": "string",
  "quantity": 0,
  "orderId": "string"
}

But with following payload, it is worked

{
   "food": {
      "name": "Homestyle Breakfast",
      "price": "drop table",
      "description": "Two eggs, bacon or sausage, toast, and our ever-popular hash browns",
      "calories": "950"
   }
}
  1. After the 1st API call, it always sends a bad request error for the rest of the API calls until that API is republished.

Response:

<am:fault xmlns:am="http://wso2.org/apimanager">
  <am:code>400</am:code>
  <am:message>Bad Request</am:message>
  <am:description>Threat detection key words are missing</am:description>
</am:fault>

Steps to reproduce:

  1. Deploy an API adding the regex policy in the run time configuration at the publisher portal
  2. Try JSON payloads with SQL injection.

Affected Product Version:

3.00, 3.1.0

Environment details (with versions):


Optional Fields

Related Issues:

Suggested Labels:

Suggested Assignees:

HiranyaKavishani commented 4 years ago

Fixed with https://github.com/wso2/product-apim/issues/7971