Default behavior for additionalProperties has changed in OAS3.1#26
Default behavior for additionalProperties has changed in OAS3.1#26philsturgeon wants to merge 2 commits into
Conversation
|
@DavidBiesack I'd be interested in your thoughts on this, as the default behavior for additional properties has changed in OAS 3.1 to make it more permissive. The rules you wrote for #50 are the same as the old rules: they'll look for this keyword and if used will restrict it to false, or an object with maxProperties, but perhaps 3.1 needs a new approach? |
the functionality in the repo was contradicting itself, saying it had to be false but also another rule allowed it to be an object. OAS3.0 is additionalPorperties: false by default, and OAS3.1 is additionalProperties: true by default. It seems like we should address that, by making OAS3.1 users use additionalProperties, and saying it either needs to be false or an object with maxProperties set?
2c74abf to
f8c5e7b
Compare
|
@philsturgeon |
|
JSON Schema has always allowed additional properties by default, that hasn't changed. What did change in OpenAPI v3.1 was In v3.0.3 the Schema Object section of the spec says:
In v3.1.1 the Schema Object section of the spec says:
Another change is from this in 3.0.x
To this in 3.1.x:
tl;dr: Y'all can do what you want now. |
|
@philsturgeon That 3.0.3 vs. 3.1.0 language is not talking about the JSON schema |
| message: "Objects should not allow unconstrained additionalProperties.", | ||
| description: | ||
| "By default JSON Schema allows additional properties, which can potentially lead to mass assignment issues, where unspecified fields are passed to the API without validation. Disable them with `additionalProperties: false` or add `maxProperties`", | ||
| "Additional properties are enabled by default in modern OpenAPI and JSON Schema as it helps keep your API forwards compatible, but it can potentially lead to mass assignment issues, where unspecified fields are passed to the API without validation. Disable additional properties explicitly with `additionalProperties: false`, or constrain the additional properties by providing a schema for their validation: `additionalProperties: { type: ... } }`.", |
There was a problem hiding this comment.
or additionalProperties: { '$ref: .... }
| message: "Objects should not allow unconstrained additionalProperties.", | ||
| description: | ||
| "By default JSON Schema allows additional properties, which can potentially lead to mass assignment issues, where unspecified fields are passed to the API without validation. Disable them with `additionalProperties: false` or add `maxProperties`", | ||
| "Additional properties are enabled by default in modern OpenAPI and JSON Schema as it helps keep your API forwards compatible, but it can potentially lead to mass assignment issues, where unspecified fields are passed to the API without validation. Disable additional properties explicitly with `additionalProperties: false`, or constrain the additional properties by providing a schema for their validation: `additionalProperties: { type: ... } }`.", |
There was a problem hiding this comment.
double } } should be just } at the end of the sentence
Well exactly. OWASP does not have opinions about how OpenAPI or JSON Schema is written. OWASP is concerned about whether additional keywords can be sent than you're expecting. In OpenAPI v3.0 the assumption was default off, and you would have to say "yeah thats fine" with additionalProperties: true, so we'd look for that and say "dont do that". In OpenAPI v3.1 the assumption is that you can, so it feels like we should tell everyone to turn that off. Right? It feels like its a bigger change than just changing additionalProperties to unevaluatedProperties, it's a change in the default behavior which means a change in how we approach the rules. |
the functionality in the repo was contradicting itself, saying it had to be false but also another rule allowed it to be an object. OAS3.0 is additionalPorperties: false by default, and OAS3.1 is additionalProperties: true by default. It seems like we should address that, by making OAS3.1 users use additionalProperties, and saying it either needs to be false or an object with maxProperties set?
Motivation and Context
#InsertIssueNumberHere
Description
How Has This Been Tested?
Screenshot(s)/recordings(s)
Types of changes
Checklist