Host With Invalid Pattern
- Query id: 3d7d7b6c-fb0a-475e-8a28-c125e30d15f0
- Query name: Host With Invalid Pattern
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- CWE: 20
- URL: Github
Description¶
Host field should be an IP or a valid host name
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"host": "kics.io/test",
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
Positive test num. 2 - yaml file
---
swagger: '2.0'
info:
title: Simple API Overview
version: 1.0.0
host: kics.io/test
paths:
"/":
get:
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: integer
operationId: listVersionsv2
summary: List API versions
responses:
'200':
description: 200 response
parameters:
limitParam:
name: limit
in: body
description: max records to return
required: true
schema:
type: integer
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"host": "127.0.0.1:8080",
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
Negative test num. 2 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"host": "kics.io",
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
Negative test num. 3 - yaml file
swagger: '2.0'
info:
title: Simple API Overview
version: 1.0.0
host: 127.0.0.1
paths:
"/":
get:
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: integer
operationId: listVersionsv2
summary: List API versions
responses:
'200':
description: 200 response
parameters:
limitParam:
name: limit
in: body
description: max records to return
required: true
schema:
type: integer
Negative test num. 4 - yaml file
swagger: '2.0'
info:
title: Simple API Overview
version: 1.0.0
host: kics.io
paths:
"/":
get:
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: integer
operationId: listVersionsv2
summary: List API versions
responses:
'200':
description: 200 response
parameters:
limitParam:
name: limit
in: body
description: max records to return
required: true
schema:
type: integer