Additional Properties Too Permissive
- Query id: 9f88c88d-824d-4d9a-b985-e22977046042
- Query name: Additional Properties Too Permissive
- Platform: OpenAPI
- Severity: Low
- Category: Insecure Configurations
- CWE: 665
- 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'
Negative test num. 3 - json file
{
"components": {},
"info": {
"description": "Swagger auto-generated from learnt schema for ves-io-s-gorman-s-gorman-sent4-http-load-balancer",
"title": "ves-io-s-gorman-s-gorman-sent4-http-load-balancer",
"version": "2023-06-21 17:30:59"
},
"openapi": "3.0.3",
"paths": {
"/": {
"get": {
"description": "Swagger auto-generated from learnt schema",
"parameters": [
{
"description": "Integer",
"in": "header",
"name": "upgrade-insecure-requests",
"schema": {
"pattern": "-?\\d+",
"type": "string"
}
}
]
}
},
"servers": [
{
"url": "http://sent4.volterra.plutometal.com"
},
{
"url": "https://sent4.volterra.plutometal.com"
}
]
}
}