Additional Properties Too Permissive
- Query id: 9f88c88d-824d-4d9a-b985-e22977046042
- Query name: Additional Properties Too Permissive
- Platform: OpenAPI
- Severity: Medium
- Category: Insecure Configurations
- URL: Github
Description¶
Objects should not accept 'additionalProperties' if it is possible
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "true"
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "true"
},
{
"type": "string",
"additionalProperties": "false"
}
]
}
}
}
}
Positive test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
schema:
type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'true'
components:
schemas:
MyObject:
oneOf:
- type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'true'
- type: string
additionalProperties: 'false'
Positive test num. 3 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "false"
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "true"
},
{
"type": "string",
"additionalProperties": "true"
}
]
}
}
}
}
Positive test num. 4 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
schema:
type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'false'
components:
schemas:
MyObject:
oneOf:
- type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'true'
- type: string
additionalProperties: 'true'
Positive test num. 5 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "true"
},
{
"type": "string",
"additionalProperties": "false"
}
]
}
}
}
}
Positive test num. 6 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
schema:
type: object
properties:
id:
type: string
name:
type: string
components:
schemas:
MyObject:
oneOf:
- type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'true'
- type: string
additionalProperties: 'false'
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "false"
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": "true"
},
{
"type": "string",
"additionalProperties": "false"
}
]
}
}
}
}
Negative test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
schema:
type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'false'
components:
schemas:
MyObject:
oneOf:
- type: object
properties:
id:
type: string
name:
type: string
additionalProperties: 'true'
- type: string
additionalProperties: 'false'