Imagine your API definition only allows HTTPS connections and has two operations that both have multiple security requirements defined. You are using a secure OAuth 2.0 flow in your OAuth2
scheme. The operation /Cat
is sensitive, while the operation /Dog
is not sensitive at all. You have used the x-42c-sensitivity
extension to tell Security Audit that these operations should not be considered equal:
{
"servers": [
{
"url": "https://my.api.server.com/",
"description": "API server"
}
],
// ...
"paths": {
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] },
{ "Oauth2": ["readOnly"], "BasicAuth" },
{ "apiKey1": [],"apiKey2": [] }
],
// ...
}
"/Dog": {
"x-42c-sensitivity" : 1,
// ...
"security" : [
{ "BasicAuth": [] },
{ "Oauth2": ["readOnly"], "BasicAuth" },
{ "apiKey1": [],"apiKey2": [] }
]
// ...
}
}
}
Security Audit checks the security requirements, what issues should be raised for them, and what is their severity. Only HTTPS is allowed, so no issues on cleartext are raised. The operation /Dog
is marked as not sensitive, so Security Audit raises no issues on it. For the operation /Cat
, Security Audit notes the added sensitivity from x-42c-sensitivity
and gives the following rating:
BasicAuth
: issue severity is 3
OAuth2
: issue severity is 1
apiKey1
and apiKey2
: issue severity is 3
{
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] }, -->3
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1,3
{ "apiKey1": [],"apiKey2": [] } --> 3, 3
],
// ...
}
"/Dog": {
"x-42c-sensitivity" : 1,
// ...
"security" : [
{ "BasicAuth": [] }, --> 1
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1,1
{ "apiKey1": [],"apiKey2": [] } --> 1,1
]
// ...
}
}
Security Audit ignores BasicAuth
that is applied together with OAuth2
, because the more secure OAuth2
provides protection for it:
{
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] }, --> 3
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1, 3
{ "apiKey1": [],"apiKey2": [] } --> 3, 3
]
}
}
OAuth 2.0 over HTTPS uses a good flow and is secure, so Security Audit does not raise any issues for it:
{
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] }, --> 3
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1
{ "apiKey1": [],"apiKey2": [] } --> 3, 3
]
}
}
This means that only the three security requirements in the operation /Cat
rated at severity 3
will affect the audit score. Now, Security Audit is ready to calculate the score impact.
The maximum points for security is 30 points. Security risks in more sensitive operations pose a bigger threat, so they get a bigger share of the total pot, but the maximum grade is divided between all operations in the API. So even though the operation /Dog
did not raise any issues and does not affect the audit score at all, it does have a role to play in the calculations.
In this example, the potential points are allocated to the two operations as follows:
/Cat
counts 24 points towards the maximum of 30
/Dog
counts 6 points
Now that Security Audit knows how many points the operation /Cat
could have gotten, it can count how many points the found issues take away from the audit score. In the end, the three issues found reduce the score for security and the audit score of your API by 18 points to 12/30.
You decide to remove the lone BasicAuth
because you realize that you do not actually need it:
{
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] }, --> 3
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1
{ "apiKey1": [],"apiKey2": [] } --> 3, 3
]
}
}
However, this is not yet enough to increase your audit score, because you still have the issues from apiKey1
and apiKey2
left. The found severity 3
issues still take away 18 points as before, but they are now reallocated between the two remaining issues. Only after you have fixed the issues with apiKey1
and apiKey2
does the severity of the found issues raise to 1
from the OAuth2
and your audit score increases:
{
"/Cat": {
"x-42c-sensitivity" : 4,
// ...
"security" : [
{ "BasicAuth": [] }, --> 3
{ "Oauth2": ["readOnly"], "BasicAuth" }, --> 1
{ "apiKey1": [],"apiKey2": [] } --> 3, 3
]
}
}