This section includes everything that is outside of the source code but is still critical to the security of the product that is being created. Because the issues covered by this kingdom are not directly related to source code, we separated it from the rest of the kingdoms.
tls:context
element defines a set of TLS connection configurations. Among the configurations, the tls:trust-store
element specifies a file that contains certificates from trusted Certificate Authorities that a client uses to verify a certificate presented by a server. By default, the Mule runtime engine verifies the server certificate for every TLS connection.insecure
attribute of the tls:trust-store
element is true
, server certificates are accepted without verification.insecure
attribute to true
. As a result, the Mule runtime engine does not verify the server certificate of any connection with the TLS context named demoTlsContext
. Such a connection is susceptible to a man-in-the-middle attack.
...
<tls:context name="demoTlsContext">
...
<tls:trust-store ... insecure="true" ... />
...
<tls:context/>
...
Denial of Wallet (DoW)
attack can occur if attackers exploit the cost-per-use model of cloud-based AI services by initiating a high volume of requests. This leads to unsustainable financial burdens on the provider. This can result in financial ruin for the provider, as the cost of processing excessive requests becomes unmanageable.max_completion_tokens
parameter to None
can increase the chances of producing excessive data. This can overwhelm the resources of the LLM server and potentially lead to a Denial of Wallet (DoW)
attack.
import os
from openai import OpenAI
client = OpenAI(api_key='OPENAI_API_KEY')
def generate_safe_response(prompt):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
timeout=10,
max_completion_tokens=None,
messages=[
{"role": "user", "content": prompt}
]
)
return completion.choices[0].message
prompt = "Describe the latest advancements in machine learning."
response = generate_safe_response(prompt)
print(response)
max_completion_tokens
parameter limits the length of the output, which helps to ensure that the model does not generate excessively long responses that could cause issues downstream. By controlling the output size, you reduce the risk of generating unintended, potentially harmful content that could lead to security vulnerabilities.security
requirements and target servers
definitions for an API operation will always override the respective global settings. security
requirements and target servers
definitions for an API operation will always override the respective global settings. security
definition.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
{
"openapi" : "3.0.3",
"info" : {
"title" : "My API",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "/"
} ],
"security" : [],
...
}
security
definition.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
openapi: 3.0.3
info:
title: My API
version: 1.0.0
security:
security
definition for an API operation.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform actions that should be restricted to specific user accounts with explicit privileges.security
definition for a sensitive operation. This overrides globally defined security requirements and renders the createUsers
operation vulnerable to unauthorized and unauthenticated access.
{
"openapi": "3.0.0",
"info": {
...
},
"paths": {
"/users": {
"post": {
"security": [],
"summary": "Create a user",
"operationId": "createUsers",
...
}
...
}
}
security
definition for an API operation.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform actions that should be restricted to specific user accounts with explicit privileges.security
definition for a sensitive operation. This overrides globally defined security requirements and renders the createUsers
operation vulnerable to unauthorized and unauthenticated access.
openapi: 3.0.0
info:
...
paths:
/users:
post:
operationId: createUsers
security: []
responses:
'201':
...
security
definition.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
{
"openapi" : "3.0.3",
"info" : {
"title" : "My API",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "https://example.org"
} ],
...
}
security
definition.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
openapi: 3.0.3
info:
title: My API
version: 1.0.0
...
security
definition for an API operation.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform actions that should be restricted to specific user accounts with explicit privileges.security
definition for a sensitive operation. Additionally, without a global security
definition, the createUsers
operation is vulnerable to unauthorized and unauthenticated access.
{
"openapi": "3.0.0",
"info": {
...
},
"paths": {
"/users": {
"post": {
"summary": "Create a user",
"operationId": "createUsers",
...
}
...
}
}
security
definition for an API operation.security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform actions that should be restricted to specific user accounts with explicit privileges.security
definition for a sensitive operation. Additionally, without a global security
definition, the createUsers
operation is vulnerable to unauthorized and unauthenticated access.
openapi: 3.0.0
info:
...
paths:
/users:
post:
operationId: createUsers
responses:
'201':
...
securitySchemes
definition.securitySchemes
definition specifies the security mechanisms that may be used globally or by specific API operations.securitySchemes
definition is typically specified under the reusable components
object and is referenced globally or by specific operations to dictate security requirements for interaction.securitySchemes
definition.
{
"openapi" : "3.0.3",
"info" : {
"title" : "My API",
"version" : "1.0.0"
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"properties": {
...
}
}
}
securitySchemes
definition.securitySchemes
definition specifies the security mechanisms that may be used globally or by specific API operations.securitySchemes
definition is typically specified under the reusable components
object and is referenced globally or by specific operations to dictate security requirements for interaction.securitySchemes
definition.
openapi: 3.0.3
info:
title: My API
version: 1.0.0
components:
schemas:
GeneralError:
type: object
properties:
...
security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition with optional security via the empty {}
item. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
{
"openapi" : "3.0.3",
"info" : {
"title" : "My API",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "/"
} ],
"security" : [ {}, { "oauth_auth" : ["write","read" ]} ],
...
}
security
definition might enable attackers to interact with sensitive API endpoints and allow them to perform operations that should be restricted to specific user accounts with specific privileges.security
definition with optional security via the empty {}
item. APIs that implement this specification might be vulnerable to unauthorized or unauthenticated access to sensitive operations.
openapi: 3.0.3
info:
title: My API
version: 1.0.0
security:
- {}
- oauth_auth:
- write:users
- read:users
{}
in the security
definition for a sensitive operation. This overrides globally defined security requirements and renders the createUsers
operation vulnerable to unauthorized and unauthenticated access.
{
"openapi": "3.0.0",
"info": {
...
},
"paths": {
"/users": {
"post": {
"security": [
{},
{
"my_auth": [
"write:users"
]
}
],
"summary": "Create a user",
"operationId": "createUsers",
...
}
...
}
}
{}
in the security
definition for a sensitive operation. This overrides globally defined security requirements and renders the createUsers
operation vulnerable to unauthorized and unauthenticated access.
openapi: 3.0.0
info:
...
paths:
/users:
post:
operationId: createUsers
security:
- {}
- oauth_auth:
- write:users
- read:users
responses:
'201':
...
allow_url_fopen
option allows PHP functions that accept a filename to operate on remote files using an HTTP or FTP URL. The option, which was introduced in PHP 4.0.4 and is enabled by default, is dangerous because it can allow attackers to introduce malicious content into an application. At best, operating on remote files leaves the application susceptible to attackers who alter the remote file to include malicious content. At worst, if attackers can control a URL that the application operates on, then they can inject arbitrary malicious content into the application by supplying a URL to a remote server.$file
is controlled by a request parameter, an attacker could violate the programmer's assumptions by providing a URL to a remote file.
<?php
$file = fopen ($_GET["file"], "r");
if (!$file) {
// handle errors
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
// operate on file content
}
fclose($file);
?>
allow_url_include
option allows PHP functions that specify a file for inclusion in the current page, such as include()
and require()
, to accept an HTTP or FTP URL to a remote file. The option, which was introduced in PHP 5.2.0 and is disabled by default, is dangerous because it can allow attackers to introduce malicious content into an application. At best, including remote files leaves the application susceptible to attackers who alter the remote file to include malicious content. At worst, if attackers can control a URL that the application uses to specify the remote file to include, then they can inject arbitrary malicious content into the application by supplying a URL to a remote server.cgi.force_redirect
, which is enabled by default, is disabled, then attackers with access to /cgi-bin/php can use the permissions of the PHP interpreter to access arbitrary Web documents, thus bypassing any access control checks that would have been performed by the server.dl
can be used to circumvent open_basedir
restrictions.enable_dl
configuration allows dynamic loading of libraries. These could potentially allow an attacker to circumvent the restrictions set with the open_basedir configuration, and potentially allow access to any file on the system.enable_dl
can make it easier for attackers to exploit other vulnerabilities.file_uploads
option allows PHP users to upload arbitrary files to the server. Permitting users to upload files does not represent a security vulnerability itself. However, this capability can enable a variety attacks because it gives malicious users an avenue to introduce data into the server environment.
<?php
$udir = 'upload/'; // Relative path under Web root
$ufile = $udir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ufile)) {
echo "Valid upload received\n";
} else {
echo "Invalid upload rejected\n";
} ?>