express-openapi-validator
express-openapi-validator copied to clipboard
additionalProperties should default to false (not true) even if undefined
Describe the bug
Right now if you define a route that does not have the additionalProperties key defined, the middleware will allow random properties to be sent to the route. This is a security risk. The only way to block these random properties is to not forget to set additionalProperties: false. As of today, it defaults to true when missing which is not safe. Users should have to explicitly allow additional properties in their schema.
To Reproduce
- Create a route in the API schema
- Do not add
additionalProperties: booleanto the route - Make a request to the route using a param that is not defined in the route
- Observe that request is allowed